aboutsummaryrefslogtreecommitdiff
path: root/sys/tty/ttyinit.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/tty/ttyinit.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/tty/ttyinit.x')
-rw-r--r--sys/tty/ttyinit.x46
1 files changed, 46 insertions, 0 deletions
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 <error.h>
+include <chars.h>
+include <fset.h>
+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