2007-04-27 22:42:41 +00:00
|
|
|
/* $Source$
|
|
|
|
* $State$
|
|
|
|
* $Revision$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <cpm.h>
|
|
|
|
|
|
|
|
void _sys_write_tty(char c)
|
|
|
|
{
|
2019-06-10 21:54:23 +00:00
|
|
|
cpm_conout(c);
|
2007-04-27 22:42:41 +00:00
|
|
|
if (c == '\n')
|
2019-06-10 21:54:23 +00:00
|
|
|
cpm_conout(c);
|
2007-04-27 22:42:41 +00:00
|
|
|
}
|
|
|
|
|
2018-06-23 09:46:55 +00:00
|
|
|
ssize_t write(int fd, void* buffer, size_t count)
|
2007-04-27 22:42:41 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char* p = buffer;
|
|
|
|
|
|
|
|
/* We're only allowed to write to fd 0, 1 or 2. */
|
|
|
|
|
|
|
|
if ((fd < 0) || (fd > 2))
|
|
|
|
{
|
|
|
|
errno = EBADF;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write all data. */
|
|
|
|
|
2019-06-10 21:54:23 +00:00
|
|
|
i = count;
|
|
|
|
while (i--)
|
2007-04-27 22:42:41 +00:00
|
|
|
_sys_write_tty(*p++);
|
|
|
|
|
|
|
|
/* No failures. */
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|