aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/splot/stshelp.x
blob: f34de38ab7e9009051c0a307d608486835186ad9 (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
include	<error.h>


# STS_HELP -- Issue a help line

procedure sts_help (line, nlines, fname, ptr)

int	line		# Line to print
int	nlines		# Number of lines of help
char	fname[ARB]	# Help file
pointer	ptr		# Cache help

int	fd, open(), getline()

begin
	if (ptr == NULL) {
	    iferr (fd = open (fname, READ_ONLY, TEXT_FILE)) {
		call erract (EA_WARN)
		return
	    }
	    nlines = 0
	    call malloc (ptr, SZ_LINE, TY_CHAR)
	    while (getline (fd, Memc[ptr+nlines*SZ_LINE]) != EOF) {
		nlines = nlines + 1
		call realloc (ptr, (nlines+1)*SZ_LINE, TY_CHAR)
	    }
	    call close (fd)
	}

	if (line >= 1  && line <= nlines) {
	    call putline (STDOUT, Memc[ptr+(line-1)*SZ_LINE])
	    call flush (STDOUT)
	}
end