2007-02-20 00:31:54 +00:00
|
|
|
/* $Source$
|
|
|
|
* $State$
|
|
|
|
* $Revision$
|
|
|
|
*/
|
|
|
|
|
2007-02-20 00:25:12 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
2007-04-21 22:59:42 +00:00
|
|
|
#include <unistd.h>
|
2007-02-20 00:25:12 +00:00
|
|
|
#include "libsys.h"
|
|
|
|
|
|
|
|
void _sys_write_tty(char c)
|
|
|
|
{
|
|
|
|
_sys_rawwrite(c);
|
2007-04-21 22:59:42 +00:00
|
|
|
#if 0
|
2007-02-20 00:25:12 +00:00
|
|
|
if ((c == '\n') && !(_sys_ttyflags & RAW))
|
|
|
|
_sys_rawwrite('\r');
|
2007-04-21 22:59:42 +00:00
|
|
|
#endif
|
|
|
|
if (c == '\n')
|
|
|
|
_sys_rawwrite('\r');
|
2007-02-20 00:25:12 +00:00
|
|
|
}
|
|
|
|
|
2007-04-21 22:59:42 +00:00
|
|
|
int write(int fd, void* buffer, size_t count)
|
2007-02-20 00:25:12 +00:00
|
|
|
{
|
|
|
|
int i;
|
2007-04-21 22:59:42 +00:00
|
|
|
char* p = buffer;
|
2007-02-20 00:25:12 +00:00
|
|
|
|
|
|
|
/* We're only allowed to write to fd 0, 1 or 2. */
|
|
|
|
|
2007-04-21 22:59:42 +00:00
|
|
|
if ((fd < 0) || (fd > 2))
|
|
|
|
{
|
|
|
|
errno = EBADF;
|
|
|
|
return -1;
|
|
|
|
}
|
2007-02-20 00:25:12 +00:00
|
|
|
|
|
|
|
/* Write all data. */
|
|
|
|
|
|
|
|
i = 0;
|
2007-04-21 22:59:42 +00:00
|
|
|
while (i < count)
|
2007-02-20 00:25:12 +00:00
|
|
|
{
|
2007-04-21 22:59:42 +00:00
|
|
|
_sys_write_tty(*p++);
|
2007-02-20 00:25:12 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No failures. */
|
|
|
|
|
2007-04-21 22:59:42 +00:00
|
|
|
return count;
|
2007-02-20 00:25:12 +00:00
|
|
|
}
|