From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/tty/ttyinit.x | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sys/tty/ttyinit.x (limited to 'sys/tty/ttyinit.x') diff --git a/sys/tty/ttyinit.x b/sys/tty/ttyinit.x new file mode 100644 index 00000000..9aeff341 --- /dev/null +++ b/sys/tty/ttyinit.x @@ -0,0 +1,46 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include +include +include "tty.h" + +# TTYINIT -- Initialize the terminal. The termcap entry potentially contains +# two initialization entries. The first, "is" is an initialization string +# which is sent to the terminal. The second, "if", is the name of a file +# containing the initialization string. If both are given, "if" is sent +# followed by "is", however, there seems no reason to have an "is" string +# if there is already an initialization file. The names of initialization +# files may be either IRAF virtual filenames or host system pathnames. + +procedure ttyinit (fd, tty) + +int fd # file descriptor of terminal +pointer tty # tty descriptor + +pointer sp, fname +int in, junk, rawmode +int ttyctrl(), ttygets(), open(), fstati() +errchk ttygets, fcopyo + +begin + call smark (sp) + call salloc (fname, SZ_PATHNAME, TY_CHAR) + + # Output contents of initialization file, if any. + if (ttygets (tty, "if", Memc[fname], SZ_PATHNAME) > 0) + iferr (in = open (Memc[fname], READ_ONLY, TEXT_FILE)) + call erract (EA_WARN) + else { + rawmode = fstati (fd, F_RAW) + call fseti (fd, F_RAW, YES) + call fcopyo (in, fd) + call fseti (fd, F_RAW, rawmode) + call close (in) + } + + # Output initialization string. + junk = ttyctrl (fd, tty, "is", 1) + + call sfree (sp) +end -- cgit