source: buchla-68k/libcio/flread.c@ 0580615

Last change on this file since 0580615 was 0580615, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Point of no return.

  • Property mode set to 100644
File size: 990 bytes
Line 
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
21int flread(char *buff, long len, FILE *fp)
22{
23 register int ilen;
24
25 while (len > 0L) {
26
27 if (len GE (long)CHUNK) {
28
29 if (1 NE fread(buff, CHUNK, 1, fp))
30 return(EOF);
31
32 buff += (long)CHUNK;
33 len -= (long)CHUNK;
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.