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

Last change on this file since 3f2d518 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
RevLine 
[f40a309]1/*
2 ============================================================================
3 flread.c -- read a long buffer
4 Version 2 -- 1987-07-09 -- D.N. Lynx Crowe
5 ============================================================================
6*/
7
[b28a12e]8#include "ram.h"
[f40a309]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
[7258c6a]20int16_t flread(int8_t *buff, int32_t len, FILE *fp)
[f40a309]21{
[7258c6a]22 register int16_t ilen;
[f40a309]23
24 while (len > 0L) {
25
[7258c6a]26 if (len GE (int32_t)CHUNK) {
[f40a309]27
28 if (1 NE fread(buff, CHUNK, 1, fp))
29 return(EOF);
30
[7258c6a]31 buff += (int32_t)CHUNK;
32 len -= (int32_t)CHUNK;
[f40a309]33
34 } else {
35
[8973acd]36 ilen = (int16_t)len;
[f40a309]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
[6262b5c]48
Note: See TracBrowser for help on using the repository browser.