aboutsummaryrefslogtreecommitdiff
path: root/sys/fmio/fmlfname.x
blob: 1d0b92e784a9bd13a4760f1b5e1879dab5469d25 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<fmset.h>
include	"fmio.h"

# FM_LFNAME -- Encode the pseudo-filename for an lfile.  This is necessary to
# pass all lfile info through FIO, when opening a file descriptor on an lfile.
#
# The filename syntax is "Tddd.fff" where
#
#       T       is 'B' or 'T' for text or binary
#       ddd     is the encoded descriptor pointer
#       fff     is the encoded lfile number

procedure fm_lfname (fm, lfile, type, lfname, maxch)

pointer	fm			#I FMIO descriptor
int	lfile			#I lfile number
int	type			#I file type, text or binary
char	lfname[maxch]		#O encoded lfile filename
int	maxch			#I max chars out

int	op
int	itoc()
errchk	fmio_bind, fmio_errchk

begin
	call fmio_bind (fm)
	call fmio_errchk (fm)
	if (maxch <= 0)
	    return

	op = 1
	if (type == TEXT_FILE)
	    lfname[op] = 'T'
	else
	    lfname[op] = 'B'
	op = min (maxch, op + 1)

	op = min (maxch, op + itoc (fm, lfname[op], maxch-op+1))
	lfname[op] = '.'
	op = min (maxch, op + 1)
	op = min (maxch, op + itoc (lfile, lfname[op], maxch-op+1))
	lfname[op] = EOS
end