|
|
1.1 root 1: .th GETC III 4/30/72
2: .sh NAME
3: getc \*- buffered input
4: .sh SYNOPSIS
5: .ft B
6: mov $filename,r0
7: .br
8: jsr r5,fopen; iobuf
9: .s3
10: fopen(filename, iobuf)
11: .br
12: char *filename;
13: .br
14: struct buf *iobuf;
15: .s3
16: jsr r5,getc; iobuf
17: .br
18: .ft R
19: (character in r0)
20: .s3
21: .ft B
22: getc(iobuf)
23: .br
24: struct buf *iobuf;
25: .s3
26: jsr r5,getw; iobuf
27: .br
28: .ft R
29: (word in r0)
30: .s3
31: [getw not available in C]
32: .sh DESCRIPTION
33: These routines provide a buffered input
34: facility.
35: .it Iobuf
36: is the address of a 518(10) byte buffer area whose
37: contents are maintained by these routines. Its format is:
38: .s3
39: .nf
40: .ft B
41: ioptr: .=.+2 / file descriptor
42: .=.+2 / characters left in buffer
43: .=.+2 / ptr to next character
44: .=.+512. / the buffer
45: .ft R
46: .s3
47: Or in C,
48: .s3
49: .ft B
50: struct buf {
51: int fildes;
52: int nleft;
53: char *nextp;
54: char buffer[512];
55: };
56: .ft R
57: .s3
58: .fi
59: .it Fopen
60: may be called initially to open the file. On return,
61: the error bit (c-bit) is set if the open failed.
62: If \fIfopen\fR is never called, \fIget\fR will
63: read from the standard
64: input file.
65: From C, the value is negative if the open failed.
66: .s3
67: .it Getc
68: returns the next byte from the file in r0. The
69: error bit is set on end of file or a read error.
70: From C, the character is returned;
71: it is \*-1 on end-of-file or error.
72: .s3
73: \fIGetw\fR returns the next word in r0.
74: .it Getc
75: and
76: \fIgetw\fR
77: may be used alternately; there are no odd/even
78: problems.
79: \fIGetw\fR is not available from C.
80: .s3
81: .it Iobuf
82: must be provided by the user; it must be on a word boundary.
83: .s3
84: To reuse the same buffer for another file, it is sufficient
85: to close the original file and call \fIfopen\fR again.
86: .sh "SEE ALSO"
87: open(II), read(II), putc(III)
88: .sh DIAGNOSTICS
89: c-bit set on EOF or error;
90: .br
91: from C, negative return indicates error or EOF.
92: .sh BUGS
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.