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

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

Compiled full ROM in Hatari.

  • Property mode set to 100644
File size: 1.0 KB
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
22flread(buff, len, fp)
23register char *buff;
24register long len;
25FILE *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.