File: type.x

package info (click to toggle)
iraf 2.18.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,000 kB
  • sloc: ansic: 115,890; fortran: 74,576; lisp: 18,888; yacc: 5,642; sh: 961; lex: 596; makefile: 509; asm: 159; csh: 54; xml: 33; sed: 4
file content (68 lines) | stat: -rw-r--r-- 1,494 bytes parent folder | download | duplicates (7)
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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<error.h>

# TYPE -- Type the named files on the standard output.  If more than one
# file, print a brief header identifying each file.

procedure t_type()

char	fname[SZ_FNAME], device[SZ_FNAME]
bool	multiple_files
int	map_cc, list
pointer	tty, ttyodes()
bool	clgetb()
int	clpopni(), clplen(), clgfil(), btoi()

begin
	list = clpopni ("input_files")
	multiple_files = (clplen (list) > 1)
	map_cc = btoi (clgetb ("map_cc"))
	call clgstr ("device", device, SZ_FNAME)
	tty = ttyodes (device)

	while (clgfil (list, fname, SZ_FNAME) != EOF)
	    iferr (call type_file (STDOUT, tty, fname, multiple_files, map_cc))
		call erract (EA_WARN)

	call ttycdes (tty)
	call clpcls (list)
end


# TYPE_FILE -- Print the named file on the output stream given as the first
# argument, optionally with a leading header.

procedure type_file (out, tty, fname, print_file_name, map_cc)

int	out
pointer	tty
char	fname[ARB]
bool	print_file_name
int	map_cc

int	in
pointer	sp, buf
int	open(), getline()
errchk	salloc, open, getline, ttyputline

begin
	call smark (sp)
	call salloc (buf, SZ_LINE, TY_CHAR)

	in = open (fname, READ_ONLY, TEXT_FILE)

	if (print_file_name) {
	    call fprintf (out, "===> %s <===\n")
		call pargstr (fname)
	}

	while (getline (in, Memc[buf]) != EOF)
	    call ttyputline (out, tty, Memc[buf], map_cc)

	if (print_file_name)
	    call fprintf (out, "\n\n")

	call close (in)
	call sfree (sp)
end