source: buchla-68k/libcio/fwrite.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: 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 "stdio.h"
9#include "stddefs.h"
10
11/*
12 =============================================================================
13 fwrite(buffer, size, number, stream) -- write 'number' items of sixe
14 'size' bytes from 'buffer' onto 'stream'. Returns the number of items
15 written. If 'number' or 'size' is negative, nothing is written, and
16 0 is returned. EOF may cause the last item written to be imcomplete.
17 Check with feof() to detect an EOF condition. Use ferror() to check
18 for error conditions.
19 =============================================================================
20*/
21
22int16_t fwrite(int8_t *buffer, int16_t size, int16_t number, FILE *stream)
23{
24 register int16_t i, j;
25
26 if (size < 0) /* check size for validity */
27 return(0);
28
29 if (number < 0) /* check number for validity */
30 return(0);
31
32 for (i = 0; i < number; ++i)
33 for (j = 0; j < size; ++j)
34 if (putc(*buffer++, stream) EQ EOF)
35 return(i);
36
37 return(number);
38}
39
Note: See TracBrowser for help on using the repository browser.