kolibrios/contrib/sdk/sources/newlib/libc/sys/conio.c
turbocat 9562f01892 NewLib:
- Duplicate functionality files removed;
- Refactoring of file handling functions;
- Removed broken impliments.
Gears (C + TinyGL):
- Removed because it duplicates an existing example on Fasm and uses unsupported wrappers on the KOS API.
KosJS:
- Removed. The MuJS port is too old and not used anywhere. Support is not profitable.
Backy:
- Removed useless GCC version. Support is not profitable.
DGen-SDL and SQLite3
- Fix after removing broken "dirent.h".
Fridge:
- Moving the KOS API wrapper to avoid compilation errors.
Udis86, uARM and 8086tiny:
- Fix after removing redundant "kos_LoadConsole.h".


git-svn-id: svn://kolibrios.org@9952 a494cfbc-eb01-0410-851d-a64ba20cac60
2024-01-04 22:20:35 +00:00

58 lines
1.4 KiB
C

/*
* Copyright (C) KolibriOS team 2004-2024. All rights reserved.
* Distributed under terms of the GNU General Public License
*/
#include <_ansi.h>
#include <stdio.h>
#include <sys/unistd.h>
#include "io.h"
#include <string.h>
extern void load_libconsole();
extern void __stdcall con_init(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t);
extern void __stdcall con_exit(char bCloseWindow);
extern void __stdcall con_write_string(const char* string, unsigned length);
extern char* __stdcall con_gets(char*, unsigned);
int __gui_mode;
static int console_read(const char *path, void *buff,
size_t offset, size_t count, size_t *done)
{
char *p = buff;
con_gets(p, count+1);
*done = strlen(p);
return 0;
}
static int console_write(const char *path, const void *buff,
size_t offset, size_t count, size_t *writes)
{
con_write_string(buff, count);
*writes = count;
return 0;
}
void __init_conio()
{
__io_handle *ioh;
load_libconsole();
con_init(80, 25, 80, 500, "Console application");
ioh = &__io_tab[STDIN_FILENO];
ioh->mode = _READ|_ISTTY;
ioh->read = &console_read;
ioh = &__io_tab[STDOUT_FILENO];
ioh->mode = _WRITE|_ISTTY;
ioh->write = &console_write;
};
void __fini_conio()
{
con_exit(0);
}