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

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

No more warnings in libcio.

  • Property mode set to 100644
File size: 999 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 "ram.h"
9
10#define CHUNK 32256 /* largest practical sized chunk of data */
11
12/*
13 ============================================================================
14 flread(buff, len, fp) -- Reads 'len' bytes into 'buff' from file 'fp'.
15
16 Returns SUCCESS (0) if OK, EOF (-1) on end of file.
17 ============================================================================
18*/
19
20int16_t flread(int8_t *buff, int32_t len, FILE *fp)
21{
22 register int16_t ilen;
23
24 while (len > 0L) {
25
26 if (len GE (int32_t)CHUNK) {
27
28 if (1 NE fread(buff, CHUNK, 1, fp))
29 return(EOF);
30
31 buff += (int32_t)CHUNK;
32 len -= (int32_t)CHUNK;
33
34 } else {
35
36 ilen = (int16_t)len;
37
38 if (1 NE fread(buff, ilen, 1, fp))
39 return(EOF);
40
41 len = 0L;
42 }
43 }
44
45 return(SUCCESS);
46}
47
48
Note: See TracBrowser for help on using the repository browser.