From 95a2cd92256aa3dba52a16fcf90fa0b1cf9aadfc Mon Sep 17 00:00:00 2001 From: Boudewijn Dekker Date: Sun, 21 Feb 1999 08:39:36 +0000 Subject: [PATCH] Added some files svn path=/trunk/; revision=254 --- reactos/lib/crtdll/conio/cprintf.c | 17 +++++++++++++++++ reactos/lib/crtdll/conio/cscanf.c | 26 ++++++++++++++++++++++++++ reactos/lib/crtdll/conio/getch.c | 4 ++-- reactos/lib/crtdll/conio/kbhit.c | 13 +++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 reactos/lib/crtdll/conio/cprintf.c create mode 100644 reactos/lib/crtdll/conio/cscanf.c create mode 100644 reactos/lib/crtdll/conio/kbhit.c diff --git a/reactos/lib/crtdll/conio/cprintf.c b/reactos/lib/crtdll/conio/cprintf.c new file mode 100644 index 00000000000..72411163751 --- /dev/null +++ b/reactos/lib/crtdll/conio/cprintf.c @@ -0,0 +1,17 @@ +#include +#include + +int +cprintf(const char *fmt, ...) +{ + int cnt; + char buf[ 2048 ]; /* this is buggy, because buffer might be too small. */ + va_list ap; + + va_start(ap, fmt); + cnt = vsprintf(buf, fmt, ap); + va_end(ap); + + cputs(buf); + return cnt; +} diff --git a/reactos/lib/crtdll/conio/cscanf.c b/reactos/lib/crtdll/conio/cscanf.c new file mode 100644 index 00000000000..3fa931c035a --- /dev/null +++ b/reactos/lib/crtdll/conio/cscanf.c @@ -0,0 +1,26 @@ +#include + + +/* + * The next two functions are needed by cscanf + */ +static int +_scan_getche(FILE *fp) +{ + return(getche()); +} + +static int +_scan_ungetch(int c, FILE *fp) +{ + return(ungetch(c)); +} + +int +_cscanf(const char *fmt, ...) +{ + return(_doscan_low(NULL, _scan_getche, _scan_ungetch, + fmt, (void **) unconst( ((&fmt)+1), char ** ))); +} + + diff --git a/reactos/lib/crtdll/conio/getch.c b/reactos/lib/crtdll/conio/getch.c index 5fc66ed507a..e83c885e157 100644 --- a/reactos/lib/crtdll/conio/getch.c +++ b/reactos/lib/crtdll/conio/getch.c @@ -32,11 +32,11 @@ _getch(void) } else { - ReadConsoleA(filehnd(stdin->_file), &c,1,&NumberOfCharsRead ,NULL); + ReadConsoleA(_get_osfhandle(stdin->_file), &c,1,&NumberOfCharsRead ,NULL); } if ( c == 10 ) c = 13; putchar(c); return c; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/conio/kbhit.c b/reactos/lib/crtdll/conio/kbhit.c new file mode 100644 index 00000000000..50b185f7d36 --- /dev/null +++ b/reactos/lib/crtdll/conio/kbhit.c @@ -0,0 +1,13 @@ +int +_kbhit(void) +{ + INPUT_RECORD InputRecord; + DWORD NumberRead; + if (char_avail) + return(1); + else { + PeekConsoleInput(stdin->file,&InputRecord,1,&NumberRead); + return NumberRead; + } + return 0; +}