Added conio functions

svn path=/trunk/; revision=2034
This commit is contained in:
Eric Kohl 2001-07-04 16:39:37 +00:00
parent d46de4a28a
commit eed177f191
21 changed files with 1989 additions and 54 deletions

View file

@ -0,0 +1,67 @@
/*
* conio.h
*
* Low level console I/O functions. Pretty please try to use the ANSI
* standard ones if you are writing new code.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.1 $
* $Author: ekohl $
* $Date: 2001/07/04 16:31:14 $
*
*/
#ifndef __STRICT_ANSI__
#ifndef _CONIO_H_
#define _CONIO_H_
#ifdef __cplusplus
extern "C" {
#endif
char* _cgets (char* szBuffer);
int _cprintf (const char* szFormat, ...);
int _cputs (const char* szString);
int _cscanf (char* szFormat, ...);
int _getch (void);
int _getche (void);
int _kbhit (void);
int _putch (int cPut);
int _ungetch (int cUnget);
#ifndef _NO_OLDNAMES
#define getch _getch
#define getche _getche
#define kbhit _kbhit
#define putch(cPut) _putch(cPut)
#define ungetch(cUnget) _ungetch(cUnget)
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
}
#endif
#endif /* Not _CONIO_H_ */
#endif /* Not __STRICT_ANSI__ */

View file

@ -0,0 +1,11 @@
/* console.h */
#ifndef __MSVCRT_INTERNAL_CONSOLE_H
#define __MSVCRT_INTERNAL_CONSOLE_H
extern int char_avail;
extern int ungot_char;
#endif /* __MSVCRT_INTERNAL_CONSOLE_H */
/* EOF */

View file

