Last change
on this file since bc11fc1 was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
Use standard integer types.
|
-
Property mode
set to
100644
|
File size:
858 bytes
|
Rev | Line | |
---|
[f40a309] | 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 |
|
---|
[7258c6a] | 18 | int16_t fread(int8_t *buffer, uint16_t size, int16_t number, FILE *stream)
|
---|
[f40a309] | 19 | {
|
---|
[7258c6a] | 20 | int16_t total;
|
---|
| 21 | register int16_t c,i;
|
---|
[f40a309] | 22 |
|
---|
| 23 | for (total = 0; total < number; ++total) {
|
---|
| 24 |
|
---|
| 25 | for (i = size; i; --i) {
|
---|
| 26 |
|
---|
| 27 | if ((c = getc(stream)) EQ EOF)
|
---|
| 28 | return(total);
|
---|
| 29 |
|
---|
| 30 | *buffer++ = c;
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
| 33 | return(total);
|
---|
| 34 | }
|
---|
| 35 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.