source:
buchla-68k/libcio/fread.c@
6262b5c
| Last change on this file since 6262b5c was 6262b5c, checked in by , 8 years ago | |
|---|---|
|
|
| File size: 836 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 | ||
| [6262b5c] | 8 | #include "all.h" |
| [f40a309] | 9 | |
| 10 | /* | |
| 11 | ============================================================================= | |
| 12 | fread(buffer, size, number, stream) -- read 'number' items of size | |
| 13 | 'size' bytes from file 'stream' into 'buffer'. | |
| 14 | ============================================================================= | |
| 15 | */ | |
| 16 | ||
| [7258c6a] | 17 | int16_t fread(int8_t *buffer, uint16_t size, int16_t number, FILE *stream) |
| [f40a309] | 18 | { |
| [7258c6a] | 19 | int16_t total; |
| 20 | register int16_t c,i; | |
| [f40a309] | 21 | |
| 22 | for (total = 0; total < number; ++total) { | |
| 23 | ||
| 24 | for (i = size; i; --i) { | |
| 25 | ||
| 26 | if ((c = getc(stream)) EQ EOF) | |
| 27 | return(total); | |
| 28 | ||
| 29 | *buffer++ = c; | |
| 30 | } | |
| 31 | } | |
| 32 | return(total); | |
| 33 | } | |
| 34 | ||
| [6262b5c] | 35 |
Note:
See TracBrowser
for help on using the repository browser.
![(please configure the [header_logo] section in trac.ini)](http://bob.lopatic.de/chrome/site/logo.png)