Last change
on this file since cbc2fcf was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
919 bytes
|
Rev | Line | |
---|
[3ae31e9] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | fread.c -- read a stream file
|
---|
| 4 | Version 3 -- 1987-06-29 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stdio.h"
|
---|
| 9 | #include "stddefs.h"
|
---|
| 10 |
|
---|
| 11 | /*
|
---|
| 12 | =============================================================================
|
---|
| 13 | fread(buffer, size, number, stream) -- read 'number' items of size
|
---|
| 14 | 'size' bytes from file 'stream' into 'buffer'.
|
---|
| 15 | =============================================================================
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 | int
|
---|
| 19 | fread(buffer, size, number, stream)
|
---|
| 20 | register char *buffer;
|
---|
| 21 | unsigned size;
|
---|
| 22 | int number;
|
---|
| 23 | FILE *stream;
|
---|
| 24 | {
|
---|
| 25 | int total;
|
---|
| 26 | register int c,i;
|
---|
| 27 |
|
---|
| 28 | for (total = 0; total < number; ++total) {
|
---|
| 29 |
|
---|
| 30 | for (i = size; i; --i) {
|
---|
| 31 |
|
---|
| 32 | if ((c = getc(stream)) EQ EOF)
|
---|
| 33 | return(total);
|
---|
| 34 |
|
---|
| 35 | *buffer++ = c;
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 | return(total);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.