@ -0,0 +1,12 @@
/* stdio.h */
#ifndef __MSVCRT_INTERNAL_STDIO_H
#define __MSVCRT_INTERNAL_STDIO_H
int __vfscanf (FILE *s, const char *format, va_list argptr);
int __vscanf (const char *format, va_list arg);
int __vsscanf (const char *s,const char *format,va_list arg);
#endif /* __MSVCRT_INTERNAL_STDIO_H */
/* EOF */

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.12 2001/07/02 21:51:18 ekohl Exp $
# $Id: Makefile,v 1.13 2001/07/04 16:39:36 ekohl Exp $
#
# ReactOS Operating System
#
@ -12,6 +12,17 @@ CFLAGS = -I../../include -D__MSVCRT__
all: $(TARGET_DLL)
OBJECTS_CONIO = \
conio/cgets.o \
conio/cprintf.o \
conio/cputs.o \
conio/cscanf.o \
conio/getch.o \
conio/getche.o \
conio/kbhit.o \
conio/putch.o \
conio/ungetch.o
OBJECTS_CTYPE = \
ctype/isalnum.o \
ctype/isalpha.o \
@ -65,16 +76,30 @@ OBJECTS_FLOAT = \
OBJECTS_IO = \
io/access.o \
io/chmod.o \
io/chsize.o \
io/close.o \
io/commit.o \
io/create.o \
io/dup.o \
io/dup2.o \
io/eof.o \
io/filelen.o \
io/find.o \
io/fmode.o \
io/isatty.o \
io/locking.o \
io/lseek.o \
io/mktemp.o \
io/open.o \
io/pipe.o \
io/read.o \
io/setmode.o \
io/sopen.o \
io/tell.o \
io/umask.o \
io/unlink.o \
io/utime.o \
io/write.o
OBJECTS_MATH = \
@ -115,6 +140,7 @@ OBJECTS_STDIO = \
stdio/fputc.o \
stdio/fputs.o \
stdio/fread.o \
stdio/fscanf.o \
stdio/fwalk.o \
stdio/fwrite.o \
stdio/getc.o \
@ -123,14 +149,20 @@ OBJECTS_STDIO = \
stdio/putchar.o \
stdio/puts.o \
stdio/remove.o \
stdio/scanf.o \
stdio/setvbuf.o \
stdio/sprintf.o \
stdio/sscanf.o \
stdio/stdhnd.o \
stdio/tempnam.o \
stdio/ungetc.o \
stdio/vfprintf.o \
stdio/vfscanf.o \
stdio/vfwprint.o \
stdio/vprintf.o \
stdio/vscanf.o \
stdio/vsprintf.o \
stdio/vsscanf.o
#incomplete
OBJECTS_STDLIB = \
@ -206,6 +238,7 @@ OBJECTS_STRING = \
OBJECTS_SYS_STAT = \
sys_stat/fstat.o \
sys_stat/futime.o \
sys_stat/stat.o
OBJECTS_TIME = \
@ -239,6 +272,7 @@ OBJECTS_WSTRING = \
wstring/wcsxfrm.o
OBJECTS = \
$(OBJECTS_CONIO) \
$(OBJECTS_CTYPE) \
$(OBJECTS_DIRECT) \
$(OBJECTS_EXCEPT) \
@ -258,6 +292,7 @@ OBJECTS = \
ifeq ($(DOSCLI), yes)
CLEAN_FILES = \
conio\*.o \
ctype\*.o \
direct\*.o \
float\*.o \
@ -280,6 +315,7 @@ CLEAN_FILES = \
base.tmp
else
CLEAN_FILES = \
conio/*.o \
ctype/*.o \
direct/*.o \
float/*.o \

View file

@ -0,0 +1,64 @@
#include <msvcrt/conio.h>
#include <msvcrt/stdlib.h>
char *_cgets(char *string)
{
unsigned len = 0;
unsigned int maxlen_wanted;
char *sp;
int c;
/*
* Be smart and check for NULL pointer.
* Don't know wether TURBOC does this.
*/
if (!string)
return(NULL);
maxlen_wanted = (unsigned int)((unsigned char)string[0]);
sp = &(string[2]);
/*
* Should the string be shorter maxlen_wanted including or excluding
* the trailing '\0' ? We don't take any risk.
*/
while(len < maxlen_wanted-1)
{
c=_getch();
/*
* shold we check for backspace here?
* TURBOC does (just checked) but doesn't in cscanf (thats harder
* or even impossible). We do the same.
*/
if (c == '\b')
{
if (len > 0)
{
_cputs("\b \b"); /* go back, clear char on screen with space
and go back again */
len--;
sp[len] = '\0'; /* clear the character in the string */
}
}
else if (c == '\r')
{
sp[len] = '\0';
break;
}
else if (c == 0)
{
/* special character ends input */
sp[len] = '\0';
_ungetch(c); /* keep the char for later processing */
break;
}
else
{
sp[len] = _putch(c);
len++;
}
}
sp[maxlen_wanted-1] = '\0';
string[1] = (char)((unsigned char)len);
return(sp);
}

View file

@ -0,0 +1,17 @@
#include <msvcrt/stdio.h>
#include <msvcrt/conio.h>
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;
}

View file

@ -0,0 +1,23 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/conio/cputs.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <windows.h>
#include <msvcrt/conio.h>
#include <msvcrt/string.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
int _cputs(const char *_str)
{
int len = strlen(_str);
DWORD written = 0;
if (!WriteFile(filehnd(stdout->_file),_str,len,&written,NULL))
return -1;
return 0;
}

View file

@ -0,0 +1,18 @@
#include <msvcrt/conio.h>
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
int _cscanf(char *fmt, ...)
{
int cnt;
va_list ap;
//fixme cscanf should scan the console's keyboard
va_start(ap, fmt);
cnt = __vscanf(fmt, ap);
va_end(ap);
return cnt;
}

View file

@ -0,0 +1,40 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/conio/getch.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <windows.h>
#include <msvcrt/conio.h>
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/console.h>
int _getch(void)
{
DWORD NumberOfCharsRead = 0;
char c;
if (char_avail)
{
c = ungot_char;
char_avail = 0;
}
else
{
ReadConsoleA(_get_osfhandle(stdin->_file),
&c,
1,
&NumberOfCharsRead,
NULL);
}
if (c == 10)
c = 13;
putchar(c);
return c;
}

