Last change
on this file since cbe2c15 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
1.2 KB
|
Rev | Line | |
---|
[3ae31e9] | 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 |
|
---|
| 22 | int
|
---|
| 23 | fwrite(buffer, size, number, stream)
|
---|
| 24 | register char *buffer;
|
---|
| 25 | register int size, number;
|
---|
| 26 | register 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.