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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
task rexec = t_rexec,
rtype = t_rtype,
rread = t_rread
define SZ_BUF 4096
# REXEC -- Execute a command on a remote node and print the resultant output on
# the standard output. Used to test the kernel server driver.
procedure t_rexec()
char server[SZ_LINE]
char buf[SZ_BUF]
int chan, nbytes, status
begin
call clgstr ("server", server, SZ_LINE)
call strpak (server, server, SZ_LINE)
call zopnks (server, READ_WRITE, chan)
if (chan == ERR)
call error (1, "cannot connect to remote server process")
repeat {
call zardks (chan, buf, SZ_BUF, 0)
call zawtks (chan, nbytes)
if (nbytes > 0) {
call chrupk (buf, 1, buf, 1, nbytes)
call write (STDOUT, buf, nbytes)
call flush (STDOUT)
}
} until (nbytes <= 0)
call zclsks (chan, status)
if (status == ERR)
call error (1, "error disconnecting server process")
end
# RTYPE -- Type a text file possibly resident on a remote node.
procedure t_rtype()
char fname[SZ_FNAME]
char lbuf[SZ_LINE]
int fd
int open(), getline()
begin
call clgstr ("file", fname, SZ_FNAME)
fd = open (fname, READ_ONLY, TEXT_FILE)
while (getline (fd, lbuf) != EOF) {
call putline (STDOUT, lbuf)
call flush (STDOUT)
}
call close (fd)
end
# RREAD -- Read a binary file.
procedure t_rread()
char fname[SZ_FNAME]
char dbuf[SZ_BUF]
int fd
long nchars, totchars
int open(), read()
begin
call clgstr ("file", fname, SZ_FNAME)
fd = open (fname, READ_ONLY, BINARY_FILE)
totchars = 0
repeat {
nchars = read (fd, dbuf, SZ_BUF)
if (nchars > 0)
totchars = totchars + nchars
} until (nchars == EOF)
call close (fd)
call printf ("read %d chars\n")
call pargi (totchars)
end
|