View file

@ -0,0 +1,31 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/conio/getche.c
* PURPOSE: Reads a character from stdin
* PROGRAMER: DJ Delorie
Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
int getche(void)
{
if (char_avail)
/*
* We don't know, wether the ungot char was already echoed
* we assume yes (for example in cscanf, probably the only
* place where ungetch is ever called.
* There is no way to check for this really, because
* ungetch could have been called with a character that
* hasn't been got by a conio function.
* We don't echo again.
*/
return(getch());
return (_putch(getch()));
}

View file

@ -0,0 +1,31 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/conio/kbhit.c
* PURPOSE: Checks for keyboard hits
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <windows.h>
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
// FIXME PeekCosoleInput returns more than keyboard hits
int _kbhit(void)
{
INPUT_RECORD InputRecord;
DWORD NumberRead=0;
if (char_avail)
return(1);
else
{
//FIXME PeekConsoleInput might do DeviceIo
//PeekConsoleInput((HANDLE)stdin->_file,&InputRecord,1,&NumberRead);
return NumberRead;
}
return 0;
}

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/conio/putch.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <windows.h>
#include <msvcrt/conio.h>
int _putch(int c)
{
DWORD NumberOfCharsWritten;
if (WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL))
return -1;
return NumberOfCharsWritten;
}

View file

@ -0,0 +1,29 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/conio/ungetch.c
* PURPOSE: Ungets a character from stdin
* PROGRAMER: DJ Delorie
Boudewijn Dekker [ Adapted from djgpp libc ]
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
#define EOF -1
int char_avail = 0;
int ungot_char = 0;
int _ungetch(int c)
{
if (char_avail)
return(EOF);
ungot_char = c;
char_avail = 1;
return(c);
}

View file

