(rmail-decode-babyl-format): Message modified.
[bpt/emacs.git] / src / sysdep.c
index 9a73b1c..240b0f8 100644 (file)
@@ -147,7 +147,7 @@ extern int errno;
 #undef TIOCSWINSZ
 #endif
 
-#ifdef USG
+#if defined(USG) || defined(DGUX)
 #include <sys/utsname.h>
 #include <string.h>
 #ifndef MEMORY_IN_STRING_H
@@ -162,7 +162,7 @@ extern int errno;
 #include <sys/ptem.h>
 #endif
 #endif /* TIOCGWINSZ or ISC4_0 */
-#endif /* USG */
+#endif /* USG or DGUX */
 
 extern int quit_char;
 
@@ -255,6 +255,7 @@ change_input_fd (fd)
 
 /* Discard pending input on descriptor input_fd.  */
 
+void
 discard_tty_input ()
 {
 #ifndef WINDOWSNT
@@ -313,6 +314,7 @@ stuff_char (c)
 
 #endif /* SIGTSTP */
 \f
+void
 init_baud_rate ()
 {
   if (noninteractive)
@@ -408,6 +410,7 @@ wait_for_termination_signal ()
 /* Wait for subprocess with process id `pid' to terminate and
    make sure it will get eliminated (not remain forever as a zombie) */
 
+void
 wait_for_termination (pid)
      int pid;
 {
@@ -505,6 +508,7 @@ wait_for_termination (pid)
  *      (may flush input as well; it does not matter the way we use it)
  */
  
+void
 flush_pending_output (channel)
      int channel;
 {
@@ -532,6 +536,7 @@ flush_pending_output (channel)
     It should not echo or do line-editing, since that is done
     in Emacs.  No padding needed for insertion into an Emacs buffer.  */
 
+void
 child_setup_tty (out)
      int out;
 {
@@ -637,11 +642,15 @@ child_setup_tty (out)
 struct save_signal
 {
   int code;
-  SIGTYPE (*handler) ();
+  SIGTYPE (*handler) P_ ((int));
 };
 
+static void save_signal_handlers P_ ((struct save_signal *));
+static void restore_signal_handlers P_ ((struct save_signal *));
+
 /* Suspend the Emacs process; give terminal to its superior.  */
 
+void
 sys_suspend ()
 {
 #ifdef VMS
@@ -711,10 +720,11 @@ sys_suspend ()
 
 /* Fork a subshell.  */
 
+void
 sys_subshell ()
 {
 #ifndef VMS
-#ifdef MSDOS   /* Demacs 1.1.2 91/10/20 Manabu Higashida */
+#ifdef DOS_NT  /* Demacs 1.1.2 91/10/20 Manabu Higashida */
   int st;
   char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS.  */
 #endif
@@ -752,11 +762,7 @@ sys_subshell ()
   str[len] = 0;
  xyzzy:
 
-#ifdef WINDOWSNT
-  pid = -1;
-#else /* not WINDOWSNT */
-
-#ifdef MSDOS
+#ifdef DOS_NT
   pid = 0;
 #if __DJGPP__ > 1
   save_signal_handlers (saved_handlers);
@@ -769,11 +775,10 @@ sys_subshell ()
 #endif
 
   if (pid == 0)
-#endif /* not WINDOWSNT */
     {
       char *sh = 0;
 
-#ifdef MSDOS    /* MW, Aug 1993 */
+#ifdef DOS_NT    /* MW, Aug 1993 */
       getwd (oldwd);
       if (sh == 0)
        sh = (char *) egetenv ("SUSPEND");      /* KFS, 1994-12-14 */
@@ -811,10 +816,9 @@ sys_subshell ()
 #ifdef  WINDOWSNT
       /* Waits for process completion */
       pid = _spawnlp (_P_WAIT, sh, sh, NULL);
+      chdir (oldwd);
       if (pid == -1)
        write (1, "Can't execute subshell", 22);
-
-      take_console ();
 #else   /* not WINDOWSNT */
       execlp (sh, sh, 0);
       write (1, "Can't execute subshell", 22);
@@ -829,7 +833,7 @@ sys_subshell ()
   synch_process_alive = 1;
 #endif
 
-#ifndef MSDOS
+#ifndef DOS_NT
   wait_for_termination (pid);
 #endif
   restore_signal_handlers (saved_handlers);
@@ -837,17 +841,19 @@ sys_subshell ()
 #endif /* !VMS */
 }
 
+static void
 save_signal_handlers (saved_handlers)
      struct save_signal *saved_handlers;
 {
   while (saved_handlers->code)
     {
       saved_handlers->handler
-       = (SIGTYPE (*) ()) signal (saved_handlers->code, SIG_IGN);
+       = (SIGTYPE (*) P_ ((int))) signal (saved_handlers->code, SIG_IGN);
       saved_handlers++;
     }
 }
 
+static void
 restore_signal_handlers (saved_handlers)
      struct save_signal *saved_handlers;
 {
@@ -862,6 +868,7 @@ restore_signal_handlers (saved_handlers)
 
 int old_fcntl_flags;
 
+void
 init_sigio (fd)
      int fd;
 {
@@ -872,6 +879,7 @@ init_sigio (fd)
   interrupts_deferred = 0;
 }
 
+void
 reset_sigio ()
 {
   unrequest_sigio ();
@@ -879,6 +887,7 @@ reset_sigio ()
 
 #ifdef FASYNC          /* F_SETFL does not imply existence of FASYNC */
 
+void
 request_sigio ()
 {
   if (read_socket_hook)
@@ -892,6 +901,7 @@ request_sigio ()
   interrupts_deferred = 0;
 }
 
+void
 unrequest_sigio ()
 {
   if (read_socket_hook)
@@ -907,6 +917,7 @@ unrequest_sigio ()
 #else /* no FASYNC */
 #ifdef STRIDE          /* Stride doesn't have FASYNC - use FIOASYNC */
 
+void
 request_sigio ()
 {
   int on = 1;
@@ -918,6 +929,7 @@ request_sigio ()
   interrupts_deferred = 0;
 }
 
+void
 unrequest_sigio ()
 {
   int off = 0;
@@ -935,6 +947,7 @@ unrequest_sigio ()
 
 #include <termios.h>
 
+void
 request_sigio ()
 {
   int on = 1;
@@ -950,6 +963,7 @@ request_sigio ()
   sigprocmask(SIG_UNBLOCK, &st, (sigset_t *)0);
 }
 
+void
 unrequest_sigio ()
 {
   int off = 0;
@@ -963,6 +977,7 @@ unrequest_sigio ()
 
 #else /* ! _CX_UX */
 
+void
 request_sigio ()
 {
   if (read_socket_hook)
@@ -971,6 +986,7 @@ request_sigio ()
   croak ("request_sigio");
 }
  
+void
 unrequest_sigio ()
 {
   if (read_socket_hook)
@@ -1220,6 +1236,7 @@ static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1};
 static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
 #endif 
 
+void
 init_sys_modes ()
 {
   struct emacs_tty tty;
@@ -1550,7 +1567,13 @@ init_sys_modes ()
 #ifdef HAVE_WINDOW_SYSTEM
   /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
      needs the initialization code below.  */
-  if (! read_socket_hook && EQ (Vwindow_system, Qnil))
+  if (EQ (Vwindow_system, Qnil)
+#ifndef WINDOWSNT
+      /* When running in tty mode on NT/Win95, we have a read_socket
+        hook, but still need the rest of the initialization code below.  */
+      && (! read_socket_hook)
+#endif
+      )
 #endif
     set_terminal_modes ();
 
@@ -1584,6 +1607,7 @@ tabs_safe_p ()
    Store number of lines into *HEIGHTP and width into *WIDTHP.
    We store 0 if there's no valid information.  */
 
+void
 get_frame_size (widthp, heightp)
      int *widthp, *heightp;
 {
@@ -1679,6 +1703,7 @@ set_window_size (fd, height, width)
 \f
 /* Prepare the terminal for exiting Emacs; move the cursor to the
    bottom of the frame, turn off interrupt-driven I/O, etc.  */
+void
 reset_sys_modes ()
 {
   if (noninteractive)
@@ -1691,7 +1716,13 @@ reset_sys_modes ()
 #ifdef HAVE_WINDOW_SYSTEM
   /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
      needs the clean-up code below.  */
-  if (read_socket_hook || !EQ (Vwindow_system, Qnil))
+  if (!EQ (Vwindow_system, Qnil)
+#ifndef WINDOWSNT
+      /* When running in tty mode on NT/Win95, we have a read_socket
+        hook, but still need the rest of the clean-up code below.  */
+      || read_socket_hook
+#endif
+      )
     return;
 #endif
   cursor_to (FRAME_HEIGHT (selected_frame) - 1, 0);
@@ -1765,6 +1796,7 @@ reset_sys_modes ()
 
 /* Set up the proper status flags for use of a pty.  */
 
+void
 setup_pty (fd)
      int fd;
 {
@@ -2022,6 +2054,7 @@ sys_sleep (timeval)
     SYS$WAITFR (timer_ef);       /* Wait for timer expiry only */
 }
 
+void
 init_sigio (fd)
      int fd;
 {
@@ -2033,11 +2066,13 @@ reset_sigio ()
   unrequest_sigio ();
 }
 
+void
 request_sigio ()
 {
   croak ("request sigio");
 }
 
+void
 unrequest_sigio ()
 {
   croak ("unrequest sigio");
@@ -2235,55 +2270,62 @@ init_system_name ()
 #ifndef CANNOT_DUMP
   if (initialized)
 #endif /* not CANNOT_DUMP */
-    {
-      struct hostent *hp;
-      int count;
-      for (count = 0;; count++)
-       {
+    if (! index (hostname, '.'))
+      {
+       struct hostent *hp;
+       int count;
+       for (count = 0;; count++)
+         {
 #ifdef TRY_AGAIN
-         h_errno = 0;
+           h_errno = 0;
 #endif
-         hp = gethostbyname (hostname);
+           hp = gethostbyname (hostname);
 #ifdef TRY_AGAIN
-         if (! (hp == 0 && h_errno == TRY_AGAIN))
+           if (! (hp == 0 && h_errno == TRY_AGAIN))
 #endif
-           break;
-         if (count >= 5)
-           break;
-         Fsleep_for (make_number (1), Qnil);
-       }
-      if (hp)
-       {
-         char *fqdn = (char *) hp->h_name;
-         char *p;
-
-         if (!index (fqdn, '.'))
-           {
-             /* We still don't have a fully qualified domain name.
-                Try to find one in the list of alternate names */
-             char **alias = hp->h_aliases;
-             while (*alias && !index (*alias, '.'))
-               alias++;
-             if (*alias)
-               fqdn = *alias;
-           }
-         hostname = fqdn;
+             break;
+           if (count >= 5)
+             break;
+           Fsleep_for (make_number (1), Qnil);
+         }
+       if (hp)
+         {
+           char *fqdn = (char *) hp->h_name;
+           char *p;
+
+           if (!index (fqdn, '.'))
+             {
+               /* We still don't have a fully qualified domain name.
+                  Try to find one in the list of alternate names */
+               char **alias = hp->h_aliases;
+               while (*alias && !index (*alias, '.'))
+                 alias++;
+               if (*alias)
+                 fqdn = *alias;
+             }
+           hostname = fqdn;
 #if 0
-         /* Convert the host name to lower case.  */
-         /* Using ctype.h here would introduce a possible locale
-            dependence that is probably wrong for hostnames.  */
-         p = hostname;
-         while (*p)
-           {
-             if (*p >= 'A' && *p <= 'Z')
-               *p += 'a' - 'A';
-             p++;
-           }
+           /* Convert the host name to lower case.  */
+           /* Using ctype.h here would introduce a possible locale
+              dependence that is probably wrong for hostnames.  */
+           p = hostname;
+           while (*p)
+             {
+               if (*p >= 'A' && *p <= 'Z')
+                 *p += 'a' - 'A';
+               p++;
+             }
 #endif
-       }
-    }
+         }
+      }
 #endif /* HAVE_SOCKETS */
-#if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) || HAVE_GETDOMAINNAME
+  /* We used to try using getdomainname here,
+     but NIIBE Yutaka <gniibe@etl.go.jp> says that
+     getdomainname gets the NIS/YP domain which often is not the same
+     as in Internet domain name.  */
+#if 0 /* Turned off because sysinfo is not really likely to return the
+        correct Internet domain.  */
+#if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN))
   if (! index (hostname, '.'))
     {
       /* The hostname is not fully qualified.  Append the domain name.  */
@@ -2295,7 +2337,6 @@ init_system_name ()
        {
          char *domain = (char *) alloca (domain_size + 1);
          char *fqdn = (char *) alloca (hostlen + 1 + domain_size + 1);
-#if HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)
          int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size);
          if (sys_domain_size <= 0)
            break;
@@ -2304,23 +2345,6 @@ init_system_name ()
              domain_size = sys_domain_size;
              continue;
            }
-#else /* HAVE_GETDOMAINNAME */
-         if (getdomainname (domain, domain_size - 1) != 0 || ! *domain)
-           break;
-         domain[domain_size - 1] = '\0';
-         if (strlen (domain) == domain_size - 1)
-           {
-             domain_size *= 2;
-             continue;
-           }
-         /* If we get an answer which means "domain unknown",
-            don't use a domain.  */
-         if (!strcmp (domain, "(none)"))
-           {
-             *domain = 0;
-             break;
-           }
-#endif /* HAVE_GETDOMAINNAME */
          strcpy (fqdn, hostname);
          if (domain[0] == '.')
            strcpy (fqdn + hostlen, domain);
@@ -2333,7 +2357,8 @@ init_system_name ()
          break;
        }
     }
-#endif /*! ((HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) || HAVE_GETDOMAINNAME)*/
+#endif /* HAVE_SYSINFO && defined (SI_SRPC_DOMAIN) */
+#endif /* 0 */
   Vsystem_name = build_string (hostname);
 #endif /* HAVE_GETHOSTNAME */
 #endif /* VMS */
@@ -2622,6 +2647,7 @@ sys_open (path, oflag, mode)
     return open (path, oflag);
 }
 
+void
 init_sigio (fd)
      int fd;
 {
@@ -2639,6 +2665,7 @@ reset_sigio ()
   ioctl (0, TIOCLSET, &lmode);
 }
 
+void
 request_sigio ()
 {
   sigrelse (SIGTINT);
@@ -2646,6 +2673,7 @@ request_sigio ()
   interrupts_deferred = 0;
 }
 
+void
 unrequest_sigio ()
 {
   sighold (SIGTINT);