Compare commits
No commits in common. "00672c4b221995cc0125df5ec5a4d705fd9955aa" and "cda036ce701e353da6e10899e55d4423cc629fc5" have entirely different histories.
00672c4b22
...
cda036ce70
@ -3,10 +3,4 @@
|
|||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
printf("Hello world! argc=%d, argv[0]=%s, argv[1]=%s, argv[2]=%s\n", argc, argv[0], argv[1], argv[2]);
|
printf("Hello world! argc=%d, argv[0]=%s, argv[1]=%s, argv[2]=%s\n", argc, argv[0], argv[1], argv[2]);
|
||||||
|
|
||||||
char buf[1024];
|
|
||||||
char* rc = fgets(buf, sizeof(buf), stdin);
|
|
||||||
if (!rc) perror("fgets");
|
|
||||||
|
|
||||||
fputs(buf, stdout);
|
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,11 @@ void io_thread()
|
|||||||
while (!scancode_queue.try_pop(scancode)) { kernel_sleep(10); }
|
while (!scancode_queue.try_pop(scancode)) { kernel_sleep(10); }
|
||||||
|
|
||||||
char key;
|
char key;
|
||||||
if (Keyboard::decode_scancode(scancode).try_set_value(key)) { ConsoleDevice::did_press_key(key); }
|
if (Keyboard::decode_scancode(scancode).try_set_value(key))
|
||||||
|
{
|
||||||
|
TextConsole::putchar(key);
|
||||||
|
ConsoleDevice::did_press_key(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ void ConsoleDevice::did_press_key(char key)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_temp_input.try_append((u8)key).value();
|
g_temp_input.try_append(key).value();
|
||||||
|
|
||||||
if (key == '\n')
|
if (key == '\n')
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ bool FileDescriptor::should_append()
|
|||||||
|
|
||||||
bool FileDescriptor::should_block()
|
bool FileDescriptor::should_block()
|
||||||
{
|
{
|
||||||
return !(flags & O_NONBLOCK);
|
return flags & O_NONBLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileDescriptor::is_readable()
|
bool FileDescriptor::is_readable()
|
||||||
|
@ -81,18 +81,6 @@ extern "C"
|
|||||||
/* Write a string to stream. */
|
/* Write a string to stream. */
|
||||||
int fputs(const char* str, FILE* stream);
|
int fputs(const char* str, FILE* stream);
|
||||||
|
|
||||||
/* Read a character from stream. */
|
|
||||||
int fgetc(FILE* stream);
|
|
||||||
|
|
||||||
/* Read a character from stream. */
|
|
||||||
int getc(FILE* stream);
|
|
||||||
|
|
||||||
/* Read a character from standard input. */
|
|
||||||
int getchar();
|
|
||||||
|
|
||||||
/* Read a line from stream. */
|
|
||||||
char* fgets(char* buf, size_t size, FILE* stream);
|
|
||||||
|
|
||||||
/* Clear the error and end-of-file indicators in stream. */
|
/* Clear the error and end-of-file indicators in stream. */
|
||||||
void clearerr(FILE* stream);
|
void clearerr(FILE* stream);
|
||||||
|
|
||||||
|
@ -187,42 +187,6 @@ extern "C"
|
|||||||
return (rc < 0) ? -1 : 0;
|
return (rc < 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fgetc(FILE* stream)
|
|
||||||
{
|
|
||||||
u8 value;
|
|
||||||
ssize_t rc = read(stream->_fd, &value, 1);
|
|
||||||
if (rc <= 0) return EOF;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getc(FILE* stream)
|
|
||||||
{
|
|
||||||
return fgetc(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
int getchar()
|
|
||||||
{
|
|
||||||
return fgetc(stdin);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* fgets(char* buf, size_t size, FILE* stream)
|
|
||||||
{
|
|
||||||
size_t i = 0;
|
|
||||||
while (i + 1 < size)
|
|
||||||
{
|
|
||||||
int c = fgetc(stream);
|
|
||||||
if (c == EOF) break;
|
|
||||||
buf[i++] = (char)c;
|
|
||||||
if (c == '\n') break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == 0) return NULL;
|
|
||||||
|
|
||||||
buf[i] = 0;
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearerr(FILE* stream)
|
void clearerr(FILE* stream)
|
||||||
{
|
{
|
||||||
stream->_eof = stream->_err = 0;
|
stream->_eof = stream->_err = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user