source: buchla-68k/libcio/fwrite.c@ 197ff76

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

No more warnings in libcio.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 =============================================================================
3 fwrite.c -- write a stream file
4 Version 3 -- 1987-07-09 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "ram.h"
9
10/*
11 =============================================================================
12 fwrite(buffer, size, number, stream) -- write 'number' items of sixe
13 'size' bytes from 'buffer' onto 'stream'. Returns the number of items
14 written. If 'number' or 'size' is negative, nothing is written, and
15 0 is returned. EOF may cause the last item written to be imcomplete.
16 Check with feof() to detect an EOF condition. Use ferror() to check
17 for error conditions.
18 =============================================================================
19*/
20
21int16_t fwrite(void *buffer, int16_t size, int16_t number, FILE *stream)
22{
23 uint8_t *buffer8;
24 register int16_t i, j;
25
26 buffer8 = buffer;
27
28 if (size < 0) /* check size for validity */
29 return(0);
30
31 if (number < 0) /* check number for validity */
32 return(0);
33
34 for (i = 0; i < number; ++i)
35 for (j = 0; j < size; ++j)
36 if (putc(*buffer8++, stream) EQ EOF)
37 return(i);
38
39 return(number);
40}
41
42
Note: See TracBrowser for help on using the repository browser.