#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <libp.h>

size_t fwrite(void *buf, size_t size, size_t count, FILE *stream)
{
	int len = size * count,i;
	if (stream->token != FILTOK) {
		errno = _dos_errno = ENOENT;
		return 0;
	}
	if (!(stream->flags & _F_WRIT)) {
		stream->flags |= _F_ERR;
		return 0;
	}
	for (i=0; i < len; i++)
		if (_baseputc(*((unsigned char *)buf)++,stream) == EOF)
			return i / size;
	return count;
}