aboutsummaryrefslogtreecommitdiff
path: root/sys/clio/clgfil.x
blob: 62d40dd112d5db59c5443d54e61e84f8f8129859 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<fset.h>

.help clpopn[isu], clplen, clgfil, clpcls
.nf ___________________________________________________________________________
Expand a filename template given as the string value of a CL parameter.

	clpopni - open a sorted input list or open list "STDIN"
	clpopns - open a sorted list
	clpopnu - open an unsorted list
	 clpcls - close a list
	 clplen - get number of filenames in list
	 clgfil - get next filename from list
	 clprew - rewind the list

The CLPOPNI procedure creates a dummy list containing the single filename
"STDIN" if the standard input is redirected.
.endhelp ______________________________________________________________________


# CLPOPNI -- Open an input list (sorted list of input files).  If the standard
# input has been redirected, create a dummy list containing the single file
# name "STDIN", and do not try to access the template parameter.

int procedure clpopni (param)

char	param[ARB]			# CL filename template parameter
int	sort
pointer	sp, template, list
int	fntopnb(), fstati()

begin
	call smark (sp)
	call salloc (template, SZ_COMMAND, TY_CHAR)

	sort = YES

	if (fstati (STDIN, F_REDIR) == YES)
	    list = fntopnb ("STDIN", sort)
	else {
	    call clgstr (param, Memc[template], SZ_COMMAND)
	    list = fntopnb (Memc[template], sort)
	}

	call sfree (sp)
	return (list)
end


# CLPOPNS -- Open a sorted list (sorted list of files, not associated with any
# particular byte stream).

int procedure clpopns (param)

char	param[ARB]			# CL filename template parameter
int	sort
pointer	sp, template, list
int	fntopnb()

begin
	call smark (sp)
	call salloc (template, SZ_COMMAND, TY_CHAR)

	sort = YES

	call clgstr (param, Memc[template], SZ_COMMAND)
	list = fntopnb (Memc[template], sort)

	call sfree (sp)
	return (list)
end


# CLPOPNU -- Open an unsorted list (unsorted list of files, not associated
# with any particular stream).

int procedure clpopnu (param)

char	param[ARB]			# CL filename template parameter
int	sort
pointer	sp, template, list
int	fntopnb()

begin
	call smark (sp)
	call salloc (template, SZ_COMMAND, TY_CHAR)

	sort = NO

	call clgstr (param, Memc[template], SZ_COMMAND)
	list = fntopnb (Memc[template], sort)

	call sfree (sp)
	return (list)
end


# CLPLEN -- Return the number of file names in the list.

int procedure clplen (list)

pointer	list
int	fntlenb()

begin
	return (fntlenb (list))
end


# CLGFIL -- Return the next filename from the list.

int procedure clgfil (list, fname, maxch)

int	list			# list descriptor
char	fname[ARB]		# output string
int	maxch
int	fntgfnb()

begin
	return (fntgfnb (list, fname, maxch))
end


# CLPCLS -- Close a filename list and return all storage.

procedure clpcls (list)

int	list			# list descriptor

begin
	call fntclsb (list)
end


# GLPREW -- Rewind the filename list.

procedure clprew (list)

int	list			# list descriptor

begin
	call fntrewb (list)
end