Last change
on this file since 8618599 was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Use standard integer types.
|
-
Property mode
set to
100644
|
File size:
1012 bytes
|
Rev | Line | |
---|
[f40a309] | 1 | /*
|
---|
| 2 | ============================================================================
|
---|
| 3 | flread.c -- read a long buffer
|
---|
| 4 | Version 2 -- 1987-07-09 -- D.N. Lynx Crowe
|
---|
| 5 | ============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stdio.h"
|
---|
| 9 | #include "stddefs.h"
|
---|
| 10 |
|
---|
| 11 | #define CHUNK 32256 /* largest practical sized chunk of data */
|
---|
| 12 |
|
---|
| 13 | /*
|
---|
| 14 | ============================================================================
|
---|
| 15 | flread(buff, len, fp) -- Reads 'len' bytes into 'buff' from file 'fp'.
|
---|
| 16 |
|
---|
| 17 | Returns SUCCESS (0) if OK, EOF (-1) on end of file.
|
---|
| 18 | ============================================================================
|
---|
| 19 | */
|
---|
| 20 |
|
---|
[7258c6a] | 21 | int16_t flread(int8_t *buff, int32_t len, FILE *fp)
|
---|
[f40a309] | 22 | {
|
---|
[7258c6a] | 23 | register int16_t ilen;
|
---|
[f40a309] | 24 |
|
---|
| 25 | while (len > 0L) {
|
---|
| 26 |
|
---|
[7258c6a] | 27 | if (len GE (int32_t)CHUNK) {
|
---|
[f40a309] | 28 |
|
---|
| 29 | if (1 NE fread(buff, CHUNK, 1, fp))
|
---|
| 30 | return(EOF);
|
---|
| 31 |
|
---|
[7258c6a] | 32 | buff += (int32_t)CHUNK;
|
---|
| 33 | len -= (int32_t)CHUNK;
|
---|
[f40a309] | 34 |
|
---|
| 35 | } else {
|
---|
| 36 |
|
---|
| 37 | ilen = len;
|
---|
| 38 |
|
---|
| 39 | if (1 NE fread(buff, ilen, 1, fp))
|
---|
| 40 | return(EOF);
|
---|
| 41 |
|
---|
| 42 | len = 0L;
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | return(SUCCESS);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.