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

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

Use standard integer types.

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