@ -1,4 +1,4 @@
; $Id: msvcrt.def,v 1.8 2001/07/03 13:21:22 ekohl Exp $
; $Id: msvcrt.def,v 1.9 2001/07/04 16:39:37 ekohl Exp $
;
; ReactOS MSVCRT Compatibility Library
;
@ -181,13 +181,13 @@ _c_exit
; _cabs
; _callnewh
_cexit
; _cgets
_cgets
_chdir
_chdrive
_chgsign
; _chkesp
; _chmod
; _chsize
_chmod
_chsize
_clearfp
_close
_commit
@ -195,21 +195,21 @@ _commode DATA
_control87
_controlfp
_copysign
; _cprintf
; _cputs
; _creat
; _cscanf
_cprintf
_cputs
_creat
_cscanf
_ctype DATA
; _cwait
; _daylight
; _dstbias
; _dup
; _dup2
_dup
_dup2
; _ecvt
_endthread
_endthreadex
_environ_dll DATA
; _eof
_eof
_errno
_except_handler2
_except_handler3
@ -230,14 +230,14 @@ _fcloseall
; _fgetwchar
_filbuf
; _fileinfo
; _filelength
; _filelengthi64
_filelength
_filelengthi64
_fileno
; _findclose
; _findfirst
; _findfirsti64
; _findnext
; _findnexti64
_findclose
_findfirst
_findfirsti64
_findnext
_findnexti64
_finite
_flsbuf
_flushall
@ -249,16 +249,16 @@ _fpreset
; _fputwchar
; _fsopen
_fstat
; _fstati64
_fstati64
; _ftime
; _ftol
_fullpath
; _futime
_futime
; _gcvt
_get_osfhandle
; _get_sbh_threshold
; _getch
; _getche
_getch
_getche
_getcwd
_getdcwd
_getdiskfree
@ -323,19 +323,19 @@ _itow
; _j0
; _j1
; _jn
; _kbhit
_kbhit
; _lfind
_loaddll
_local_unwind2
; _lock
; _locking
_locking
_logb
; _longjmpex
_lrotl
_lrotr
; _lsearch
_lseek
; _lseeki64
_lseeki64
_ltoa
_ltow
_makepath
@ -410,10 +410,10 @@ _osver DATA
; _pclose
_pctype DATA
_pgmptr DATA
; _pipe
_pipe
; _popen
_purecall
; _putch
_putch
_putenv
; _putw
_putws
@ -442,7 +442,7 @@ _setmode
_sleep
_snprintf
_snwprintf
; _sopen
_sopen
; _spawnl
; _spawnle
; _spawnlp
@ -453,7 +453,7 @@ _snwprintf
; _spawnvpe
_splitpath
_stat
; _stati64
_stati64
_statusfp
_strcmpi
; _strdate
@ -473,8 +473,8 @@ _strupr
_swab
_sys_errlist DATA
_sys_nerr DATA
; _tell
; _telli64
_tell
_telli64
_tempnam
; _timezone
_tolower
@ -485,20 +485,20 @@ _ui64toa
_ui64tow
_ultoa
_ultow
; _umask
; _ungetch
_umask
_ungetch
_unlink
_unloaddll
; _unlock
; _utime
_utime
_vsnprintf
_vsnwprintf
_waccess
; _wasctime
_wchdir
; _wchmod
_wchmod
; _wcmdln
; _wcreat
_wcreat
_wcsdup
_wcsicmp
_wcsicoll
@ -521,10 +521,10 @@ _wcsupr
; _wexecvp
; _wexecvpe
; _wfdopen
; _wfindfirst
; _wfindfirsti64
; _wfindnext
; _wfindnexti64
_wfindfirst
_wfindfirsti64
_wfindnext
_wfindnexti64
; _wfopen
; _wfreopen
; _wfsopen
@ -549,7 +549,7 @@ _write
_wrmdir
_wsearchenv
; _wsetlocale
; _wsopen
_wsopen
; _wspawnl
; _wspawnle
; _wspawnlp
@ -559,8 +559,8 @@ _wsearchenv
; _wspawnvp
; _wspawnvpe
_wsplitpath
; _wstat
; _wstati64
_wstat
_wstati64
; _wstrdate
; _wstrtime
; _wsystem
@ -569,8 +569,8 @@ _wsplitpath
_wtoi
_wtoi64
_wtol
; _wunlink
; _wutime
_wunlink
_wutime
; _y0
; _y1
; _yn
@ -619,13 +619,13 @@ fread
free
; freopen
; frexp
; fscanf
fscanf
; fseek
; fsetpos
; ftell
fwprintf
fwrite
; fwscanf
fwscanf
getc
; getchar
getenv
@ -693,7 +693,7 @@ realloc
remove
; rename
; rewind
; scanf
scanf
; setbuf
; setlocale
setvbuf
@ -703,7 +703,7 @@ signal
sprintf
; sqrt
; srand
; sscanf
sscanf
strcat
strchr
strcmp
@ -726,7 +726,7 @@ strtol
strtoul
strxfrm
swprintf
; swscanf
swscanf
; system
; tan
; tanh
@ -737,8 +737,8 @@ tolower
toupper
towlower
towupper
; ungetc
; ungetwc
ungetc
ungetwc
vfprintf
vfwprintf
vprintf
@ -768,6 +768,6 @@ wcstoul
wcsxfrm
; wctomb
wprintf
; wscanf
wscanf
; EOF

View file

@ -0,0 +1,59 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
#include <msvcrt/wchar.h>
#include <msvcrt/alloc.h>
#include <msvcrt/internal/stdio.h>
/* Read formatted input from STREAM according to the format string FORMAT. */
/* VARARGS2 */
int fscanf(FILE *stream,const char *format, ...)
{
va_list arg;
int done;
va_start(arg, format);
done = __vfscanf(stream, format, arg);
va_end(arg);
return done;
}
int
fwscanf(FILE *stream, const wchar_t *fmt, ...)
{
va_list arg;
int done;
char *cf;
int i,len = wcslen(fmt);
cf = malloc(len+1);
for(i=0;i<len;i++)
cf[i] = fmt[i];
cf[i] = 0;
va_start(arg, fmt);
done = __vfscanf(stream, cf, arg);
va_end(arg);
free(cf);
return done;
}

