aboutsummaryrefslogtreecommitdiff
path: root/pkg/system/files.x
blob: 9bd94f915f9ba0e06f97de68e1b6633c376d7765 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

# FILES -- Expand a file name template into a list of file names on the
# standard output.

procedure t_files()

int	list
pointer	sp, template, fname

bool	clgetb()
int	fntopnb(), fntgfnb(), clgeti(), btoi()

begin
	call smark (sp)
	call salloc (fname, SZ_FNAME, TY_CHAR)
	call salloc (template, SZ_LINE, TY_CHAR)

	if (clgeti ("$nargs") > 0)
	    call clgstr ("template", Memc[template], SZ_LINE)
	else
	    call strcpy ("*", Memc[template], SZ_LINE)

	list = fntopnb (Memc[template], btoi(clgetb("sort")))
	while (fntgfnb (list, Memc[fname], SZ_FNAME) != EOF) {
	    call printf ("%s\n")
		call pargstr (Memc[fname])
	}

	call fntclsb (list)
	call sfree (sp)
end