Last change
on this file since 66b48e7 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
1.0 KB
|
Rev | Line | |
---|
[3ae31e9] | 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 |
|
---|
| 21 | int
|
---|
| 22 | flread(buff, len, fp)
|
---|
| 23 | register char *buff;
|
---|
| 24 | register long len;
|
---|
| 25 | FILE *fp;
|
---|
| 26 | {
|
---|
| 27 | register int ilen;
|
---|
| 28 |
|
---|
| 29 | while (len > 0L) {
|
---|
| 30 |
|
---|
| 31 | if (len GE (long)CHUNK) {
|
---|
| 32 |
|
---|
| 33 | if (1 NE fread(buff, CHUNK, 1, fp))
|
---|
| 34 | return(EOF);
|
---|
| 35 |
|
---|
| 36 | buff += (long)CHUNK;
|
---|
| 37 | len -= (long)CHUNK;
|
---|
| 38 |
|
---|
| 39 | } else {
|
---|
| 40 |
|
---|
| 41 | ilen = len;
|
---|
| 42 |
|
---|
| 43 | if (1 NE fread(buff, ilen, 1, fp))
|
---|
| 44 | return(EOF);
|
---|
| 45 |
|
---|
| 46 | len = 0L;
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | return(SUCCESS);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.