Last change
on this file since 1efe224 was b28a12e, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Zero redundant declarations.
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[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 |
|
---|
[7258c6a] | 21 | int16_t fwrite(int8_t *buffer, int16_t size, int16_t number, FILE *stream)
|
---|
[f40a309] | 22 | {
|
---|
[7258c6a] | 23 | register int16_t i, j;
|
---|
[f40a309] | 24 |
|
---|
| 25 | if (size < 0) /* check size for validity */
|
---|
| 26 | return(0);
|
---|
| 27 |
|
---|
| 28 | if (number < 0) /* check number for validity */
|
---|
| 29 | return(0);
|
---|
| 30 |
|
---|
| 31 | for (i = 0; i < number; ++i)
|
---|
| 32 | for (j = 0; j < size; ++j)
|
---|
| 33 | if (putc(*buffer++, stream) EQ EOF)
|
---|
| 34 | return(i);
|
---|
| 35 |
|
---|
| 36 | return(number);
|
---|
| 37 | }
|
---|
| 38 |
|
---|
[6262b5c] | 39 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.