*/
#include <unistd.h>
#include <stdlib.h>
-#include <stdio.h>
+#include <string.h>
#include <termios.h>
#include <sys/ioctl.h>
+#define EOF (-1)
+
+static int _getchar(void)
+{
+ static char ch;
+ return (read(0, &ch, 1) == 1) ? ch : EOF;
+}
+
static char *_gets(char *buf, int len)
{
int ch, i = 0;
while (i < len) {
if ((ch = _getchar()) == EOF && i == 0)
return NULL;
-#if 0
- if (ch >= ' ')
- _putchar(ch);
- else {
- _putchar('^');
- _putchar(ch + '@');
- }
-#endif
- if ((ch == 'C' & 037) || (ch == 'Z' & 037))
- return NULL;
if (ch == '\n' || ch == '\r')
break;
buf[i++] = ch;
int tv;
/* display the prompt */
- fputs(prompt, stdout);
- fflush(stdout);
+ write(2, prompt, strlen(prompt));
tv = tcgetattr(0, &t);
ol = t.c_lflag;