View file

@ -0,0 +1,58 @@
/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
#include <msvcrt/wchar.h>
#include <msvcrt/alloc.h>
#include <msvcrt/internal/stdio.h>
/* Read formatted input from stdin according to the format string FORMAT. */
/* VARARGS1 */
int scanf(const char *format, ...)
{
va_list arg;
int done;
va_start(arg, format);
done = __vscanf(format, arg);
va_end(arg);
return done;
}
int
wscanf(const wchar_t *fmt, ...)
{
va_list arg;
int done;
char *f;
int i, len = wcslen(fmt);
f = malloc(len+1);
for(i=0;i<len;i++)
f[i] = fmt[i];
f[i] = 0;
va_start(arg, fmt);
done = __vscanf(f, arg);
va_end(arg);
free(f);
return done;
}

View file

@ -0,0 +1,65 @@
/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
#include <msvcrt/wchar.h>
#include <msvcrt/alloc.h>
#include <msvcrt/internal/stdio.h>
/* Read formatted input from S, according to the format string FORMAT. */
/* VARARGS2 */
int sscanf (const char *s,const char *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
done = __vsscanf (s, format, arg);
va_end (arg);
return done;
}
int swscanf(const wchar_t *str, const wchar_t *fmt, ...)
{
va_list arg;
int done;
char *f , *s;
int i,len = wcslen(fmt);
f = malloc(len+1);
for(i=0;i<len;i++)
f[i] = fmt[i];
f[i] = 0;
len = wcslen(str);
s = alloca(len+1);
for(i=0;i<len;i++)
s[i] = str[i];
s[i] = 0;
va_start (arg, fmt);
done = __vsscanf (s, f, arg);
va_end (arg);
free(f);
return done;
}

View file

@ -0,0 +1,71 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/stdio.h>
#include <msvcrt/wchar.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
int ungetc(int c, FILE *f)
{
if (!__validfp (f) || !OPEN4READING(f))
{
__set_errno (EINVAL);
return EOF;
}
if (c == EOF)
return EOF;
if (f->_ptr == NULL || f->_base == NULL)
return EOF;
if (f->_ptr == f->_base)
{
if (f->_cnt == 0)
f->_ptr++;
else
return EOF;
}
f->_cnt++;
f->_ptr--;
if (*f->_ptr != c)
{
f->_flag |= _IOUNGETC;
*f->_ptr = c;
}
return c;
}
wint_t
ungetwc(wchar_t c, FILE *f)
{
if (!__validfp (f) || !OPEN4READING(f))
{
__set_errno(EINVAL);
return EOF;
}
if (c == (wchar_t)EOF)
return EOF;
if (f->_ptr == NULL || f->_base == NULL)
return EOF;
if (f->_ptr == f->_base)
{
if (f->_cnt == 0)
f->_ptr+=sizeof(wchar_t);
else
return EOF;
}
f->_cnt+=sizeof(wchar_t);
f->_ptr-=sizeof(wchar_t);
f->_flag |= _IOUNGETC;
*((wchar_t *)(f->_ptr)) = c;
return c;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,33 @@
/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/internal/stdio.h>
#undef vscanf
/* Read formatted input from stdin according to the format
string in FORMAT, using the argument list in ARG. */
int __vscanf (const char *format, va_list arg)
{
return __vfscanf(stdin, format, arg);
}

View file

@ -0,0 +1,49 @@
/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <msvcrt/errno.h>
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
#include <msvcrt/string.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/internal/stdio.h>
#undef vsscanf
/* Read formatted input from S according to the format
string FORMAT, using the argument list in ARG. */
int __vsscanf(const char *s,const char *format,va_list arg)
{
FILE f;
if (s == NULL)
{
__set_errno(EINVAL);
return -1;
}
memset((void *) &f, 0, sizeof (f));
f._flag = _IOREAD;
f._ptr = (char *)s;
f._base = (char *)s;
f._bufsiz = strlen(s);
f._cnt = f._bufsiz;
return __vfscanf(&f, format, arg);
}