From e5e74911b3333043f345dae53f09e90de1be1ded Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 6 Jul 2001 00:58:15 +0000 Subject: [PATCH] Added missing math and stdio functions svn path=/trunk/; revision=2041 --- reactos/lib/msvcrt/Makefile | 53 ++++++++- reactos/lib/msvcrt/msvcrt.def | 170 +++++++++++++------------- reactos/lib/msvcrt/stdio/clearerr.c | 19 +++ reactos/lib/msvcrt/stdio/fdopen.c | 102 ++++++++++++++++ reactos/lib/msvcrt/stdio/fgetc.c | 23 ++++ reactos/lib/msvcrt/stdio/fgetchar.c | 12 ++ reactos/lib/msvcrt/stdio/fgetpos.c | 14 +++ reactos/lib/msvcrt/stdio/fopen.c | 65 ++++++++++ reactos/lib/msvcrt/stdio/fputchar.c | 14 +++ reactos/lib/msvcrt/stdio/freopen.c | 122 +++++++++++++++++++ reactos/lib/msvcrt/stdio/fseek.c | 54 +++++++++ reactos/lib/msvcrt/stdio/fsetpos.c | 15 +++ reactos/lib/msvcrt/stdio/fsopen.c | 177 ++++++++++++++++++++++++++++ reactos/lib/msvcrt/stdio/ftell.c | 46 ++++++++ reactos/lib/msvcrt/stdio/getchar.c | 10 ++ reactos/lib/msvcrt/stdio/gets.c | 106 +++++++++++++++++ reactos/lib/msvcrt/stdio/getw.c | 30 +++++ reactos/lib/msvcrt/stdio/perror.c | 20 ++++ reactos/lib/msvcrt/stdio/popen.c | 102 ++++++++++++++++ reactos/lib/msvcrt/stdio/putw.c | 30 +++++ reactos/lib/msvcrt/stdio/rename.c | 27 +++++ reactos/lib/msvcrt/stdio/rewind.c | 15 +++ reactos/lib/msvcrt/stdio/rmtmp.c | 72 +++++++++++ reactos/lib/msvcrt/stdio/setbuf.c | 12 ++ reactos/lib/msvcrt/stdio/tempnam.c | 43 +++++-- reactos/lib/msvcrt/stdio/tmpfile.c | 67 +++++++++++ reactos/lib/msvcrt/stdio/tmpnam.c | 28 +++++ 27 files changed, 1351 insertions(+), 97 deletions(-) create mode 100644 reactos/lib/msvcrt/stdio/clearerr.c create mode 100644 reactos/lib/msvcrt/stdio/fdopen.c create mode 100644 reactos/lib/msvcrt/stdio/fgetc.c create mode 100644 reactos/lib/msvcrt/stdio/fgetchar.c create mode 100644 reactos/lib/msvcrt/stdio/fgetpos.c create mode 100644 reactos/lib/msvcrt/stdio/fputchar.c create mode 100644 reactos/lib/msvcrt/stdio/freopen.c create mode 100644 reactos/lib/msvcrt/stdio/fseek.c create mode 100644 reactos/lib/msvcrt/stdio/fsetpos.c create mode 100644 reactos/lib/msvcrt/stdio/fsopen.c create mode 100644 reactos/lib/msvcrt/stdio/ftell.c create mode 100644 reactos/lib/msvcrt/stdio/getchar.c create mode 100644 reactos/lib/msvcrt/stdio/gets.c create mode 100644 reactos/lib/msvcrt/stdio/getw.c create mode 100644 reactos/lib/msvcrt/stdio/perror.c create mode 100644 reactos/lib/msvcrt/stdio/popen.c create mode 100644 reactos/lib/msvcrt/stdio/putw.c create mode 100644 reactos/lib/msvcrt/stdio/rename.c create mode 100644 reactos/lib/msvcrt/stdio/rewind.c create mode 100644 reactos/lib/msvcrt/stdio/rmtmp.c create mode 100644 reactos/lib/msvcrt/stdio/setbuf.c create mode 100644 reactos/lib/msvcrt/stdio/tmpfile.c create mode 100644 reactos/lib/msvcrt/stdio/tmpnam.c diff --git a/reactos/lib/msvcrt/Makefile b/reactos/lib/msvcrt/Makefile index 231bf8e680c..7fd780f79e8 100644 --- a/reactos/lib/msvcrt/Makefile +++ b/reactos/lib/msvcrt/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.14 2001/07/04 20:40:19 chorns Exp $ +# $Id: Makefile,v 1.15 2001/07/06 00:58:15 ekohl Exp $ # # ReactOS Operating System # @@ -103,9 +103,37 @@ OBJECTS_IO = \ io/write.o OBJECTS_MATH = \ + math/acos.o \ math/adjust.o \ + math/asin.o \ + math/atan.o \ + math/atan2.o \ + math/cabs.o \ + math/ceil.o \ + math/cos.o \ + math/cosh.o \ + math/exp.o \ + math/fabs.o \ + math/floor.o \ + math/fmod.o \ + math/frexp.o \ + math/ftol.o \ + math/huge_val.o \ + math/hypot.o \ + math/j0_y0.o \ + math/j1_y1.o \ + math/jn_yn.o \ + math/ldexp.o \ + math/log.o \ + math/log10.o \ math/modf.o \ math/pow.o \ + math/sin.o \ + math/sinh.o \ + math/sqrt.o \ + math/stubs.o \ + math/tan.o \ + math/tanh.o OBJECTS_MISC = \ misc/amsg.o \ @@ -127,10 +155,15 @@ OBJECTS_SIGNAL = \ OBJECTS_STDIO = \ stdio/allocfil.o \ + stdio/clearerr.o \ stdio/fclose.o \ + stdio/fdopen.o \ stdio/feof.o \ stdio/ferror.o \ stdio/fflush.o \ + stdio/fgetc.o \ + stdio/fgetchar.o \ + stdio/fgetpos.o \ stdio/fgets.o \ stdio/filbuf.o \ stdio/fileno.o \ @@ -138,23 +171,41 @@ OBJECTS_STDIO = \ stdio/fopen.o \ stdio/fprintf.o \ stdio/fputc.o \ + stdio/fputchar.o \ stdio/fputs.o \ stdio/fread.o \ + stdio/freopen.o \ stdio/fscanf.o \ + stdio/fseek.o \ + stdio/fsetpos.o \ + stdio/fsopen.o \ + stdio/ftell.o \ stdio/fwalk.o \ stdio/fwrite.o \ stdio/getc.o \ + stdio/getchar.o \ + stdio/gets.o \ + stdio/getw.o \ + stdio/perror.o \ + stdio/popen.o \ stdio/printf.o \ stdio/putc.o \ stdio/putchar.o \ stdio/puts.o \ + stdio/putw.o \ stdio/remove.o \ + stdio/rename.o \ + stdio/rewind.o \ + stdio/rmtmp.o \ stdio/scanf.o \ + stdio/setbuf.o \ stdio/setvbuf.o \ stdio/sprintf.o \ stdio/sscanf.o \ stdio/stdhnd.o \ stdio/tempnam.o \ + stdio/tmpfile.o \ + stdio/tmpnam.o \ stdio/ungetc.o \ stdio/vfprintf.o \ stdio/vfscanf.o \ diff --git a/reactos/lib/msvcrt/msvcrt.def b/reactos/lib/msvcrt/msvcrt.def index 6e5f3ce6758..52b7abcd2f5 100644 --- a/reactos/lib/msvcrt/msvcrt.def +++ b/reactos/lib/msvcrt/msvcrt.def @@ -1,4 +1,4 @@ -; $Id: msvcrt.def,v 1.9 2001/07/04 16:39:37 ekohl Exp $ +; $Id: msvcrt.def,v 1.10 2001/07/06 00:58:15 ekohl Exp $ ; ; ReactOS MSVCRT Compatibility Library ; @@ -59,28 +59,28 @@ EXPORTS ;---------------------------------------------------------------------- ; C Undecorated Symbols ;---------------------------------------------------------------------- -; _CIacos -; _CIasin -; _CIatan -; _CIatan2 -; _CIcos -; _CIcosh -; _CIexp -; _CIfmod -; _CIlog -; _CIlog10 -; _CIpow -; _CIsin -; _CIsinh -; _CIsqrt -; _CItan -; _CItanh +_CIacos +_CIasin +_CIatan +_CIatan2 +_CIcos +_CIcosh +_CIexp +_CIfmod +_CIlog +_CIlog10 +_CIpow +_CIsin +_CIsinh +_CIsqrt +_CItan +_CItanh ; _CxxThrowException ; _EH_prolog ; _Getdays ; _Getmonths ; _Gettnames -; _HUGE +_HUGE DATA ; _Strftime _XcptFilter ; __CxxFrameHandler @@ -178,7 +178,7 @@ _beep _beginthread _beginthreadex _c_exit -; _cabs +_cabs ; _callnewh _cexit _cgets @@ -225,9 +225,9 @@ _exit ; _expand _fcloseall ; _fcvt -; _fdopen -; _fgetchar -; _fgetwchar +_fdopen +_fgetchar +_fgetwchar _filbuf ; _fileinfo _filelength @@ -245,13 +245,13 @@ _fmode DATA _fpclass _fpieee_flt _fpreset -; _fputchar -; _fputwchar -; _fsopen +_fputchar +_fputwchar +_fsopen _fstat _fstati64 ; _ftime -; _ftol +_ftol _fullpath _futime ; _gcvt @@ -269,7 +269,7 @@ _getdrives ; _getmbcp _getpid ; _getsystime -; _getw +_getw ; _getws _global_unwind2 ; _heapadd @@ -278,7 +278,7 @@ _global_unwind2 ; _heapset ; _heapused ; _heapwalk -; _hypot +_hypot _i64toa _i64tow _initterm @@ -320,9 +320,9 @@ _isctype _isnan _itoa _itow -; _j0 -; _j1 -; _jn +_j0 +_j1 +_jn _kbhit ; _lfind _loaddll @@ -407,20 +407,20 @@ _osver DATA ; _outp ; _outpd ; _outpw -; _pclose +_pclose _pctype DATA _pgmptr DATA _pipe -; _popen +_popen _purecall _putch _putenv -; _putw +_putw _putws _pwctype DATA _read _rmdir -; _rmtmp +_rmtmp _rotl _rotr ; _safe_fdiv @@ -520,14 +520,14 @@ _wcsupr ; _wexecve ; _wexecvp ; _wexecvpe -; _wfdopen +_wfdopen _wfindfirst _wfindfirsti64 _wfindnext _wfindnexti64 -; _wfopen -; _wfreopen -; _wfsopen +_wfopen +_wfreopen +_wfsopen _wfullpath _wgetcwd _wgetdcwd @@ -539,12 +539,12 @@ _wmakepath _wmkdir ; _wmktemp _wopen -; _wperror +_wperror ; _wpgmptr DATA -; _wpopen +_wpopen _wputenv _wremove -; _wrename +_wrename _write _wrmdir _wsearchenv @@ -564,51 +564,51 @@ _wstati64 ; _wstrdate ; _wstrtime ; _wsystem -; _wtempnam -; _wtmpnam +_wtempnam +_wtmpnam _wtoi _wtoi64 _wtol _wunlink _wutime -; _y0 -; _y1 -; _yn +_y0 +_y1 +_yn abort abs -; acos +acos asctime -; asin -; atan -; atan2 +asin +atan +atan2 atexit atof atoi atol bsearch calloc -; ceil -; clearerr +ceil +clearerr ; clock -; cos -; cosh +cos +cosh ctime ; difftime div exit -; exp -; fabs +exp +fabs fclose feof ferror fflush -; fgetc -; fgetpos +fgetc +fgetpos fgets -; fgetwc +fgetwc ; fgetws -; floor -; fmod +floor +fmod fopen fprintf fputc @@ -617,19 +617,19 @@ fputwc ; fputws fread free -; freopen -; frexp +freopen +frexp fscanf -; fseek -; fsetpos -; ftell +fseek +fsetpos +ftell fwprintf fwrite fwscanf getc -; getchar +getchar getenv -; gets +gets getwc ; getwchar gmtime @@ -660,12 +660,12 @@ iswupper iswxdigit isxdigit labs -; ldexp +ldexp ldiv ; localeconv localtime -; log -; log10 +log +log10 ; longjmp malloc ; mblen @@ -678,7 +678,7 @@ memmove memset mktime modf -; perror +perror pow printf putc @@ -688,21 +688,21 @@ putwc putwchar qsort raise -; rand +rand realloc remove -; rename -; rewind +rename +rewind scanf -; setbuf +setbuf ; setlocale setvbuf signal -; sin -; sinh +sin +sinh sprintf -; sqrt -; srand +sqrt +srand sscanf strcat strchr @@ -728,11 +728,11 @@ strxfrm swprintf swscanf ; system -; tan -; tanh +tan +tanh time -; tmpfile -; tmpnam +tmpfile +tmpnam tolower toupper towlower diff --git a/reactos/lib/msvcrt/stdio/clearerr.c b/reactos/lib/msvcrt/stdio/clearerr.c new file mode 100644 index 00000000000..5055fa7f670 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/clearerr.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +#ifdef clearerr +#undef clearerr +void clearerr(FILE *stream); +#endif + +void +clearerr(FILE *f) +{ + if (!__validfp (f)) { + __set_errno (EINVAL); + return; + } + f->_flag &= ~(_IOERR|_IOEOF); +} diff --git a/reactos/lib/msvcrt/stdio/fdopen.c b/reactos/lib/msvcrt/stdio/fdopen.c new file mode 100644 index 00000000000..a9f70ccc888 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fdopen.c @@ -0,0 +1,102 @@ +#include +#include + +FILE * __alloc_file(void); + +FILE *_fdopen(int handle, char *mode) +{ + FILE *file; + int rw; + + if (handle == 0) + return stdin; + + if (handle == 1) + return stdout; + + if (handle == 2) + return stderr; + + if (handle == 3) + return stdaux; + + if (handle == 4) + return stdprn; + + file = __alloc_file(); + if (file == NULL) + return NULL; + file->_file = handle; + + rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+')); + + if (*mode == 'a') + _lseek(handle, 0, SEEK_END); + + file->_cnt = 0; + file->_file = handle; + file->_bufsiz = 0; + +// The mode of the stream must be compatible with the mode of the file descriptor. +// this should be checked. + + if (rw) + file->_flag = _IOREAD | _IOWRT; + else if (*mode == 'r') + file->_flag = _IOREAD; + else + file->_flag = _IOWRT; + + file->_base = file->_ptr = NULL; + + return file; +} + +FILE *_wfdopen(int handle, wchar_t *mode) +{ + FILE *file; + int rw; + + if (handle == 0) + return stdin; + + if (handle == 1) + return stdout; + + if (handle == 2) + return stderr; + + if (handle == 3) + return stdaux; + + if (handle == 4) + return stdprn; + + file = __alloc_file(); + if (file == NULL) + return NULL; + file->_file = handle; + + rw = (mode[1] == L'+') || (mode[1] && (mode[2] == L'+')); + + if (*mode == L'a') + _lseek(handle, 0, SEEK_END); + + file->_cnt = 0; + file->_file = handle; + file->_bufsiz = 0; + +// The mode of the stream must be compatible with the mode of the file descriptor. +// this should be checked. + + if (rw) + file->_flag = _IOREAD | _IOWRT; + else if (*mode == L'r') + file->_flag = _IOREAD; + else + file->_flag = _IOWRT; + + file->_base = file->_ptr = NULL; + + return file; +} diff --git a/reactos/lib/msvcrt/stdio/fgetc.c b/reactos/lib/msvcrt/stdio/fgetc.c new file mode 100644 index 00000000000..7ce598cfab6 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fgetc.c @@ -0,0 +1,23 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/crtdll/stdio/fgetc.c + * PURPOSE: Get a character string from stdin + * PROGRAMER: Boudewijn Dekker + * UPDATE HISTORY: + * 28/12/98: Appropriated for Reactos + 25/02/99: Added fgetwc + */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int fgetc(FILE *f) +{ + return getc(f); +} + +wint_t fgetwc(FILE *f) +{ + return getwc(f); +} diff --git a/reactos/lib/msvcrt/stdio/fgetchar.c b/reactos/lib/msvcrt/stdio/fgetchar.c new file mode 100644 index 00000000000..2b130a2b944 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fgetchar.c @@ -0,0 +1,12 @@ +#include +#include + +int _fgetchar(void) +{ + return _getch(); +} + +int _fgetwchar(void) +{ + return _getch(); +} \ No newline at end of file diff --git a/reactos/lib/msvcrt/stdio/fgetpos.c b/reactos/lib/msvcrt/stdio/fgetpos.c new file mode 100644 index 00000000000..82c4bf5f2e0 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fgetpos.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int fgetpos(FILE *stream, fpos_t *pos) +{ + if (stream && pos) + { + *pos = (fpos_t)ftell(stream); + return 0; + } + //errno = EFAULT; + return 1; +} diff --git a/reactos/lib/msvcrt/stdio/fopen.c b/reactos/lib/msvcrt/stdio/fopen.c index 7b584f35171..def102f2a7a 100644 --- a/reactos/lib/msvcrt/stdio/fopen.c +++ b/reactos/lib/msvcrt/stdio/fopen.c @@ -78,3 +78,68 @@ FILE* fopen(const char *file, const char *mode) f->_base = f->_ptr = NULL; return f; } + +FILE* _wfopen(const wchar_t *file, const wchar_t *mode) +{ + FILE *f; + int fd, rw, oflags = 0; + wchar_t tbchar; + + if (file == 0) + return 0; + if (mode == 0) + return 0; + + f = __alloc_file(); + if (f == NULL) + return NULL; + + rw = (mode[1] == L'+') || (mode[1] && (mode[2] == L'+')); + + switch (*mode) + { + case L'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case L'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case L'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return (NULL); + } + if (mode[1] == L'+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == L't') + oflags |= O_TEXT; + else if (tbchar == L'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); + + fd = _wopen(file, oflags, 0); + if (fd < 0) + return NULL; + +// ms crtdll ensures that writes will end up at the end of file in append mode +// we just move the file pointer to the end of file initially + if (*mode == L'a') + lseek(fd, 0, SEEK_END); + + f->_cnt = 0; + f->_file = fd; + f->_bufsiz = 0; + if (rw) + f->_flag = _IOREAD | _IOWRT; + else if (*mode == L'r') + f->_flag = _IOREAD; + else + f->_flag = _IOWRT; + + f->_base = f->_ptr = NULL; + return f; +} diff --git a/reactos/lib/msvcrt/stdio/fputchar.c b/reactos/lib/msvcrt/stdio/fputchar.c new file mode 100644 index 00000000000..46d4eb5e2e2 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fputchar.c @@ -0,0 +1,14 @@ +#include +#include + + +int _fputchar(int c) +{ + return _putch(c); +} + +int _fputwchar(wchar_t c) +{ + //return _putch(c); + return 0; +} diff --git a/reactos/lib/msvcrt/stdio/freopen.c b/reactos/lib/msvcrt/stdio/freopen.c new file mode 100644 index 00000000000..f6f14fd2b5c --- /dev/null +++ b/reactos/lib/msvcrt/stdio/freopen.c @@ -0,0 +1,122 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include +#include +#include + + +FILE *freopen(const char *file, const char *mode, FILE *f) +{ + int fd, rw, oflags=0; + char tbchar; + + if (file == 0 || mode == 0 || f == 0) + return 0; + + rw = (mode[1] == '+'); + + fclose(f); + + switch (*mode) { + case 'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case 'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case 'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return NULL; + } + if (mode[1] == '+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == 't') + oflags |= O_TEXT; + else if (tbchar == 'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); + + fd = _open(file, oflags, 0666); + if (fd < 0) + return NULL; + + if (*mode == 'a') + lseek(fd, 0, SEEK_END); + + f->_cnt = 0; + f->_file = fd; + f->_bufsiz = 0; + if (rw) + f->_flag = _IOREAD | _IOWRT; + else if (*mode == 'r') + f->_flag = _IOREAD; + else + f->_flag = _IOWRT; + + f->_base = f->_ptr = NULL; + return f; +} + +FILE *_wfreopen(const wchar_t *file, const wchar_t *mode, FILE *f) +{ + int fd, rw, oflags=0; + wchar_t tbchar; + + if (file == 0 || mode == 0 || f == 0) + return 0; + + rw = (mode[1] == L'+'); + + fclose(f); + + switch (*mode) { + case L'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case L'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case L'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return NULL; + } + if (mode[1] == L'+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == L't') + oflags |= O_TEXT; + else if (tbchar == L'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); + + fd = _wopen(file, oflags, 0666); + if (fd < 0) + return NULL; + + if (*mode == L'a') + lseek(fd, 0, SEEK_END); + + f->_cnt = 0; + f->_file = fd; + f->_bufsiz = 0; + if (rw) + f->_flag = _IOREAD | _IOWRT; + else if (*mode == L'r') + f->_flag = _IOREAD; + else + f->_flag = _IOWRT; + + f->_base = f->_ptr = NULL; + return f; +} diff --git a/reactos/lib/msvcrt/stdio/fseek.c b/reactos/lib/msvcrt/stdio/fseek.c new file mode 100644 index 00000000000..0c7707e67f2 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fseek.c @@ -0,0 +1,54 @@ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include +#include +#include + + +int fseek(FILE *f, long offset, int ptrname) +{ + long p = -1; /* can't happen? */ + if ( f == NULL ) { + __set_errno (EINVAL); + return -1; + } + + f->_flag &= ~_IOEOF; + if (!OPEN4WRITING(f)) + { + if (f->_base && !(f->_flag & _IONBF)) + { + p = ftell(f); + if (ptrname == SEEK_CUR) + { + offset += p; + ptrname = SEEK_SET; + } + /* check if the target position is in the buffer and + optimize seek by moving inside the buffer */ + if (ptrname == SEEK_SET && (f->_flag & (_IOUNGETC|_IOREAD|_IOWRT )) == 0 + && p-offset <= f->_ptr-f->_base && offset-p <= f->_cnt) + { + f->_ptr+=offset-p; + f->_cnt+=p-offset; + return 0; + } + } + + p = lseek(fileno(f), offset, ptrname); + f->_cnt = 0; + f->_ptr = f->_base; + f->_flag &= ~_IOUNGETC; + } + else + { + p = fflush(f); + return lseek(fileno(f), offset, ptrname) == -1 || p == EOF ? + -1 : 0; + } + return p==-1 ? -1 : 0; +} diff --git a/reactos/lib/msvcrt/stdio/fsetpos.c b/reactos/lib/msvcrt/stdio/fsetpos.c new file mode 100644 index 00000000000..eb485576700 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fsetpos.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int fsetpos(FILE *stream,const fpos_t *pos) +{ + if (stream && pos) + { + fseek(stream, (long)(*pos), SEEK_SET); + return 0; + } + __set_errno(EFAULT); + return -1; +} diff --git a/reactos/lib/msvcrt/stdio/fsopen.c b/reactos/lib/msvcrt/stdio/fsopen.c new file mode 100644 index 00000000000..0b36507bbc8 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fsopen.c @@ -0,0 +1,177 @@ +/* + * 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 + */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include +#include +#include +#include + + +FILE * __alloc_file(void); + + +FILE* _fsopen(const char *file, const char *mode, int shflag) +{ + FILE *f; + int fd, rw, oflags = 0; + char tbchar; + + int shf; + + if (file == 0) + return 0; + if (mode == 0) + return 0; + + f = __alloc_file(); + if (f == NULL) + return NULL; + + rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+')); + + switch (*mode) + { + case 'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case 'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case 'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return (NULL); + } + if (mode[1] == '+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == 't') + oflags |= O_TEXT; + else if (tbchar == 'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); + + if ( shflag == _SH_DENYNO ) + shf = _S_IREAD | _S_IWRITE; + else if( shflag == _SH_DENYRD ) + shf = _S_IWRITE; + else if( shflag == _SH_DENYRW ) + shf = 0; + else if( shflag == _SH_DENYWR ) + shf = _S_IREAD; + else + shf = _S_IREAD | _S_IWRITE; + + fd = _open(file, oflags, shf); + if (fd < 0) + return NULL; + +// ms crtdll ensures that writes will end up at the end of file in append mode +// we just move the file pointer to the end of file initially + if (*mode == 'a') + lseek(fd, 0, SEEK_END); + + f->_cnt = 0; + f->_file = fd; + f->_bufsiz = 0; + if (rw) + f->_flag = _IOREAD | _IOWRT; + else if (*mode == 'r') + f->_flag = _IOREAD; + else + f->_flag = _IOWRT; + + f->_base = f->_ptr = NULL; + return f; +} + +FILE* _wfsopen(const wchar_t *file, const wchar_t *mode, int shflag) +{ + FILE *f; + int fd, rw, oflags = 0; + wchar_t tbchar; + + int shf; + + if (file == 0) + return 0; + if (mode == 0) + return 0; + + f = __alloc_file(); + if (f == NULL) + return NULL; + + rw = (mode[1] == L'+') || (mode[1] && (mode[2] == L'+')); + + switch (*mode) + { + case L'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case L'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case L'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return (NULL); + } + if (mode[1] == L'+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == L't') + oflags |= O_TEXT; + else if (tbchar == L'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); + + if ( shflag == _SH_DENYNO ) + shf = _S_IREAD | _S_IWRITE; + else if( shflag == _SH_DENYRD ) + shf = _S_IWRITE; + else if( shflag == _SH_DENYRW ) + shf = 0; + else if( shflag == _SH_DENYWR ) + shf = _S_IREAD; + else + shf = _S_IREAD | _S_IWRITE; + + fd = _wopen(file, oflags, shf); + if (fd < 0) + return NULL; + +// ms crtdll ensures that writes will end up at the end of file in append mode +// we just move the file pointer to the end of file initially + if (*mode == L'a') + lseek(fd, 0, SEEK_END); + + f->_cnt = 0; + f->_file = fd; + f->_bufsiz = 0; + if (rw) + f->_flag = _IOREAD | _IOWRT; + else if (*mode == L'r') + f->_flag = _IOREAD; + else + f->_flag = _IOWRT; + + f->_base = f->_ptr = NULL; + return f; +} diff --git a/reactos/lib/msvcrt/stdio/ftell.c b/reactos/lib/msvcrt/stdio/ftell.c new file mode 100644 index 00000000000..390fa4d4cf9 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/ftell.c @@ -0,0 +1,46 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include +//#include +#include +#include +#include +#include + + +long ftell(FILE *f) +{ + long tres; + int adjust=0; + + if (!f) + { + __set_errno(EBADF); + return -1; + } + + if (f->_cnt < 0) + f->_cnt = 0; + else if (f->_flag&_IOREAD) + { + adjust = - f->_cnt; + } + else if (f->_flag&(_IOWRT)) + { + if (f->_base && (f->_flag&_IONBF)==0) + adjust = f->_ptr - f->_base; + } + else + return -1; + + tres = lseek(fileno(f), 0L, SEEK_CUR); + if (tres<0) + return tres; + tres += adjust; + + //f->_cnt = f->_bufsiz - tres; + //f->_ptr = f->_base + tres; + + return tres; +} diff --git a/reactos/lib/msvcrt/stdio/getchar.c b/reactos/lib/msvcrt/stdio/getchar.c new file mode 100644 index 00000000000..14392d2cb81 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/getchar.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#undef getchar +int +getchar(void) +{ + return getc(stdin); +} diff --git a/reactos/lib/msvcrt/stdio/gets.c b/reactos/lib/msvcrt/stdio/gets.c new file mode 100644 index 00000000000..ac974203fdf --- /dev/null +++ b/reactos/lib/msvcrt/stdio/gets.c @@ -0,0 +1,106 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/crtdll/stdio/gets.c + * PURPOSE: Get a character string from stdin + * PROGRAMER: DJ Delorie + * UPDATE HISTORY: + * 28/12/98: Appropriated for Reactos + */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +char *gets(char *s) +{ + int c; + char *cs; + + cs = s; + while ((c = getchar()) != '\n' && c != EOF) + *cs++ = c; + if (c == EOF && cs==s) + return NULL; + *cs++ = '\0'; + return s; +} + +#if 0 +/* Copyright (C) 1991, 1994, 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 +#include +#include + +link_warning (gets, "the `gets' function is dangerous and should not be used.") + + +/* Read a newline-terminated multibyte string from stdin into S, + removing the trailing newline. Return S or NULL. */ + +char * +gets (s) + char *s; +{ + register char *p = s; + register int c; + FILE *stream = stdin; + int l; + + if (!__validfp (stream) || p == NULL) + { + __set_errno (EINVAL); + return NULL; + } + + if (feof (stream) || ferror (stream)) + return NULL; + + while ((c = getc(stdin)) != EOF) { + if (c == '\n') + break; + if ( isascii(c) ) + *cs++ = c; +#ifdef _MULTIBYTE + else if ( isleadbyte(c) ) { + l = mblen(c); + while(l > 0 ) { + c = getchar(); + if ( isleadbyte(c) || c == EOF ) + return NULL; // encoding error + *cs++ = c; + l--; + } + } +#endif + else + return NULL; // suspicious input + } + + *p = '\0'; + + /* Return null if we had an error, or if we got EOF + before writing any characters. */ + + if (ferror (stream) || (feof (stream) && p == s)) + return NULL; + + return s; +} + +#endif diff --git a/reactos/lib/msvcrt/stdio/getw.c b/reactos/lib/msvcrt/stdio/getw.c new file mode 100644 index 00000000000..119d4e19418 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/getw.c @@ -0,0 +1,30 @@ +/* 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 + +/* Read a word (int) from STREAM. */ +int _getw(FILE *stream) +{ + int w; + + /* Is there a better way? */ + if (fread( &w, sizeof(w), 1, stream) != 1) + return(EOF); + return(w); +} diff --git a/reactos/lib/msvcrt/stdio/perror.c b/reactos/lib/msvcrt/stdio/perror.c new file mode 100644 index 00000000000..7606a1eca3b --- /dev/null +++ b/reactos/lib/msvcrt/stdio/perror.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + + +#ifdef perror +#undef perror +void perror(const char *s); +#endif + +void perror(const char *s) +{ + fprintf(stderr, "%s: %s\n", s, _strerror(NULL)); +} + +void _wperror(const wchar_t *s) +{ + fwprintf(stderr, L"%s: %S\n", s, _strerror(NULL)); +} diff --git a/reactos/lib/msvcrt/stdio/popen.c b/reactos/lib/msvcrt/stdio/popen.c new file mode 100644 index 00000000000..83c1282c723 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/popen.c @@ -0,0 +1,102 @@ + +#include +#include +#include +#include +#include +#include +#include + + +FILE *_popen (const char *cm, const char *md) /* program name, pipe mode */ +{ + FILE *pf; + HANDLE hReadPipe, hWritePipe; + STARTUPINFOA StartupInfo; + PROCESS_INFORMATION ProcessInformation; + + // fixme CreatePipe + +// if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,1024)) +// return NULL; + + StartupInfo.cb = sizeof(STARTUPINFOA); + if ( md == "r" ) { + StartupInfo.hStdOutput = hWritePipe; + } + else if ( md == "w" ) { + StartupInfo.hStdInput = hReadPipe; + } + + if (CreateProcessA("cmd.exe",(char *)cm,NULL,NULL,TRUE, + CREATE_NEW_CONSOLE,NULL,NULL, + &StartupInfo, + &ProcessInformation) == FALSE) + return NULL; + + if ( *md == 'r' ) + { + pf = _fdopen(__fileno_alloc(hReadPipe, _fmode) , "r"); + } + else + { + pf = _fdopen( __fileno_alloc(hWritePipe, _fmode) , "w"); + } + + pf->_name_to_remove = ProcessInformation.hProcess; + + return pf; +} + + +int _pclose (FILE *pp) +{ + fclose(pp); + printf("Terminate Process\n"); +// if (!TerminateProcess(pp->_name_to_remove,0)) +// return -1; + return 0; +} + + +FILE *_wpopen (const wchar_t *cm, const wchar_t *md) /* program name, pipe mode */ +{ + FILE *pf; + HANDLE hReadPipe, hWritePipe; + STARTUPINFOW StartupInfo; + PROCESS_INFORMATION ProcessInformation; + + // fixme CreatePipe + +// if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,1024)) +// return NULL; + + StartupInfo.cb = sizeof(STARTUPINFOW); + if (*md == L'r') + { + StartupInfo.hStdOutput = hWritePipe; + } + else if (*md == L'w') + { + StartupInfo.hStdInput = hReadPipe; + } + + if (CreateProcessW(L"cmd.exe",(wchar_t *)cm,NULL,NULL,TRUE, + CREATE_NEW_CONSOLE,NULL,NULL, + &StartupInfo, + &ProcessInformation) == FALSE) + return NULL; + + if (*md == L'r') + { + pf = _wfdopen(__fileno_alloc(hReadPipe, _fmode) , L"r"); + } + else + { + pf = _wfdopen( __fileno_alloc(hWritePipe, _fmode) , L"w"); + } + + pf->_name_to_remove = ProcessInformation.hProcess; + + return pf; +} diff --git a/reactos/lib/msvcrt/stdio/putw.c b/reactos/lib/msvcrt/stdio/putw.c new file mode 100644 index 00000000000..94951269905 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/putw.c @@ -0,0 +1,30 @@ +/* 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 + + +/* Write the word (int) W to STREAM. */ +int _putw(int w,FILE *stream) +{ + /* Is there a better way? */ + if (fwrite( &w, sizeof(w), 1, stream) < 1) + return(EOF); + return(0); +} diff --git a/reactos/lib/msvcrt/stdio/rename.c b/reactos/lib/msvcrt/stdio/rename.c new file mode 100644 index 00000000000..6139cf70266 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/rename.c @@ -0,0 +1,27 @@ +#include +#include +#include + + +int rename(const char *old_, const char *new_) +{ + if (old_ == NULL || new_ == NULL) + return -1; + + if (!MoveFileA(old_,new_)) + return -1; + + return 0; +} + +int _wrename(const wchar_t *old_, const wchar_t *new_) +{ + if (old_ == NULL || new_ == NULL) + return -1; + + if (!MoveFileW(old_,new_)) + return -1; + + return 0; +} + diff --git a/reactos/lib/msvcrt/stdio/rewind.c b/reactos/lib/msvcrt/stdio/rewind.c new file mode 100644 index 00000000000..013e2fcc38a --- /dev/null +++ b/reactos/lib/msvcrt/stdio/rewind.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include + + +void rewind(FILE *f) +{ + fflush(f); + lseek(fileno(f), 0L, SEEK_SET); + f->_cnt = 0; + f->_ptr = f->_base; + f->_flag &= ~(_IOERR|_IOEOF|_IOAHEAD); +} diff --git a/reactos/lib/msvcrt/stdio/rmtmp.c b/reactos/lib/msvcrt/stdio/rmtmp.c new file mode 100644 index 00000000000..69894475007 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/rmtmp.c @@ -0,0 +1,72 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/crtdll/stdio/rmtmp.c + * PURPOSE: remove temporary files in current directory + * PROGRAMMER: Boudewijn ( ariadne@xs4all.nl) + * UPDATE HISTORY: + * Created 19/01/99 + * NOTE Not tested. + */ + +#include +#include +#include + +#ifndef F_OK + #define F_OK 0x01 +#endif +#ifndef R_OK + #define R_OK 0x02 +#endif +#ifndef W_OK + #define W_OK 0x04 +#endif +#ifndef X_OK + #define X_OK 0x08 +#endif +#ifndef D_OK + #define D_OK 0x10 +#endif + +// should be replace by a closure of the tmp files +extern __file_rec *__file_rec_list; + +int _rmtmp( void ) +{ +/* +loop files and check for name_to_remove +*/ + __file_rec *fr = __file_rec_list; + __file_rec **last_fr = &__file_rec_list; + + int total_closed = 0; + int i = 0; + char temp_name[260]; + + /* Try to find an empty slot */ + while (fr) + { + last_fr = &(fr->next); + + /* If one of the existing slots is available, return it */ + for (i=0; icount; i++) { + if (fr->files[i]->_name_to_remove != NULL) { + if ( _access(fr->files[i]->_name_to_remove,W_OK) ) { + strcpy(temp_name,fr->files[i]->_name_to_remove); + fclose(fr->files[i]); + remove(temp_name); + total_closed++; + } + } + } + + /* If this one is full, go to the next */ + if (fr->count == __FILE_REC_MAX) + fr = fr->next; + else + /* it isn't full, we can add to it */ + break; + } + return total_closed; +} diff --git a/reactos/lib/msvcrt/stdio/setbuf.c b/reactos/lib/msvcrt/stdio/setbuf.c new file mode 100644 index 00000000000..a112ae3dfeb --- /dev/null +++ b/reactos/lib/msvcrt/stdio/setbuf.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +void setbuf(FILE *f, char *buf) +{ + if (buf) + setvbuf(f, buf, _IOFBF, BUFSIZ); + else + setvbuf(f, 0, _IONBF, BUFSIZ); +} diff --git a/reactos/lib/msvcrt/stdio/tempnam.c b/reactos/lib/msvcrt/stdio/tempnam.c index 2cee3f2bd9e..f3582247a5f 100644 --- a/reactos/lib/msvcrt/stdio/tempnam.c +++ b/reactos/lib/msvcrt/stdio/tempnam.c @@ -5,17 +5,38 @@ char *_tempnam(const char *dir,const char *prefix ) { - char *TempFileName = malloc(MAX_PATH); - char *d; - if ( dir == NULL ) - d = getenv("TMP"); - else - d = (char *)dir; + char *TempFileName = malloc(MAX_PATH); + char *d; - if ( GetTempFileNameA(d, prefix, 0, TempFileName ) == 0 ) { - free(TempFileName); - return NULL; - } + if (dir == NULL) + d = getenv("TMP"); + else + d = (char *)dir; - return TempFileName; + if (GetTempFileNameA(d, prefix, 0, TempFileName) == 0) + { + free(TempFileName); + return NULL; + } + + return TempFileName; +} + +wchar_t *_wtempnam(const wchar_t *dir,const wchar_t *prefix) +{ + wchar_t *TempFileName = malloc(MAX_PATH); + wchar_t *d; + + if (dir == NULL) + d = _wgetenv(L"TMP"); + else + d = (wchar_t *)dir; + + if (GetTempFileNameW(d, prefix, 0, TempFileName) == 0) + { + free(TempFileName); + return NULL; + } + + return TempFileName; } diff --git a/reactos/lib/msvcrt/stdio/tmpfile.c b/reactos/lib/msvcrt/stdio/tmpfile.c new file mode 100644 index 00000000000..1e1c116e1ed --- /dev/null +++ b/reactos/lib/msvcrt/stdio/tmpfile.c @@ -0,0 +1,67 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include +#include +#include +//#include +#include +#include +#include + + +FILE * __alloc_file(void); + +FILE * +tmpfile(void) +{ + int temp_fd; + FILE *f; + char *temp_name = tmpnam(0); + char *n_t_r = (char *)malloc(L_tmpnam); + + if (!n_t_r) + return 0; + + /* We could have a race condition, whereby another program + (in another virtual machine, or if the temporary file is + in a directory which is shared via a network) opens the + file returned by `tmpnam' between the call above and the + moment when we actually open the file below. This loop + retries the call to `tmpnam' until we actually succeed + to create the file which didn't exist before. */ + do { + // errno = 0; + temp_fd = _open(temp_name, 0, SH_DENYRW); + // if ( errno == ENOENT ) +// break; + } while (temp_fd == -1 && (temp_name = tmpnam(0)) != 0); + + if (temp_name == 0) + return 0; + + /* This should have been fdopen(temp_fd, "wb+"), but `fdopen' + is non-ANSI. So we need to dump some of its guts here. Sigh... */ + f = __alloc_file(); + if (f) + { + f->_file = temp_fd; + f->_cnt = 0; + f->_bufsiz = 0; + f->_flag = _IORMONCL | _IOREAD | _IOWRT; + f->_name_to_remove = n_t_r; + strcpy(f->_name_to_remove, temp_name); + f->_base = f->_ptr = NULL; + } + else + { + close(temp_fd); + remove(temp_name); + free(n_t_r); + } + return f; +} diff --git a/reactos/lib/msvcrt/stdio/tmpnam.c b/reactos/lib/msvcrt/stdio/tmpnam.c new file mode 100644 index 00000000000..cd16118dce4 --- /dev/null +++ b/reactos/lib/msvcrt/stdio/tmpnam.c @@ -0,0 +1,28 @@ +#include +#include +#include + + +char *tmpnam(char *s) +{ + char PathName[MAX_PATH]; + static char static_buf[MAX_PATH]; + + GetTempPathA(MAX_PATH, PathName); + GetTempFileNameA(PathName, "ARI", 007, static_buf); + strcpy(s, static_buf); + + return s; +} + +wchar_t *_wtmpnam(wchar_t *s) +{ + wchar_t PathName[MAX_PATH]; + static wchar_t static_buf[MAX_PATH]; + + GetTempPathW(MAX_PATH, PathName); + GetTempFileNameW(PathName, L"ARI", 007, static_buf); + wcscpy(s, static_buf); + + return s; +}