Start development on Research V7
[unix-history] / .ref-Research-V6 / usr / doc / man / man3 / getc.3
CommitLineData
878b8aef
KT
1.th GETC III 4/30/72
2.sh NAME
3getc, getw, fopen \*- buffered input
4.sh SYNOPSIS
5.ft B
6mov $filename,r0
7.br
8jsr r5,fopen; iobuf
9.s3
10fopen(filename, iobuf)
11.br
12char *filename;
13.br
14struct buf *iobuf;
15.s3
16jsr r5,getc; iobuf
17.br
18.ft R
19(character in r0)
20.s3
21.ft B
22getc(iobuf)
23.br
24struct buf *iobuf;
25.s3
26jsr r5,getw; iobuf
27.br
28.ft R
29(word in r0)
30.s3
31.ft B
32getw(iobuf)
33.br
34struct buf *iobuf;
35.ft R
36.sh DESCRIPTION
37These routines provide a buffered input
38facility.
39.it Iobuf
40is the address of a 518(10) byte buffer area whose
41contents are maintained by these routines.
42Its structure is
43.s3
44.nf
45.ft B
46 struct buf {
47 int fildes; /* File descriptor */
48 int nleft; /* Chars left in buffer */
49 char *nextp; /* Ptr to next character */
50 char buff[512]; /* The buffer */
51 };
52.ft R
53.s3
54.fi
55.it Fopen
56may be called initially to open the file. On return,
57the error bit (c-bit) is set if the open failed.
58If \fIfopen\fR is never called, \fIget\fR will
59read from the standard
60input file.
61From C, the value is negative if the open failed.
62.s3
63.it Getc
64returns the next byte from the file in r0.
65The error bit is set on end of file or a read error.
66From C, the character is returned as an integer, without sign extension;
67it is \*-1 on end-of-file or error.
68.s3
69\fIGetw\fR returns the next word in r0.
70.it Getc
71and
72\fIgetw\fR
73may be used alternately; there are no odd/even
74problems.
75\fIGetw\fR is may be called from C;
76\*-1 is returned on end-of-file or error,
77but of course
78is also a legitimate value.
79.s3
80.it Iobuf
81must be provided by the user; it must be on a word boundary.
82.s3
83To reuse the same buffer for another file, it is sufficient
84to close the original file and call \fIfopen\fR again.
85.sh "SEE ALSO"
86open (II), read (II), getchar (III), putc (III)
87.sh DIAGNOSTICS
88c-bit set on EOF or error;
89from C, negative return indicates error or EOF.
90Moreover,
91.it errno
92is set by this routine just as it is for a system call
93(see introduction (II)).
94.sh BUGS