source: buchla-68k/libcio/fwrite.c

Last change on this file 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
RevLine 
[f40a309]1/*
2 =============================================================================
3 fwrite.c -- write a stream file
4 Version 3 -- 1987-07-09 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
[b28a12e]8#include "ram.h"
[f40a309]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
[8973acd]21int16_t fwrite(void *buffer, int16_t size, int16_t number, FILE *stream)
[f40a309]22{
[8973acd]23 uint8_t *buffer8;
[7258c6a]24 register int16_t i, j;
[f40a309]25
[8973acd]26 buffer8 = buffer;
27
[f40a309]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)
[8973acd]36 if (putc(*buffer8++, stream) EQ EOF)
[f40a309]37 return(i);
38
39 return(number);
40}
41
[6262b5c]42
Note: See TracBrowser for help on using the repository browser.