source: buchla-68k/orig/IOLIB/FWRITE.C@ fe7b401

Last change on this file since fe7b401 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
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
22int
23fwrite(buffer, size, number, stream)
24register char *buffer;
25register int size, number;
26register FILE *stream;
27{
28 register int i, j;
29
30 if (size < 0) /* check size for validity */
31 return(0);
32
33 if (number < 0) /* check number for validity */
34 return(0);
35
36 for (i = 0; i < number; ++i)
37 for (j = 0; j < size; ++j)
38 if (putc(*buffer++, stream) EQ EOF)
39 return(i);
40
41 return(number);
42}
43
Note: See TracBrowser for help on using the repository browser.