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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <syserr.h>
# GTR_CONNECT -- Connect a subprocess containing a graphics kernel task to a
# graphics stream. The graphics kernel task is a conventional IRAF task
# linked into the kernel process. After spawning the subprocess, we command
# the process to run the named kernel task, then service the parameter
# requests from the task as it begins running. Graphics i/o will be via one
# of the graphics streams, leaving STDIN, STDOUT, and STDERR free to access
# the corresponding streams in the parent (the CL). A kernel may be opened
# either to drive a particular device (if devname is specified) or to drive
# a device selected at runtime. If the kernel is opened to drive a particular
# device the device name in the OPENWS instruction will be ignored. We require
# that the graphics kernel begin processing metacode immediately after
# receiving "yes" for the value of the parameter "generic", signifying that
# the caller wishes a generic kernel, i.e., cannot return the values of any
# kernel dependent parameters.
int procedure gtr_connect (kernfname, taskname, devname, stream, in, out)
char kernfname[ARB] # name of executable kernel file
char taskname[ARB] # name of kernel task
char devname[ARB] # device name or null string
int stream # graphics stream to connect process to
int in, out # input and output streams to process
pointer sp, lbuf
int pid
bool streq()
int propen(), getline()
errchk propen, flush, getline, syserr
begin
call smark (sp)
call salloc (lbuf, SZ_LINE, TY_CHAR)
pid = propen (kernfname, in, out)
call fprintf (out, "%s\n")
call pargstr (taskname)
call flush (out)
# Pass values of the kernel parameters. For a kernel run as
# part of the graphics system there are only three parameters,
# the input file name (STDGRAPH, etc. for a connected kernel)
# the device name if the kernel is to ignore device names in
# OPENWS instructions, and "generic=yes", signifying that the
# kernel dependent parameters are not to be requested.
while (getline (in, Memc[lbuf]) != EOF) {
if (streq (Memc[lbuf], "=input\n")) {
call fprintf (out, "%s\n")
switch (stream) {
case STDGRAPH:
call pargstr ("STDGRAPH")
case STDIMAGE:
call pargstr ("STDIMAGE")
case STDPLOT:
call pargstr ("STDPLOT")
}
call flush (out)
} else if (streq (Memc[lbuf], "=device\n")) {
call fprintf (out, "%s\n")
call pargstr (devname)
call flush (out)
} else if (streq (Memc[lbuf], "=generic\n")) {
call putline (out, "yes\n")
call flush (out)
break
} else {
call putline (STDERR, Memc[lbuf])
call syserr (SYS_GKERNPARAM)
}
}
call sfree (sp)
return (pid)
end
|