1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
|