aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/sgikern/t_sgikern.x
blob: 359a87adfe6af83e435849fffb01160d9871849c (plain) (blame)
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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<error.h>
include	<gki.h>

# SGIKERN -- Generic graphics kernel for the standard plotter output.  The whole
# package is copied as much as possible from the stdgraph package.

procedure t_sgikern()

int	fd, list
pointer	gki, sp, fname, devname
int	dev[LEN_GKIDD], deb[LEN_GKIDD]
int	debug, verbose, gkiunits
bool	clgetb()
int	clpopni(), clgfil(), open(), btoi()
int	gki_fetch_next_instruction()

begin
	call smark (sp)
	call salloc (fname, SZ_FNAME, TY_CHAR)
	call salloc (devname, SZ_FNAME, TY_CHAR)

	# Open list of metafiles to be decoded.
	list = clpopni ("input")

	# Get parameters.
	call clgstr ("device", Memc[devname], SZ_FNAME)
	if (clgetb ("generic")) {
	    debug = NO
	    verbose = NO
	    gkiunits = NO
	} else {
	    debug   = btoi (clgetb ("debug"))
	    verbose = btoi (clgetb ("verbose"))
	    gkiunits = btoi (clgetb ("gkiunits"))
	}

	# Open the graphics kernel.
	call sgi_open (Memc[devname], dev)
	call gkp_install (deb, STDERR, verbose, gkiunits)

	# Process a list of metacode files, writing the decoded metacode
	# instructions on the standard output.

	while (clgfil (list, Memc[fname], SZ_FNAME) != EOF) {
	    # Open input file.
	    iferr (fd = open (Memc[fname], READ_ONLY, BINARY_FILE)) {
		call erract (EA_WARN)
		next
	    }

	    # Process the metacode instruction stream.
	    while (gki_fetch_next_instruction (fd, gki) != EOF) {
		if (debug == YES)
		    call gki_execute (Mems[gki], deb)
		call gki_execute (Mems[gki], dev)
	    }

	    call close (fd)
	}

	call gkp_close()
	call sgi_close()
	call clpcls (list)
	call sfree (sp)
end