#include "blockinput.h"
#undef NULL
-#ifdef HAVE_TERMIOS_H
-#include <termios.h>
-#endif
-
#define min(x,y) ((x) > (y) ? (y) : (x))
/* In this file, open, read and write refer to the system calls,
#undef TIOCSWINSZ
#endif
-#ifdef USG
+#if defined(USG) || defined(DGUX)
#include <sys/utsname.h>
#include <string.h>
#ifndef MEMORY_IN_STRING_H
#include <sys/ptem.h>
#endif
#endif /* TIOCGWINSZ or ISC4_0 */
-#endif /* USG */
+#endif /* USG or DGUX */
extern int quit_char;
};
#endif
-#ifdef HAVE_TERMIOS_H
+#if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T)
+extern short ospeed;
+#else
+#if defined (HAVE_TERMIOS_H) && defined (LINUX)
+#include <termios.h>
+/* HJL's version of libc is said to need this on the Alpha.
+ On the other hand, DEC OSF1 on the Alpha needs ospeed to be a short. */
extern speed_t ospeed;
#else
extern short ospeed;
#endif
+#endif
/* The file descriptor for Emacs's input terminal.
Under Unix, this is normally zero except when using X;
under VMS, we place the input channel number here. */
int input_fd;
+
+void croak P_ ((char *));
+
+
\f
/* Specify a different file descriptor for further input operations. */
/* Discard pending input on descriptor input_fd. */
+void
discard_tty_input ()
{
#ifndef WINDOWSNT
/* Arrange for character C to be read as the next input from
the terminal. */
+void
stuff_char (c)
char c;
{
#endif /* SIGTSTP */
\f
+void
init_baud_rate ()
{
if (noninteractive)
}
/*ARGSUSED*/
+void
set_exclusive_use (fd)
int fd;
{
/* 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;
{
* (may flush input as well; it does not matter the way we use it)
*/
+void
flush_pending_output (channel)
int 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;
{
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
/* 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
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);
#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 */
#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);
synch_process_alive = 1;
#endif
-#ifndef MSDOS
+#ifndef DOS_NT
wait_for_termination (pid);
#endif
restore_signal_handlers (saved_handlers);
#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;
{
int old_fcntl_flags;
+void
init_sigio (fd)
int fd;
{
interrupts_deferred = 0;
}
+void
reset_sigio ()
{
unrequest_sigio ();
#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */
+void
request_sigio ()
{
if (read_socket_hook)
interrupts_deferred = 0;
}
+void
unrequest_sigio ()
{
if (read_socket_hook)
#else /* no FASYNC */
#ifdef STRIDE /* Stride doesn't have FASYNC - use FIOASYNC */
+void
request_sigio ()
{
int on = 1;
interrupts_deferred = 0;
}
+void
unrequest_sigio ()
{
int off = 0;
#include <termios.h>
+void
request_sigio ()
{
int on = 1;
sigprocmask(SIG_UNBLOCK, &st, (sigset_t *)0);
}
+void
unrequest_sigio ()
{
int off = 0;
#else /* ! _CX_UX */
+void
request_sigio ()
{
if (read_socket_hook)
croak ("request_sigio");
}
+void
unrequest_sigio ()
{
if (read_socket_hook)
When we are in the foreground, but not started in our own process
group, redirect the TTY to point to our own process group. We need
to be in our own process group to receive SIGIO properly. */
+void
narrow_foreground_group ()
{
int me = getpid ();
}
/* Set the tty to our original foreground group. */
+void
widen_foreground_group ()
{
if (inherited_pgroup != getpid ())
/* Retrieve the primary parameters - baud rate, character size, etcetera. */
#ifdef HAVE_TCATTR
/* We have those nifty POSIX tcmumbleattr functions. */
+ bzero (&settings->main, sizeof (settings->main));
if (tcgetattr (fd, &settings->main) < 0)
return -1;
{
struct termios new;
+ bzero (&new, sizeof (new));
/* Get the current settings, and see if they're what we asked for. */
tcgetattr (fd, &new);
/* We cannot use memcmp on the whole structure here because under
static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
#endif
+void
init_sys_modes ()
{
struct emacs_tty tty;
tty = old_tty;
#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
- Vtty_erase_char = old_tty.main.c_cc[VERASE];
+ XSETINT (Vtty_erase_char, old_tty.main.c_cc[VERASE]);
#ifdef DGUX
/* This allows meta to be sent on 8th bit. */
tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use
of C-z */
#endif /* VSWTCH */
+
#if defined (mips) || defined (HAVE_TCATTR)
#ifdef VSUSP
tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */
#ifdef VDISCARD
tty.main.c_cc[VDISCARD] = CDISABLE;
#endif /* VDISCARD */
+
+ if (flow_control)
+ {
+#ifdef VSTART
+ tty.main.c_cc[VSTART] = '\021';
+#endif /* VSTART */
+#ifdef VSTOP
+ tty.main.c_cc[VSTOP] = '\023';
+#endif /* VSTOP */
+ }
+ else
+ {
#ifdef VSTART
- tty.main.c_cc[VSTART] = CDISABLE;
+ tty.main.c_cc[VSTART] = CDISABLE;
#endif /* VSTART */
#ifdef VSTOP
- tty.main.c_cc[VSTOP] = CDISABLE;
+ tty.main.c_cc[VSTOP] = CDISABLE;
#endif /* VSTOP */
+ }
#endif /* mips or HAVE_TCATTR */
+
#ifdef SET_LINE_DISCIPLINE
/* Need to explicitly request TERMIODISC line discipline or
Ultrix's termios does not work correctly. */
tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON;
#else /* not VMS (BSD, that is) */
#ifndef DOS_NT
- Vtty_erase_char = tty.main.sg_erase;
+ XSETINT (Vtty_erase_char, tty.main.sg_erase);
tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
if (meta_key)
tty.main.sg_flags |= ANYP;
#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 ();
/* Return nonzero if safe to use tabs in output.
At the time this is called, init_sys_modes has not been done yet. */
+int
tabs_safe_p ()
{
struct emacs_tty tty;
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;
{
\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)
#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);
/* Set up the proper status flags for use of a pty. */
+void
setup_pty (fd)
int fd;
{
This is called each time Emacs is resumed, also, but does nothing
because input_chain is no longer zero. */
+void
init_vms_input ()
{
int status;
/* Deassigning the input channel is done before exiting. */
+void
stop_vms_input ()
{
return SYS$DASSGN (input_fd);
/* Request reading one character into the keyboard buffer.
This is done as soon as the buffer becomes empty. */
+void
queue_kbd_input ()
{
int status;
/* Ast routine that is called when keyboard input comes in
in accord with the SYS$QIO above. */
+void
kbd_input_ast ()
{
register int c = -1;
/* Wait until there is something in kbd_buffer. */
+void
wait_for_kbd_input ()
{
extern int have_process_input, process_exited;
and therefore there is no I/O request queued when we return.
SYS$SETAST is used to avoid a timing error. */
+void
end_kbd_input ()
{
#ifdef ASTDEBUG
/* Wait for either input available or time interval expiry. */
+void
input_wait_timeout (timeval)
int timeval; /* Time to wait, in seconds */
{
SYS$WAITFR (timer_ef); /* Wait for timer expiry only */
}
+void
init_sigio (fd)
int fd;
{
unrequest_sigio ();
}
+void
request_sigio ()
{
croak ("request sigio");
}
+void
unrequest_sigio ()
{
croak ("unrequest sigio");
#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. */
for (;;)
{
- char *fqdn = (char *) alloca (hostlen + 1 + domain_size);
- char *domain = fqdn + hostlen + 1;
-#if HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)
+ char *domain = (char *) alloca (domain_size + 1);
+ char *fqdn = (char *) alloca (hostlen + 1 + domain_size + 1);
int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size);
if (sys_domain_size <= 0)
break;
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)"))
+ strcpy (fqdn, hostname);
+ if (domain[0] == '.')
+ strcpy (fqdn + hostlen, domain);
+ else if (domain[0] != 0)
{
- *domain = 0;
- break;
+ fqdn[hostlen] = '.';
+ strcpy (fqdn + hostlen + 1, domain);
}
-#endif /* HAVE_GETDOMAINNAME */
- strcpy (fqdn, hostname);
- fqdn[hostlen] = '.';
hostname = fqdn;
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 */
#define BUFFER_SIZE_FACTOR 1
#endif
+void
read_input_waiting ()
{
struct input_event e;
return open (path, oflag);
}
+void
init_sigio (fd)
int fd;
{
ioctl (fd, TIOCLSET, &lmode);
}
+void
reset_sigio ()
{
if (noninteractive)
ioctl (0, TIOCLSET, &lmode);
}
+void
request_sigio ()
{
sigrelse (SIGTINT);
interrupts_deferred = 0;
}
+void
unrequest_sigio ()
{
sighold (SIGTINT);
int sigheld; /* Mask of held signals */
+void
sigholdx (signum)
int signum;
{
sighold (signum);
}
+void
sigisheld (signum)
int signum;
{
sigheld |= sigbit (signum);
}
+void
sigunhold (signum)
int signum;
{
sigrelse (signum);
}
+void
sigfree () /* Free all held signals */
{
int i;
sigheld = 0;
}
+int
sigbit (i)
{
return 1 << (i - 1);
#ifdef POSIX_SIGNALS
-sigset_t old_mask, empty_mask, full_mask, temp_mask;
-static struct sigaction new_action, old_action;
+sigset_t empty_mask, full_mask;
+void
init_signals ()
{
sigemptyset (&empty_mask);
signal_handler_t
sys_signal (int signal_number, signal_handler_t action)
{
+ struct sigaction new_action, old_action;
sigemptyset (&new_action.sa_mask);
new_action.sa_handler = action;
#ifdef SA_RESTART
}
#endif
-int
-sys_sigpause (sigset_t new_mask)
-{
- /* pause emulating berk sigpause... */
- sigsuspend (&new_mask);
- return (EINTR);
-}
-
/* I'd like to have these guys return pointers to the mask storage in here,
but there'd be trouble if the code was saving multiple masks. I'll be
safe and pass the structure. It normally won't be more than 2 bytes
#ifdef INTERRUPTIBLE_CLOSE
+int
sys_close (fd)
int fd;
{
#ifdef HAVE_TIMEVAL
/* ARGSUSED */
+int
gettimeofday (tp, tzp)
struct timeval *tp;
struct timezone *tzp;
tp->tv_usec = 0;
if (tzp != 0)
tzp->tz_minuteswest = -1;
+ return 0;
}
#endif
* This function will go away as soon as all the stubs fixed. (fnf)
*/
+void
croak (badfunc)
char *badfunc;
{
/* Called from init_sys_modes, so it happens not very often
but at least each time Emacs is loaded. */
+void
sys_access_reinit ()
{
uic = 0;
return pathname;
}
+int
getppid ()
{
long item_code = JPI$_OWNER;
#endif
#endif
+int
sys_creat (va_alist)
va_dcl
{
#endif /* creat */
/* fwrite to stdout is S L O W. Speed it up by using fputc...*/
+int
sys_fwrite (ptr, size, num, fp)
register char * ptr;
FILE * fp;
while (tot--)
fputc (*ptr++, fp);
+ return num;
}
/*
/* return total address space available to the current process. This is
the sum of the current p0 size, p1 size and free page table entries
available. */
+int
vlimit ()
{
int item_code;
return free_pages + frep0va + (0x7fffffff - frep1va);
}
+int
define_logical_name (varname, string)
char *varname;
char *string;
return LIB$SET_LOGICAL (&envdsc, &strdsc, &lnmdsc, 0, 0);
}
+int
delete_logical_name (varname)
char *varname;
{
return LIB$DELETE_LOGICAL (&envdsc, &lnmdsc);
}
+int
ulimit ()
-{}
+{
+ return 0;
+}
+int
setpgrp ()
-{}
+{
+ return 0;
+}
+int
execvp ()
{
error ("execvp system call not implemented");
+ return -1;
}
int
return 0;
}
+int
link (file, new)
char * file, * new;
{
return 0;
}
+void
croak (badfunc)
char *badfunc;
{
return rand () - (1 << 30);
}
+void
srandom (seed)
{
srand (seed);
#ifdef AIXHFT
/* Called from init_sys_modes. */
+void
hft_init ()
{
int junk;
/* Reset the rubout key to backspace. */
+void
hft_reset ()
{
struct hfbuf buf;
*b2++ = *b1++;
#endif /* not VMS */
}
-#endif /* (defined (BSTRING) && !defined (bcopy)) || defined (NEED_BCOPY) */
+#endif /* (!defined (BSTRING) && !defined (bcopy)) || defined (NEED_BCOPY) */
#ifndef BSTRING
#ifndef bcmp