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

include	<config.h>
include	<fio.h>

# GETC -- Get a character from a file.

char procedure getc (fd, ch)

int	fd			# input file
char	ch			# character (output)
int	filbuf()
errchk	filbuf
include	<fio.com>

begin
 	if (iop[fd] < bufptr[fd] || iop[fd] >= itop[fd])
	    if (filbuf(fd) == EOF) {
		ch = EOF
		return (EOF)
	    }

	ch = Memc[iop[fd]]
	iop[fd] = iop[fd] + 1

	return (ch)
end