int uart_putc(int port, char c) { if (c == '\n') { _uart_putc(0, '\r'); } _uart_putc(0, c); }
static int _uart_putc(char c, FILE* stream) { if (c == '\n') { _uart_putc('\r', NULL); } uart_putc(c); return 0; }
/* -------------------------------------------------------------------------- */ int _read (int file, char *buf, int len) { if (STDIN_FILENO == file) { int i; for (i = 0; i < len; i++) { buf[i] = _uart_getc (); #ifdef UART_AUTO_ECHO _uart_putc (buf[i]); #endif /* Return partial buffer if we get EOL */ if ('\n' == buf[i]) { return i; } } return i; /* Filled the buffer */ } else { errno = EBADF; return -1; } } /* _read () */