From 55fb40a502b35274c46bd1ab5f23d95d6945a204 Mon Sep 17 00:00:00 2001 From: Gunnar Dalsnes Date: Wed, 16 Feb 2005 22:29:48 +0000 Subject: [PATCH] ntdll: -critical.c: catch (more) invalid use -impl. sscanf (stolen from wine) crt: -use native mingw headers and not private copies of them -converted some routines to using tchar == impl. many missing unicode routines -impl. sscanf and friends correctly (stolen from wine) tchar.h: -added lotsa missin stuff svn path=/trunk/; revision=13608 --- reactos/lib/crt/conio/cgets.c | 4 +- reactos/lib/crt/conio/cprintf.c | 5 +- reactos/lib/crt/conio/cputs.c | 10 +- reactos/lib/crt/conio/cscanf.c | 29 - reactos/lib/crt/conio/getch.c | 10 +- reactos/lib/crt/conio/getche.c | 10 +- reactos/lib/crt/conio/kbhit.c | 4 +- reactos/lib/crt/conio/putch.c | 2 +- reactos/lib/crt/conio/ungetch.c | 4 +- reactos/lib/crt/ctype/ctype.c | 2 +- reactos/lib/crt/ctype/isalnum.c | 2 +- reactos/lib/crt/ctype/isalpha.c | 2 +- reactos/lib/crt/ctype/isascii.c | 2 +- reactos/lib/crt/ctype/iscntrl.c | 2 +- reactos/lib/crt/ctype/iscsym.c | 2 +- reactos/lib/crt/ctype/isctype.c | 4 +- reactos/lib/crt/ctype/isdigit.c | 2 +- reactos/lib/crt/ctype/isgraph.c | 2 +- reactos/lib/crt/ctype/islower.c | 2 +- reactos/lib/crt/ctype/isprint.c | 2 +- reactos/lib/crt/ctype/ispunct.c | 2 +- reactos/lib/crt/ctype/isspace.c | 2 +- reactos/lib/crt/ctype/isupper.c | 2 +- reactos/lib/crt/ctype/isxdigit.c | 2 +- reactos/lib/crt/ctype/toascii.c | 2 +- reactos/lib/crt/ctype/tolower.c | 2 +- reactos/lib/crt/ctype/toupper.c | 2 +- reactos/lib/crt/direct/chdir.c | 6 +- reactos/lib/crt/direct/chdrive.c | 10 +- reactos/lib/crt/direct/getcwd.c | 8 +- reactos/lib/crt/direct/getdcwd.c | 4 +- reactos/lib/crt/direct/getdfree.c | 4 +- reactos/lib/crt/direct/getdrive.c | 4 +- reactos/lib/crt/direct/mkdir.c | 4 +- reactos/lib/crt/direct/rmdir.c | 4 +- reactos/lib/crt/direct/wchdir.c | 7 +- reactos/lib/crt/direct/wgetcwd.c | 8 +- reactos/lib/crt/direct/wgetdcwd.c | 4 +- reactos/lib/crt/direct/wmkdir.c | 4 +- reactos/lib/crt/direct/wrmdir.c | 4 +- reactos/lib/crt/float/chgsign.c | 4 +- reactos/lib/crt/float/clearfp.c | 2 +- reactos/lib/crt/float/cntrlfp.c | 2 +- reactos/lib/crt/float/copysign.c | 4 +- reactos/lib/crt/float/fpclass.c | 6 +- reactos/lib/crt/float/fpecode.c | 4 +- reactos/lib/crt/float/fpreset.c | 2 +- reactos/lib/crt/float/isnan.c | 6 +- reactos/lib/crt/float/logb.c | 2 +- reactos/lib/crt/float/nafter.c | 4 +- reactos/lib/crt/float/scalb.c | 4 +- reactos/lib/crt/float/statfp.c | 2 +- reactos/lib/crt/io/access.c | 53 +- reactos/lib/crt/io/chmod.c | 18 +- reactos/lib/crt/io/chsize.c | 6 +- reactos/lib/crt/io/close.c | 21 +- reactos/lib/crt/io/commit.c | 8 +- reactos/lib/crt/io/create.c | 6 +- reactos/lib/crt/io/dup.c | 10 +- reactos/lib/crt/io/dup2.c | 4 +- reactos/lib/crt/io/eof.c | 3 +- reactos/lib/crt/io/filelen.c | 6 +- reactos/lib/crt/io/fileleni.c | 6 +- reactos/lib/crt/io/find.c | 248 ++++-- reactos/lib/crt/io/fmode.c | 8 +- reactos/lib/crt/io/isatty.c | 8 +- reactos/lib/crt/io/locking.c | 6 +- reactos/lib/crt/io/lseek.c | 6 +- reactos/lib/crt/io/lseeki64.c | 8 +- reactos/lib/crt/io/mktemp.c | 8 +- reactos/lib/crt/io/open.c | 704 ++++++++++----- reactos/lib/crt/io/pipe.c | 25 +- reactos/lib/crt/io/read.c | 10 +- reactos/lib/crt/io/setmode.c | 16 +- reactos/lib/crt/io/sopen.c | 7 +- reactos/lib/crt/io/tell.c | 5 +- reactos/lib/crt/io/telli64.c | 5 +- reactos/lib/crt/io/umask.c | 2 +- reactos/lib/crt/io/unlink.c | 5 +- reactos/lib/crt/io/utime.c | 10 +- reactos/lib/crt/io/waccess.c | 34 +- reactos/lib/crt/io/wchmod.c | 49 +- reactos/lib/crt/io/wcreate.c | 6 +- reactos/lib/crt/io/wfind.c | 227 +---- reactos/lib/crt/io/wmktemp.c | 8 +- reactos/lib/crt/io/wopen.c | 27 +- reactos/lib/crt/io/write.c | 20 +- reactos/lib/crt/io/wunlink.c | 6 +- reactos/lib/crt/io/wutime.c | 10 +- reactos/lib/crt/locale/locale.c | 12 +- reactos/lib/crt/makefile | 28 +- reactos/lib/crt/math/acos.c | 2 +- reactos/lib/crt/math/asin.c | 2 +- reactos/lib/crt/math/atan.c | 2 +- reactos/lib/crt/math/atan2.c | 2 +- reactos/lib/crt/math/cabs.c | 2 +- reactos/lib/crt/math/ceil.c | 2 +- reactos/lib/crt/math/cos.c | 2 +- reactos/lib/crt/math/cosh.c | 2 +- reactos/lib/crt/math/exp.c | 2 +- reactos/lib/crt/math/fabs.c | 2 +- reactos/lib/crt/math/floor.c | 2 +- reactos/lib/crt/math/fmod.c | 2 +- reactos/lib/crt/math/frexp.c | 6 +- reactos/lib/crt/math/huge_val.c | 2 +- reactos/lib/crt/math/hypot.c | 6 +- reactos/lib/crt/math/j0_y0.c | 2 +- reactos/lib/crt/math/j1_y1.c | 2 +- reactos/lib/crt/math/jn_yn.c | 2 +- reactos/lib/crt/math/ldexp.c | 2 +- reactos/lib/crt/math/log.c | 2 +- reactos/lib/crt/math/log10.c | 2 +- reactos/lib/crt/math/math.c | 2 +- reactos/lib/crt/math/modf.c | 8 +- reactos/lib/crt/math/pow.c | 2 +- reactos/lib/crt/math/sin.c | 2 +- reactos/lib/crt/math/sinh.c | 2 +- reactos/lib/crt/math/sqrt.c | 2 +- reactos/lib/crt/math/stubs.c | 2 +- reactos/lib/crt/math/tan.c | 2 +- reactos/lib/crt/math/tanh.c | 2 +- reactos/lib/crt/mbstring/hanzen.c | 2 +- reactos/lib/crt/mbstring/ischira.c | 4 +- reactos/lib/crt/mbstring/iskana.c | 9 +- reactos/lib/crt/mbstring/iskmoji.c | 2 +- reactos/lib/crt/mbstring/iskpun.c | 6 +- reactos/lib/crt/mbstring/islead.c | 2 +- reactos/lib/crt/mbstring/islwr.c | 4 +- reactos/lib/crt/mbstring/ismbal.c | 6 +- reactos/lib/crt/mbstring/ismbaln.c | 6 +- reactos/lib/crt/mbstring/ismbc.c | 2 +- reactos/lib/crt/mbstring/ismbgra.c | 8 +- reactos/lib/crt/mbstring/ismbkaln.c | 8 +- reactos/lib/crt/mbstring/ismblead.c | 13 +- reactos/lib/crt/mbstring/ismbpri.c | 8 +- reactos/lib/crt/mbstring/ismbpun.c | 8 +- reactos/lib/crt/mbstring/ismbtrl.c | 7 +- reactos/lib/crt/mbstring/isuppr.c | 4 +- reactos/lib/crt/mbstring/jistojms.c | 4 +- reactos/lib/crt/mbstring/jmstojis.c | 4 +- reactos/lib/crt/mbstring/mbbtype.c | 5 +- reactos/lib/crt/mbstring/mbccpy.c | 4 +- reactos/lib/crt/mbstring/mbclen.c | 4 +- reactos/lib/crt/mbstring/mbscat.c | 2 +- reactos/lib/crt/mbstring/mbschr.c | 2 +- reactos/lib/crt/mbstring/mbscmp.c | 4 +- reactos/lib/crt/mbstring/mbscoll.c | 2 +- reactos/lib/crt/mbstring/mbscpy.c | 4 +- reactos/lib/crt/mbstring/mbscspn.c | 2 +- reactos/lib/crt/mbstring/mbsdec.c | 3 +- reactos/lib/crt/mbstring/mbsdup.c | 4 +- reactos/lib/crt/mbstring/mbsicmp.c | 6 +- reactos/lib/crt/mbstring/mbsicoll.c | 6 +- reactos/lib/crt/mbstring/mbsinc.c | 2 +- reactos/lib/crt/mbstring/mbslen.c | 2 +- reactos/lib/crt/mbstring/mbslwr.c | 4 +- reactos/lib/crt/mbstring/mbsncat.c | 4 +- reactos/lib/crt/mbstring/mbsnccnt.c | 2 +- reactos/lib/crt/mbstring/mbsncmp.c | 2 +- reactos/lib/crt/mbstring/mbsncoll.c | 2 +- reactos/lib/crt/mbstring/mbsncpy.c | 2 +- reactos/lib/crt/mbstring/mbsnextc.c | 3 +- reactos/lib/crt/mbstring/mbsnicmp.c | 2 +- reactos/lib/crt/mbstring/mbsnicoll.c | 2 +- reactos/lib/crt/mbstring/mbsninc.c | 2 +- reactos/lib/crt/mbstring/mbsnset.c | 2 +- reactos/lib/crt/mbstring/mbspbrk.c | 3 +- reactos/lib/crt/mbstring/mbsrchr.c | 4 +- reactos/lib/crt/mbstring/mbsrev.c | 2 +- reactos/lib/crt/mbstring/mbsset.c | 2 +- reactos/lib/crt/mbstring/mbsspn.c | 2 +- reactos/lib/crt/mbstring/mbsspnp.c | 2 +- reactos/lib/crt/mbstring/mbsstr.c | 4 +- reactos/lib/crt/mbstring/mbstok.c | 5 +- reactos/lib/crt/mbstring/mbstrlen.c | 4 +- reactos/lib/crt/mbstring/mbsupr.c | 4 +- reactos/lib/crt/misc/amsg.c | 4 +- reactos/lib/crt/misc/assert.c | 8 +- reactos/lib/crt/misc/crtmain.c | 2 +- reactos/lib/crt/misc/environ.c | 9 +- reactos/lib/crt/misc/getargs.c | 13 +- reactos/lib/crt/misc/initterm.c | 2 +- reactos/lib/crt/misc/lock.c | 4 +- reactos/lib/crt/misc/purecall.c | 2 +- reactos/lib/crt/misc/stubs.c | 33 +- reactos/lib/crt/misc/tls.c | 6 +- reactos/lib/crt/process/_cwait.c | 6 +- reactos/lib/crt/process/_system.c | 10 +- reactos/lib/crt/process/dll.c | 2 +- reactos/lib/crt/process/process.c | 944 ++++++++++---------- reactos/lib/crt/process/procid.c | 2 +- reactos/lib/crt/process/thread.c | 6 +- reactos/lib/crt/process/threadid.c | 2 +- reactos/lib/crt/process/threadx.c | 6 +- reactos/lib/crt/process/wprocess.c | 4 + reactos/lib/crt/search/lfind.c | 4 +- reactos/lib/crt/search/lsearch.c | 6 +- reactos/lib/crt/signal/signal.c | 191 ++-- reactos/lib/crt/signal/xcptinfo.c | 2 +- reactos/lib/crt/stdio/allocfil.c | 9 +- reactos/lib/crt/stdio/clearerr.c | 7 +- reactos/lib/crt/stdio/fclose.c | 26 +- reactos/lib/crt/stdio/fdopen.c | 25 +- reactos/lib/crt/stdio/feof.c | 6 +- reactos/lib/crt/stdio/ferror.c | 4 +- reactos/lib/crt/stdio/fflush.c | 21 +- reactos/lib/crt/stdio/fgetc.c | 4 +- reactos/lib/crt/stdio/fgetchar.c | 4 +- reactos/lib/crt/stdio/fgetpos.c | 4 +- reactos/lib/crt/stdio/fgets.c | 4 +- reactos/lib/crt/stdio/fgetws.c | 4 +- reactos/lib/crt/stdio/filbuf.c | 20 +- reactos/lib/crt/stdio/fileno.c | 11 +- reactos/lib/crt/stdio/flsbuf.c | 23 +- reactos/lib/crt/stdio/fopen.c | 25 +- reactos/lib/crt/stdio/fprintf.c | 6 +- reactos/lib/crt/stdio/fputc.c | 6 +- reactos/lib/crt/stdio/fputchar.c | 4 +- reactos/lib/crt/stdio/fputs.c | 49 +- reactos/lib/crt/stdio/fputws.c | 5 + reactos/lib/crt/stdio/fread.c | 12 +- reactos/lib/crt/stdio/freopen.c | 80 +- reactos/lib/crt/stdio/fscanf.c | 65 -- reactos/lib/crt/stdio/fseek.c | 14 +- reactos/lib/crt/stdio/fsetpos.c | 6 +- reactos/lib/crt/stdio/fsopen.c | 105 +-- reactos/lib/crt/stdio/ftell.c | 12 +- reactos/lib/crt/stdio/fwalk.c | 4 +- reactos/lib/crt/stdio/fwrite.c | 34 +- reactos/lib/crt/stdio/getc.c | 8 +- reactos/lib/crt/stdio/getchar.c | 4 +- reactos/lib/crt/stdio/gets.c | 2 +- reactos/lib/crt/stdio/getw.c | 2 +- reactos/lib/crt/stdio/perror.c | 6 +- reactos/lib/crt/stdio/popen.c | 170 +--- reactos/lib/crt/stdio/printf.c | 26 +- reactos/lib/crt/stdio/putc.c | 10 +- reactos/lib/crt/stdio/putchar.c | 18 +- reactos/lib/crt/stdio/puts.c | 6 +- reactos/lib/crt/stdio/putw.c | 2 +- reactos/lib/crt/stdio/putwchar.c | 4 + reactos/lib/crt/stdio/remove.c | 23 +- reactos/lib/crt/stdio/rename.c | 10 +- reactos/lib/crt/stdio/rewind.c | 8 +- reactos/lib/crt/stdio/rmtmp.c | 29 +- reactos/lib/crt/stdio/scanf.c | 64 -- reactos/lib/crt/stdio/setbuf.c | 6 +- reactos/lib/crt/stdio/setvbuf.c | 10 +- reactos/lib/crt/stdio/sprintf.c | 48 +- reactos/lib/crt/stdio/sscanf.c | 71 -- reactos/lib/crt/stdio/stdhnd.c | 18 +- reactos/lib/crt/stdio/swprintf.c | 4 + reactos/lib/crt/stdio/tempnam.c | 20 +- reactos/lib/crt/stdio/tmpfile.c | 22 +- reactos/lib/crt/stdio/tmpnam.c | 18 +- reactos/lib/crt/stdio/ungetc.c | 71 +- reactos/lib/crt/stdio/ungetwc.c | 4 + reactos/lib/crt/stdio/vfprintf.c | 32 +- reactos/lib/crt/stdio/vfscanf.c | 1229 -------------------------- reactos/lib/crt/stdio/vfwprint.c | 28 +- reactos/lib/crt/stdio/vprintf.c | 40 +- reactos/lib/crt/stdio/vscanf.c | 34 - reactos/lib/crt/stdio/vsprintf.c | 62 +- reactos/lib/crt/stdio/vsscanf.c | 50 -- reactos/lib/crt/stdio/vswprintf.c | 4 + reactos/lib/crt/stdio/vwprintf.c | 5 + reactos/lib/crt/stdio/wfdopen.c | 56 +- reactos/lib/crt/stdio/wfreopen.c | 6 + reactos/lib/crt/stdio/wfsopen.c | 5 + reactos/lib/crt/stdio/wpopen.c | 5 + reactos/lib/crt/stdio/wprintf.c | 5 + reactos/lib/crt/stdio/wremove.c | 4 + reactos/lib/crt/stdio/wrename.c | 18 +- reactos/lib/crt/stdio/wtempnam.c | 25 +- reactos/lib/crt/stdio/wtmpnam.c | 20 +- reactos/lib/crt/stdlib/_exit.c | 8 +- reactos/lib/crt/stdlib/abort.c | 10 +- reactos/lib/crt/stdlib/abs.c | 3 +- reactos/lib/crt/stdlib/atexit.c | 4 +- reactos/lib/crt/stdlib/atof.c | 2 +- reactos/lib/crt/stdlib/atoi.c | 7 +- reactos/lib/crt/stdlib/atoi64.c | 4 +- reactos/lib/crt/stdlib/atol.c | 7 +- reactos/lib/crt/stdlib/atold.c | 2 +- reactos/lib/crt/stdlib/bsearch.c | 2 +- reactos/lib/crt/stdlib/div.c | 2 +- reactos/lib/crt/stdlib/ecvt.c | 4 +- reactos/lib/crt/stdlib/ecvtbuf.c | 12 +- reactos/lib/crt/stdlib/errno.c | 6 +- reactos/lib/crt/stdlib/fcvt.c | 4 +- reactos/lib/crt/stdlib/fcvtbuf.c | 12 +- reactos/lib/crt/stdlib/fullpath.c | 9 +- reactos/lib/crt/stdlib/gcvt.c | 6 +- reactos/lib/crt/stdlib/getenv.c | 4 +- reactos/lib/crt/stdlib/itoa.c | 6 +- reactos/lib/crt/stdlib/itow.c | 6 +- reactos/lib/crt/stdlib/labs.c | 3 +- reactos/lib/crt/stdlib/ldiv.c | 2 +- reactos/lib/crt/stdlib/makepath.c | 4 +- reactos/lib/crt/stdlib/malloc.c | 4 +- reactos/lib/crt/stdlib/mbstowcs.c | 6 +- reactos/lib/crt/stdlib/mbtowc.c | 4 +- reactos/lib/crt/stdlib/obsol.c | 2 +- reactos/lib/crt/stdlib/putenv.c | 6 +- reactos/lib/crt/stdlib/qsort.c | 7 +- reactos/lib/crt/stdlib/rand.c | 4 +- reactos/lib/crt/stdlib/rot.c | 3 +- reactos/lib/crt/stdlib/senv.c | 27 +- reactos/lib/crt/stdlib/splitp.c | 33 +- reactos/lib/crt/stdlib/strtod.c | 2 +- reactos/lib/crt/stdlib/strtol.c | 8 +- reactos/lib/crt/stdlib/strtold.c | 2 +- reactos/lib/crt/stdlib/strtoll.c | 84 -- reactos/lib/crt/stdlib/strtoul.c | 8 +- reactos/lib/crt/stdlib/strtoull.c | 6 +- reactos/lib/crt/stdlib/swab.c | 2 +- reactos/lib/crt/stdlib/wcstod.c | 2 +- reactos/lib/crt/stdlib/wcstol.c | 4 +- reactos/lib/crt/stdlib/wcstom.c | 2 +- reactos/lib/crt/stdlib/wcstomb.c | 10 +- reactos/lib/crt/stdlib/wcstombs.c | 9 +- reactos/lib/crt/stdlib/wcstoul.c | 8 +- reactos/lib/crt/stdlib/wctomb.c | 10 +- reactos/lib/crt/stdlib/wfulpath.c | 27 +- reactos/lib/crt/stdlib/witoa.c | 6 +- reactos/lib/crt/stdlib/witow.c | 6 +- reactos/lib/crt/stdlib/wmakpath.c | 4 +- reactos/lib/crt/stdlib/wputenv.c | 6 +- reactos/lib/crt/stdlib/wsenv.c | 36 +- reactos/lib/crt/stdlib/wsplitp.c | 70 +- reactos/lib/crt/stdlib/wtoi.c | 19 +- reactos/lib/crt/stdlib/wtoi64.c | 4 +- reactos/lib/crt/stdlib/wtol.c | 6 + reactos/lib/crt/string/lasttok.c | 4 +- reactos/lib/crt/string/memicmp.c | 4 +- reactos/lib/crt/string/strcoll.c | 2 +- reactos/lib/crt/string/strdup.c | 4 +- reactos/lib/crt/string/strerror.c | 14 +- reactos/lib/crt/string/stricmp.c | 4 +- reactos/lib/crt/string/strlwr.c | 4 +- reactos/lib/crt/string/strncoll.c | 2 +- reactos/lib/crt/string/strnicmp.c | 4 +- reactos/lib/crt/string/strpbrk.c | 2 +- reactos/lib/crt/string/strrev.c | 2 +- reactos/lib/crt/string/strset.c | 6 +- reactos/lib/crt/string/strstr.c | 2 +- reactos/lib/crt/string/strtok.c | 4 +- reactos/lib/crt/string/strupr.c | 4 +- reactos/lib/crt/string/strxfrm.c | 2 +- reactos/lib/crt/sys_stat/fstat.c | 16 +- reactos/lib/crt/sys_stat/fstati64.c | 16 +- reactos/lib/crt/sys_stat/futime.c | 18 +- reactos/lib/crt/sys_stat/stat.c | 18 +- reactos/lib/crt/sys_stat/systime.c | 2 +- reactos/lib/crt/sys_stat/wstat.c | 18 +- reactos/lib/crt/time/clock.c | 4 +- reactos/lib/crt/time/ctime.c | 29 +- reactos/lib/crt/time/difftime.c | 2 +- reactos/lib/crt/time/ftime.c | 8 +- reactos/lib/crt/time/strdate.c | 10 +- reactos/lib/crt/time/strftime.c | 11 +- reactos/lib/crt/time/strtime.c | 8 +- reactos/lib/crt/time/time.c | 4 +- reactos/lib/crt/time/tz_vars.c | 20 +- reactos/lib/crt/time/wctime.c | 5 +- reactos/lib/crt/time/wstrdate.c | 10 +- reactos/lib/crt/time/wstrtime.c | 8 +- reactos/lib/crt/wine/cpp.c | 10 +- reactos/lib/crt/wine/cppexcept.c | 4 +- reactos/lib/crt/wine/heap.c | 8 +- reactos/lib/crt/wine/scanf.c | 222 +++++ reactos/lib/crt/wine/scanf.h | 537 +++++++++++ reactos/lib/crt/wine/thread.c | 6 +- reactos/lib/crt/wstring/wcscoll.c | 2 +- reactos/lib/crt/wstring/wcscspn.c | 2 +- reactos/lib/crt/wstring/wcsdup.c | 8 +- reactos/lib/crt/wstring/wcsicmp.c | 4 +- reactos/lib/crt/wstring/wcslwr.c | 2 +- reactos/lib/crt/wstring/wcsnicmp.c | 2 +- reactos/lib/crt/wstring/wcspbrk.c | 2 +- reactos/lib/crt/wstring/wcsrev.c | 2 +- reactos/lib/crt/wstring/wcsset.c | 2 +- reactos/lib/crt/wstring/wcsspn.c | 2 +- reactos/lib/crt/wstring/wcsstr.c | 2 +- reactos/lib/crt/wstring/wcstok.c | 4 +- reactos/lib/crt/wstring/wcsupr.c | 4 +- reactos/lib/crt/wstring/wcsxfrm.c | 2 +- reactos/lib/crt/wstring/wlasttok.c | 4 +- 388 files changed, 3422 insertions(+), 4595 deletions(-) delete mode 100644 reactos/lib/crt/conio/cscanf.c create mode 100644 reactos/lib/crt/process/wprocess.c create mode 100644 reactos/lib/crt/stdio/fputws.c delete mode 100644 reactos/lib/crt/stdio/fscanf.c create mode 100644 reactos/lib/crt/stdio/putwchar.c delete mode 100644 reactos/lib/crt/stdio/scanf.c delete mode 100644 reactos/lib/crt/stdio/sscanf.c create mode 100644 reactos/lib/crt/stdio/swprintf.c create mode 100644 reactos/lib/crt/stdio/ungetwc.c delete mode 100644 reactos/lib/crt/stdio/vfscanf.c delete mode 100644 reactos/lib/crt/stdio/vscanf.c delete mode 100644 reactos/lib/crt/stdio/vsscanf.c create mode 100644 reactos/lib/crt/stdio/vswprintf.c create mode 100644 reactos/lib/crt/stdio/vwprintf.c create mode 100644 reactos/lib/crt/stdio/wfreopen.c create mode 100644 reactos/lib/crt/stdio/wfsopen.c create mode 100644 reactos/lib/crt/stdio/wpopen.c create mode 100644 reactos/lib/crt/stdio/wprintf.c create mode 100644 reactos/lib/crt/stdio/wremove.c delete mode 100644 reactos/lib/crt/stdlib/strtoll.c create mode 100644 reactos/lib/crt/stdlib/wtol.c create mode 100644 reactos/lib/crt/wine/scanf.c create mode 100644 reactos/lib/crt/wine/scanf.h diff --git a/reactos/lib/crt/conio/cgets.c b/reactos/lib/crt/conio/cgets.c index dfdb99bf1b0..b4e67166b5a 100644 --- a/reactos/lib/crt/conio/cgets.c +++ b/reactos/lib/crt/conio/cgets.c @@ -6,8 +6,8 @@ * PROGRAMMER: Eric Kohl (Imported from DJGPP) */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/conio/cprintf.c b/reactos/lib/crt/conio/cprintf.c index b8e487edca3..42f527ad0eb 100644 --- a/reactos/lib/crt/conio/cprintf.c +++ b/reactos/lib/crt/conio/cprintf.c @@ -6,8 +6,9 @@ * PROGRAMMER: Eric Kohl (Imported from DJGPP) */ -#include -#include +#include +#include +#include /* * @unimplemented diff --git a/reactos/lib/crt/conio/cputs.c b/reactos/lib/crt/conio/cputs.c index 008afd39781..705afe7c6ad 100644 --- a/reactos/lib/crt/conio/cputs.c +++ b/reactos/lib/crt/conio/cputs.c @@ -9,10 +9,10 @@ */ #include "precomp.h" -#include -#include -#include -#include +#include +#include +#include +#include /* @@ -22,7 +22,7 @@ int _cputs(const char *_str) { int len = strlen(_str); DWORD written = 0; - if (!WriteFile(filehnd(stdout->_file),_str,len,&written,NULL)) + if (!WriteFile( fdinfo(stdout->_file)->hFile ,_str,len,&written,NULL)) return -1; return 0; } diff --git a/reactos/lib/crt/conio/cscanf.c b/reactos/lib/crt/conio/cscanf.c deleted file mode 100644 index f508c18d212..00000000000 --- a/reactos/lib/crt/conio/cscanf.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: msvcrt/conio/cscanf.c - * PURPOSE: C Runtime - * PROGRAMMER: Eric Kohl (Imported from DJGPP) - */ - -#include -#include -#include -#include - -/* - * @unimplemented - */ -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; -} diff --git a/reactos/lib/crt/conio/getch.c b/reactos/lib/crt/conio/getch.c index bcbe825f5c2..d51c4ac0290 100644 --- a/reactos/lib/crt/conio/getch.c +++ b/reactos/lib/crt/conio/getch.c @@ -9,10 +9,10 @@ */ #include "precomp.h" -#include -#include -#include -#include +#include +#include +#include +#include /* @@ -26,7 +26,7 @@ int _getch(void) c = ungot_char; char_avail = 0; } else { - ReadConsoleA(_get_osfhandle(stdin->_file), + ReadConsoleA((HANDLE)_get_osfhandle(stdin->_file), &c, 1, &NumberOfCharsRead, diff --git a/reactos/lib/crt/conio/getche.c b/reactos/lib/crt/conio/getche.c index b9fb42a8094..4f78db94027 100644 --- a/reactos/lib/crt/conio/getche.c +++ b/reactos/lib/crt/conio/getche.c @@ -10,11 +10,11 @@ * 28/12/98: Created */ -#include -#include +#include +#include -int getche(void) +int _getche(void) { if (char_avail) /* @@ -26,6 +26,6 @@ int getche(void) * hasn't been got by a conio function. * We don't echo again. */ - return(getch()); - return (_putch(getch())); + return(_getch()); + return (_putch(_getch())); } diff --git a/reactos/lib/crt/conio/kbhit.c b/reactos/lib/crt/conio/kbhit.c index b61000d3e25..6f0c0add57c 100644 --- a/reactos/lib/crt/conio/kbhit.c +++ b/reactos/lib/crt/conio/kbhit.c @@ -9,8 +9,8 @@ */ #include "precomp.h" -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/conio/putch.c b/reactos/lib/crt/conio/putch.c index dc95ffedb6c..d6a91a609d4 100644 --- a/reactos/lib/crt/conio/putch.c +++ b/reactos/lib/crt/conio/putch.c @@ -9,7 +9,7 @@ */ #include "precomp.h" -#include +#include /* * @implemented diff --git a/reactos/lib/crt/conio/ungetch.c b/reactos/lib/crt/conio/ungetch.c index e767b6efa4f..31829a1ec97 100644 --- a/reactos/lib/crt/conio/ungetch.c +++ b/reactos/lib/crt/conio/ungetch.c @@ -10,8 +10,8 @@ * 28/12/98: Created */ -#include -#include +#include +#include #define EOF -1 diff --git a/reactos/lib/crt/ctype/ctype.c b/reactos/lib/crt/ctype/ctype.c index 3c88c06e704..f98fab7d6c3 100644 --- a/reactos/lib/crt/ctype/ctype.c +++ b/reactos/lib/crt/ctype/ctype.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include unsigned short _ctype[] = { 0, /* , 0xFFFF */ diff --git a/reactos/lib/crt/ctype/isalnum.c b/reactos/lib/crt/ctype/isalnum.c index 4aa76701247..a9a484ea1b6 100644 --- a/reactos/lib/crt/ctype/isalnum.c +++ b/reactos/lib/crt/ctype/isalnum.c @@ -7,7 +7,7 @@ * UPDATE HISTORY: * 28/12/98: Created */ -#include +#include #undef isalnum diff --git a/reactos/lib/crt/ctype/isalpha.c b/reactos/lib/crt/ctype/isalpha.c index 9fc0cb0093f..daa1878964d 100644 --- a/reactos/lib/crt/ctype/isalpha.c +++ b/reactos/lib/crt/ctype/isalpha.c @@ -8,7 +8,7 @@ * 28/12/98: Created */ -#include +#include #undef isalpha diff --git a/reactos/lib/crt/ctype/isascii.c b/reactos/lib/crt/ctype/isascii.c index 742d39dbbc5..9c98a603339 100644 --- a/reactos/lib/crt/ctype/isascii.c +++ b/reactos/lib/crt/ctype/isascii.c @@ -8,7 +8,7 @@ * 28/12/98: Created */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/ctype/iscntrl.c b/reactos/lib/crt/ctype/iscntrl.c index c7e64b861d9..8d128a29c55 100644 --- a/reactos/lib/crt/ctype/iscntrl.c +++ b/reactos/lib/crt/ctype/iscntrl.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef iscntrl /* diff --git a/reactos/lib/crt/ctype/iscsym.c b/reactos/lib/crt/ctype/iscsym.c index 8608062b8e8..bd108b4347e 100644 --- a/reactos/lib/crt/ctype/iscsym.c +++ b/reactos/lib/crt/ctype/iscsym.c @@ -7,7 +7,7 @@ * UPDATE HISTORY: * 28/12/98: Created */ -#include +#include /* diff --git a/reactos/lib/crt/ctype/isctype.c b/reactos/lib/crt/ctype/isctype.c index 7542a609d00..a1a4d3242fe 100644 --- a/reactos/lib/crt/ctype/isctype.c +++ b/reactos/lib/crt/ctype/isctype.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include extern unsigned short _ctype[]; @@ -34,7 +34,7 @@ unsigned short **__p__pwctype(void) /* * @implemented */ -int _isctype(unsigned int c, int ctypeFlags) +int _isctype(int c, int ctypeFlags) { return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags); } diff --git a/reactos/lib/crt/ctype/isdigit.c b/reactos/lib/crt/ctype/isdigit.c index 36783d43587..16219bc876f 100644 --- a/reactos/lib/crt/ctype/isdigit.c +++ b/reactos/lib/crt/ctype/isdigit.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef isdigit diff --git a/reactos/lib/crt/ctype/isgraph.c b/reactos/lib/crt/ctype/isgraph.c index 9b614805a0f..8db6f627ca8 100644 --- a/reactos/lib/crt/ctype/isgraph.c +++ b/reactos/lib/crt/ctype/isgraph.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef isgraph /* diff --git a/reactos/lib/crt/ctype/islower.c b/reactos/lib/crt/ctype/islower.c index c91e5dde091..a804c05f9a9 100644 --- a/reactos/lib/crt/ctype/islower.c +++ b/reactos/lib/crt/ctype/islower.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef islower diff --git a/reactos/lib/crt/ctype/isprint.c b/reactos/lib/crt/ctype/isprint.c index 1f234240254..c98cecbcd52 100644 --- a/reactos/lib/crt/ctype/isprint.c +++ b/reactos/lib/crt/ctype/isprint.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef isprint /* diff --git a/reactos/lib/crt/ctype/ispunct.c b/reactos/lib/crt/ctype/ispunct.c index 51fe12e3693..b0197aa7cf5 100644 --- a/reactos/lib/crt/ctype/ispunct.c +++ b/reactos/lib/crt/ctype/ispunct.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef ispunct /* diff --git a/reactos/lib/crt/ctype/isspace.c b/reactos/lib/crt/ctype/isspace.c index 6f74756b1ed..57e01b2cb2d 100644 --- a/reactos/lib/crt/ctype/isspace.c +++ b/reactos/lib/crt/ctype/isspace.c @@ -8,7 +8,7 @@ * 28/12/98: Created */ -#include +#include #undef isspace diff --git a/reactos/lib/crt/ctype/isupper.c b/reactos/lib/crt/ctype/isupper.c index 6e090255de9..fe19dc4cec9 100644 --- a/reactos/lib/crt/ctype/isupper.c +++ b/reactos/lib/crt/ctype/isupper.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef isupper /* diff --git a/reactos/lib/crt/ctype/isxdigit.c b/reactos/lib/crt/ctype/isxdigit.c index 3490c07924f..04be96ec81a 100644 --- a/reactos/lib/crt/ctype/isxdigit.c +++ b/reactos/lib/crt/ctype/isxdigit.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef isxdigit /* diff --git a/reactos/lib/crt/ctype/toascii.c b/reactos/lib/crt/ctype/toascii.c index 8ad09e23c83..81e3c02e8df 100644 --- a/reactos/lib/crt/ctype/toascii.c +++ b/reactos/lib/crt/ctype/toascii.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/ctype/tolower.c b/reactos/lib/crt/ctype/tolower.c index 48c8788020f..324d0f16eab 100644 --- a/reactos/lib/crt/ctype/tolower.c +++ b/reactos/lib/crt/ctype/tolower.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef tolower /* diff --git a/reactos/lib/crt/ctype/toupper.c b/reactos/lib/crt/ctype/toupper.c index 7e21e65e226..df93d23e677 100644 --- a/reactos/lib/crt/ctype/toupper.c +++ b/reactos/lib/crt/ctype/toupper.c @@ -6,7 +6,7 @@ * PROGRAMMER: Copyright (C) 1995 DJ Delorie */ -#include +#include #undef toupper /* diff --git a/reactos/lib/crt/direct/chdir.c b/reactos/lib/crt/direct/chdir.c index 2a48e5cad53..a2d412a8e92 100644 --- a/reactos/lib/crt/direct/chdir.c +++ b/reactos/lib/crt/direct/chdir.c @@ -1,7 +1,7 @@ #include "precomp.h" -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/direct/chdrive.c b/reactos/lib/crt/direct/chdrive.c index 250aace5d2c..b65f5218d3e 100644 --- a/reactos/lib/crt/direct/chdrive.c +++ b/reactos/lib/crt/direct/chdrive.c @@ -1,9 +1,9 @@ #include "precomp.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include int cur_drive = 0; diff --git a/reactos/lib/crt/direct/getcwd.c b/reactos/lib/crt/direct/getcwd.c index a9801b6e8eb..6d820e395a4 100644 --- a/reactos/lib/crt/direct/getcwd.c +++ b/reactos/lib/crt/direct/getcwd.c @@ -1,8 +1,8 @@ #include "precomp.h" -#include -#include -#include -#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/direct/getdcwd.c b/reactos/lib/crt/direct/getdcwd.c index 3dab6d665b5..cc6b5f6a467 100644 --- a/reactos/lib/crt/direct/getdcwd.c +++ b/reactos/lib/crt/direct/getdcwd.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/direct/getdfree.c b/reactos/lib/crt/direct/getdfree.c index 84601c43eeb..fa6e83110bc 100644 --- a/reactos/lib/crt/direct/getdfree.c +++ b/reactos/lib/crt/direct/getdfree.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/direct/getdrive.c b/reactos/lib/crt/direct/getdrive.c index 4074bafbd18..006f9e4e95f 100644 --- a/reactos/lib/crt/direct/getdrive.c +++ b/reactos/lib/crt/direct/getdrive.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include extern int cur_drive; diff --git a/reactos/lib/crt/direct/mkdir.c b/reactos/lib/crt/direct/mkdir.c index bb160d45c68..5aea15fac0b 100644 --- a/reactos/lib/crt/direct/mkdir.c +++ b/reactos/lib/crt/direct/mkdir.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/direct/rmdir.c b/reactos/lib/crt/direct/rmdir.c index 5f89e80ad5e..bdf84d74551 100644 --- a/reactos/lib/crt/direct/rmdir.c +++ b/reactos/lib/crt/direct/rmdir.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/direct/wchdir.c b/reactos/lib/crt/direct/wchdir.c index 1c92c20f22f..3e49d1f851f 100644 --- a/reactos/lib/crt/direct/wchdir.c +++ b/reactos/lib/crt/direct/wchdir.c @@ -1,8 +1,7 @@ #include "precomp.h" -#include -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/direct/wgetcwd.c b/reactos/lib/crt/direct/wgetcwd.c index f1e62f4ea70..07454dbf46e 100644 --- a/reactos/lib/crt/direct/wgetcwd.c +++ b/reactos/lib/crt/direct/wgetcwd.c @@ -1,8 +1,8 @@ #include "precomp.h" -#include -#include -#include -#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/direct/wgetdcwd.c b/reactos/lib/crt/direct/wgetdcwd.c index 4de0744cf2e..ea8d5ed81d9 100644 --- a/reactos/lib/crt/direct/wgetdcwd.c +++ b/reactos/lib/crt/direct/wgetdcwd.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/direct/wmkdir.c b/reactos/lib/crt/direct/wmkdir.c index 21faa789bd9..f6693626cc7 100644 --- a/reactos/lib/crt/direct/wmkdir.c +++ b/reactos/lib/crt/direct/wmkdir.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/direct/wrmdir.c b/reactos/lib/crt/direct/wrmdir.c index 97e7d4b2065..5033e7e75fb 100644 --- a/reactos/lib/crt/direct/wrmdir.c +++ b/reactos/lib/crt/direct/wrmdir.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/float/chgsign.c b/reactos/lib/crt/float/chgsign.c index e2a0c806309..2b0ec60ce8a 100644 --- a/reactos/lib/crt/float/chgsign.c +++ b/reactos/lib/crt/float/chgsign.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/float/clearfp.c b/reactos/lib/crt/float/clearfp.c index 8832b3b447e..bace5d2dde1 100644 --- a/reactos/lib/crt/float/clearfp.c +++ b/reactos/lib/crt/float/clearfp.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/float/cntrlfp.c b/reactos/lib/crt/float/cntrlfp.c index c093d827e64..659eaa8b6e1 100644 --- a/reactos/lib/crt/float/cntrlfp.c +++ b/reactos/lib/crt/float/cntrlfp.c @@ -1,6 +1,6 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include +#include #define X87_CW_IM (1<<0) /* Invalid operation mask */ #define X87_CW_DM (1<<1) /* Denormal operand mask */ diff --git a/reactos/lib/crt/float/copysign.c b/reactos/lib/crt/float/copysign.c index 17bb869ab5c..9a5fe173ca7 100644 --- a/reactos/lib/crt/float/copysign.c +++ b/reactos/lib/crt/float/copysign.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/float/fpclass.c b/reactos/lib/crt/float/fpclass.c index 5dac73d020e..e14a4d72418 100644 --- a/reactos/lib/crt/float/fpclass.c +++ b/reactos/lib/crt/float/fpclass.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #define _FPCLASS_SNAN 0x0001 /* signaling NaN */ diff --git a/reactos/lib/crt/float/fpecode.c b/reactos/lib/crt/float/fpecode.c index bcf5339e7dc..523c02c64a9 100644 --- a/reactos/lib/crt/float/fpecode.c +++ b/reactos/lib/crt/float/fpecode.c @@ -2,8 +2,8 @@ #undef __USE_W32API #endif -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/float/fpreset.c b/reactos/lib/crt/float/fpreset.c index 7322097d958..776438d1f51 100644 --- a/reactos/lib/crt/float/fpreset.c +++ b/reactos/lib/crt/float/fpreset.c @@ -1,4 +1,4 @@ -#include +#include /* diff --git a/reactos/lib/crt/float/isnan.c b/reactos/lib/crt/float/isnan.c index e522fcb97ce..4054f069ad8 100644 --- a/reactos/lib/crt/float/isnan.c +++ b/reactos/lib/crt/float/isnan.c @@ -16,9 +16,9 @@ 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 +#include +#include +#include /* diff --git a/reactos/lib/crt/float/logb.c b/reactos/lib/crt/float/logb.c index d71c654ee77..55e65f90b55 100644 --- a/reactos/lib/crt/float/logb.c +++ b/reactos/lib/crt/float/logb.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double _logb (double __x) { diff --git a/reactos/lib/crt/float/nafter.c b/reactos/lib/crt/float/nafter.c index 9b5ddd7cef2..4311b3d2430 100644 --- a/reactos/lib/crt/float/nafter.c +++ b/reactos/lib/crt/float/nafter.c @@ -1,4 +1,4 @@ -#include +#include /* @@ -9,7 +9,7 @@ double _nextafter( double x, double y ) if ( x == y) return x; - if ( isnan(x) || isnan(y) ) + if ( _isnan(x) || _isnan(y) ) return x; return x; diff --git a/reactos/lib/crt/float/scalb.c b/reactos/lib/crt/float/scalb.c index cf2e673f2f0..583b5293fd8 100644 --- a/reactos/lib/crt/float/scalb.c +++ b/reactos/lib/crt/float/scalb.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/float/statfp.c b/reactos/lib/crt/float/statfp.c index e2d2112afb6..73ab3b72410 100644 --- a/reactos/lib/crt/float/statfp.c +++ b/reactos/lib/crt/float/statfp.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/io/access.c b/reactos/lib/crt/io/access.c index 4a3698a1fec..cbfc7ef3b91 100644 --- a/reactos/lib/crt/io/access.c +++ b/reactos/lib/crt/io/access.c @@ -1,17 +1,26 @@ #include "precomp.h" -#include -#include +#include +#include +#include +#include + #define NDEBUG -#include +#include + +#ifdef _UNICODE + #define _TS S +#else + #define _TS s +#endif /* * @implemented */ -int _access( const char *_path, int _amode ) +int _taccess( const _TCHAR *_path, int _amode ) { - DWORD Attributes = GetFileAttributesA(_path); - DPRINT("_access('%s', %x)\n", _path, _amode); + DWORD Attributes = GetFileAttributes(_path); + DPRINT(MK_STR(_taccess)"('%"_TS"', %x)\n", _path, _amode); if (Attributes == -1) { _dosmaperr(GetLastError()); @@ -23,11 +32,31 @@ int _access( const char *_path, int _amode ) return -1; } } - if ((_amode & D_OK) == D_OK) { - if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { - __set_errno(EACCES); - return -1; - } - } + return 0; } + + + +/* + * INTERNAL + */ +int access_dirT(const _TCHAR *_path) +{ + DWORD Attributes = GetFileAttributes(_path); + DPRINT(MK_STR(is_dirT)"('%"_TS"')\n", _path); + + if (Attributes == -1) { + _dosmaperr(GetLastError()); + return -1; + } + + if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) + { + __set_errno(EACCES); + return -1; + } + + return 0; +} + diff --git a/reactos/lib/crt/io/chmod.c b/reactos/lib/crt/io/chmod.c index 65f912d3ee3..a9aa73aae5d 100644 --- a/reactos/lib/crt/io/chmod.c +++ b/reactos/lib/crt/io/chmod.c @@ -1,9 +1,13 @@ + #include "precomp.h" -#include -#include +#include +#include +#include +#include #define NDEBUG -#include +#include + #define mode_t int @@ -11,14 +15,14 @@ /* * @implemented */ -int _chmod(const char* filename, mode_t mode) +int _tchmod(const _TCHAR* filename, mode_t mode) { DWORD FileAttributes = 0; BOOLEAN Set = FALSE; - DPRINT("_chmod('%s', %x)\n", filename, mode); + DPRINT(#_tchmod"('%"sT"', %x)\n", filename, mode); - FileAttributes = GetFileAttributesA(filename); + FileAttributes = GetFileAttributes(filename); if ( FileAttributes == -1 ) { _dosmaperr(GetLastError()); return -1; @@ -38,7 +42,7 @@ int _chmod(const char* filename, mode_t mode) Set = TRUE; } } - if (Set && SetFileAttributesA(filename, FileAttributes) == FALSE) { + if (Set && SetFileAttributes(filename, FileAttributes) == FALSE) { _dosmaperr(GetLastError()); return -1; } diff --git a/reactos/lib/crt/io/chsize.c b/reactos/lib/crt/io/chsize.c index 678c0f5e24e..7826a48d3d1 100644 --- a/reactos/lib/crt/io/chsize.c +++ b/reactos/lib/crt/io/chsize.c @@ -1,8 +1,8 @@ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -#include +#include #define NDEBUG -#include +#include /* * @implemented @@ -10,7 +10,7 @@ int _chsize(int _fd, long size) { DPRINT("_chsize(fd %d, size %d)\n", _fd, size); - if (lseek(_fd, size, 0) == -1) + if (_lseek(_fd, size, 0) == -1) return -1; if (_write(_fd, 0, 0) < 0) return -1; diff --git a/reactos/lib/crt/io/close.c b/reactos/lib/crt/io/close.c index 9388877e866..862a7ea418c 100644 --- a/reactos/lib/crt/io/close.c +++ b/reactos/lib/crt/io/close.c @@ -1,19 +1,22 @@ #include "precomp.h" -#include -#include +#include +#include #define NDEBUG -#include +#include /* * @implemented */ int _close(int _fd) { - DPRINT("_close(fd %d)\n", _fd); - if (_fd == -1) - return -1; - if (CloseHandle(_get_osfhandle(_fd)) == FALSE) - return -1; - return __fileno_close(_fd); + TRACE("_close(%i)", _fd); + + if (_fd == -1) + return(-1); + if (CloseHandle((HANDLE)_get_osfhandle(_fd)) == FALSE) + return(-1); + //return + free_fd(_fd); + return(0); } diff --git a/reactos/lib/crt/io/commit.c b/reactos/lib/crt/io/commit.c index 3eaa4b4e585..1444d4f50b2 100644 --- a/reactos/lib/crt/io/commit.c +++ b/reactos/lib/crt/io/commit.c @@ -1,7 +1,7 @@ #include "precomp.h" -#include -#include -#include +#include +#include +#include /* @@ -9,7 +9,7 @@ */ int _commit(int _fd) { - if (! FlushFileBuffers(_get_osfhandle(_fd)) ) { + if (! FlushFileBuffers((HANDLE)_get_osfhandle(_fd)) ) { __set_errno(EBADF); return -1; } diff --git a/reactos/lib/crt/io/create.c b/reactos/lib/crt/io/create.c index b8e0bd0c8c1..cb306855ea0 100644 --- a/reactos/lib/crt/io/create.c +++ b/reactos/lib/crt/io/create.c @@ -1,8 +1,8 @@ -#include -#include +#include +#include #define NDEBUG -#include +#include /* diff --git a/reactos/lib/crt/io/dup.c b/reactos/lib/crt/io/dup.c index bd9a55e4f6b..c1359631b8d 100644 --- a/reactos/lib/crt/io/dup.c +++ b/reactos/lib/crt/io/dup.c @@ -1,7 +1,7 @@ #include "precomp.h" -#include -#include -#include +#include +#include +#include /* @@ -14,7 +14,7 @@ int _dup(int handle) BOOL result; int fd; - hFile = _get_osfhandle(handle); + hFile = (HANDLE)_get_osfhandle(handle); if (hFile == INVALID_HANDLE_VALUE) { __set_errno(EBADF); return -1; @@ -31,7 +31,7 @@ int _dup(int handle) return -1; } - fd = __fileno_alloc(hFile, __fileno_getmode(handle)); + fd = alloc_fd(hFile, __fileno_getmode(handle)); if (fd < 0) { CloseHandle(hFile); diff --git a/reactos/lib/crt/io/dup2.c b/reactos/lib/crt/io/dup2.c index 1571b54543d..9d09e8886ef 100644 --- a/reactos/lib/crt/io/dup2.c +++ b/reactos/lib/crt/io/dup2.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/io/eof.c b/reactos/lib/crt/io/eof.c index 827df20bf71..bae829e2943 100644 --- a/reactos/lib/crt/io/eof.c +++ b/reactos/lib/crt/io/eof.c @@ -1,4 +1,5 @@ -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/io/filelen.c b/reactos/lib/crt/io/filelen.c index d54547ad93c..dbc17e4ba7c 100644 --- a/reactos/lib/crt/io/filelen.c +++ b/reactos/lib/crt/io/filelen.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* @@ -8,7 +8,7 @@ */ long _filelength(int _fd) { - DWORD len = GetFileSize(_get_osfhandle(_fd), NULL); + DWORD len = GetFileSize((HANDLE)_get_osfhandle(_fd), NULL); if (len == INVALID_FILE_SIZE) { DWORD oserror = GetLastError(); if (oserror != 0) { diff --git a/reactos/lib/crt/io/fileleni.c b/reactos/lib/crt/io/fileleni.c index 5012eca585b..3b68824c13f 100644 --- a/reactos/lib/crt/io/fileleni.c +++ b/reactos/lib/crt/io/fileleni.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* @@ -10,7 +10,7 @@ __int64 _filelengthi64(int _fd) { DWORD lo_length, hi_length; - lo_length = GetFileSize(_get_osfhandle(_fd), &hi_length); + lo_length = GetFileSize((HANDLE)_get_osfhandle(_fd), &hi_length); if (lo_length == INVALID_FILE_SIZE) { DWORD oserror = GetLastError(); if (oserror != 0) { diff --git a/reactos/lib/crt/io/find.c b/reactos/lib/crt/io/find.c index ba06105fc0b..73b4b4fd6f5 100644 --- a/reactos/lib/crt/io/find.c +++ b/reactos/lib/crt/io/find.c @@ -1,9 +1,178 @@ #include "precomp.h" -#include -#include -#include +#include +#include +#include +#include +/* + * @implemented + */ +#ifdef _UNICODE +long +#else +int +#endif +_tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result) +{ + WIN32_FIND_DATA FindFileData; + _TCHAR dir[MAX_PATH]; + long hFindFile; + int len = 0; + + if (_name == NULL || _name[0] == 0) { + len = GetCurrentDirectory(MAX_PATH-4,dir); + if (dir[len-1] != '\\') { + dir[len] = '\\'; + dir[len+1] = 0; + } + _tcscat(dir,_T("*.*")); + } else { + _tcscpy(dir,_name); + } + + hFindFile = (long)FindFirstFile(dir, &FindFileData); + if (hFindFile == -1) { + memset(result,0,sizeof(struct _tfinddata_t)); + _dosmaperr(GetLastError()); + return -1; + } + + result->attrib = FindFileData.dwFileAttributes; + result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); + result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); + result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); + result->size = FindFileData.nFileSizeLow; + _tcsncpy(result->name,FindFileData.cFileName,MAX_PATH); + + // if no wildcard the find file handle can be closed right away + // a return value of 0 can flag this. + + if (!_tcschr(dir,'*') && !_tcschr(dir,'?')) { + _findclose(hFindFile); + return 0; + } + + return hFindFile; +} + +/* + * @implemented + */ +int _tfindnext( +#ifdef _UNICODE + long handle, +#else + int handle, +#endif + struct _tfinddata_t* result) +{ + WIN32_FIND_DATA FindFileData; + + // check no wildcards or invalid handle + if (handle == 0 || handle == -1) + return 0; + + if (!FindNextFile((void*)handle, &FindFileData)) { + _dosmaperr(GetLastError()); + return -1; + } + + result->attrib = FindFileData.dwFileAttributes; + result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); + result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); + result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); + result->size = FindFileData.nFileSizeLow; + _tcsncpy(result->name,FindFileData.cFileName, MAX_PATH); + + return 0; +} + + +/* + * @implemented + */ +long _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result) +{ + WIN32_FIND_DATA FindFileData; + _TCHAR dir[MAX_PATH]; + long hFindFile; + int len = 0; + + if ( _name == NULL || _name[0] == 0 ) + { + len = GetCurrentDirectory(MAX_PATH-4,dir); + if (dir[len-1] != '\\') + { + dir[len] = '\\'; + dir[len+1] = 0; + } + _tcscat(dir, _T("*.*")); + } + else + _tcscpy(dir, _name); + + hFindFile = (long)FindFirstFile(dir, &FindFileData); + if (hFindFile == -1) + { + memset(result,0,sizeof(struct _tfinddatai64_t)); + _dosmaperr(GetLastError()); + return -1; + } + + result->attrib = FindFileData.dwFileAttributes; + result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); + result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); + result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); + result->size = + (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow; + _tcsncpy(result->name,FindFileData.cFileName,MAX_PATH); + + // if no wildcard the find file handle can be closed right away + // a return value of 0 can flag this. + + if (!_tcschr(dir,'*') && !_tcschr(dir,'?')) { + _findclose(hFindFile); + return 0; + } + return hFindFile; +} + +//_CRTIMP long __cdecl _findfirsti64(const char*, struct _finddatai64_t*); +//_CRTIMP int __cdecl _findnexti64(long, struct _finddatai64_t*); + + +/* + * @implemented + */ +int _tfindnexti64(long handle, struct _tfinddatai64_t *result) +{ + WIN32_FIND_DATA FindFileData; + + // check no wildcards or invalid handle + if (handle == 0 || handle == -1) + return 0; + + if (!FindNextFile((HANDLE)handle, &FindFileData)) { + _dosmaperr(GetLastError()); + return -1; + } + + result->attrib = FindFileData.dwFileAttributes; + result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); + result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); + result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); + result->size = + (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow; + _tcsncpy(result->name,FindFileData.cFileName,MAX_PATH); + + return 0; +} + + + +#ifndef _UNICODE + /* * @implemented */ @@ -15,75 +184,4 @@ int _findclose(int handle) return FindClose((void*)handle); } -/* - * @implemented - */ -int _findfirst(const char* _name, struct _finddata_t* result) -{ - WIN32_FIND_DATAA FindFileData; - char dir[MAX_PATH]; - long hFindFile; - int len = 0; - - if (_name == NULL || _name[0] == 0) { - len = GetCurrentDirectoryA(MAX_PATH-4,dir); - if (dir[len-1] != '\\') { - dir[len] = '\\'; - dir[len+1] = 0; - } - strcat(dir,"*.*"); - } else { - strcpy(dir,_name); - } - - hFindFile = (long)FindFirstFileA(dir, &FindFileData); - if (hFindFile == -1) { - memset(result,0,sizeof(struct _finddata_t)); - _dosmaperr(GetLastError()); - return -1; - } - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = FindFileData.nFileSizeLow; - strncpy(result->name,FindFileData.cFileName,MAX_PATH); - - // if no wildcard the find file handle can be closed right away - // a return value of 0 can flag this. - - if (!strchr(dir,'*') && !strchr(dir,'?')) { - _findclose(hFindFile); - return 0; - } - - return hFindFile; -} - -/* - * @implemented - */ -int _findnext(int handle, struct _finddata_t* result) -{ - WIN32_FIND_DATAA FindFileData; - - // check no wildcards or invalid handle - if (handle == 0 || handle == -1) - return 0; - - if (!FindNextFileA((void*)handle, &FindFileData)) { - _dosmaperr(GetLastError()); - return -1; - } - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = FindFileData.nFileSizeLow; - strncpy(result->name,FindFileData.cFileName, MAX_PATH); - - return 0; -} - +#endif diff --git a/reactos/lib/crt/io/fmode.c b/reactos/lib/crt/io/fmode.c index 2306d60a40f..378be8025d5 100644 --- a/reactos/lib/crt/io/fmode.c +++ b/reactos/lib/crt/io/fmode.c @@ -1,14 +1,14 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include -int __fmode = O_TEXT; +int _fmode = O_TEXT; /* * @implemented */ int *__p__fmode(void) { - return &__fmode; + return &_fmode; } diff --git a/reactos/lib/crt/io/isatty.c b/reactos/lib/crt/io/isatty.c index a1d67b85289..9dae86c800c 100644 --- a/reactos/lib/crt/io/isatty.c +++ b/reactos/lib/crt/io/isatty.c @@ -1,15 +1,15 @@ -#include -#include +#include +#include #define NDEBUG -#include +#include /* * @implemented */ int _isatty( int fd ) { - struct stat buf; + struct _stat buf; DPRINT("_isatty(fd %d)\n", fd); if (_fstat (fd, &buf) < 0) return 0; diff --git a/reactos/lib/crt/io/locking.c b/reactos/lib/crt/io/locking.c index 6d82811ef21..9ea0f3530b1 100644 --- a/reactos/lib/crt/io/locking.c +++ b/reactos/lib/crt/io/locking.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* @@ -11,7 +11,7 @@ int _locking(int _fd, int mode, long nbytes) long offset = _lseek(_fd, 0L, 1); if (offset == -1L) return -1; - if (!LockFile(_get_osfhandle(_fd),offset,0,nbytes,0)) { + if (!LockFile((HANDLE)_get_osfhandle(_fd),offset,0,nbytes,0)) { _dosmaperr(GetLastError()); return -1; } diff --git a/reactos/lib/crt/io/lseek.c b/reactos/lib/crt/io/lseek.c index 2cd2599ea44..68c995fb287 100644 --- a/reactos/lib/crt/io/lseek.c +++ b/reactos/lib/crt/io/lseek.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include /* @@ -8,7 +8,7 @@ */ long _lseek(int _fildes, long _offset, int _whence) { - DWORD newpos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, NULL, _whence); + DWORD newpos = SetFilePointer((HANDLE)fdinfo(_fildes)->hFile, _offset, NULL, _whence); if (newpos == INVALID_SET_FILE_POINTER) { DWORD oserror = GetLastError(); if (oserror != 0) { diff --git a/reactos/lib/crt/io/lseeki64.c b/reactos/lib/crt/io/lseeki64.c index 78bfa0507d9..c5fbb3bdaff 100644 --- a/reactos/lib/crt/io/lseeki64.c +++ b/reactos/lib/crt/io/lseeki64.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include //#define SETFILEPOINTEREX_AVAILABLE @@ -19,7 +19,7 @@ __int64 _lseeki64(int _fildes, __int64 _offset, int _whence) // __set_errno ( EBADF ); // return -1L; // } - if (SetFilePointerEx((HANDLE)filehnd(_fildes), offset, &new_pos, _whence)) { + if (SetFilePointerEx((HANDLE)fdinfo(_fildes)->hFile, offset, &new_pos, _whence)) { } else { _dosmaperr(error); return -1L; @@ -34,7 +34,7 @@ __int64 _lseeki64(int _fildes, __int64 _offset, int _whence) LARGE_INTEGER offset; offset.QuadPart = _offset; - offset.u.LowPart = SetFilePointer((HANDLE)filehnd(_fildes), + offset.u.LowPart = SetFilePointer((HANDLE)fdinfo(_fildes)->hFile, offset.u.LowPart, &offset.u.HighPart, _whence); return ((((__int64)offset.u.HighPart) << 32) + offset.u.LowPart); diff --git a/reactos/lib/crt/io/mktemp.c b/reactos/lib/crt/io/mktemp.c index b895fa0655a..e54d95fb331 100644 --- a/reactos/lib/crt/io/mktemp.c +++ b/reactos/lib/crt/io/mktemp.c @@ -13,12 +13,12 @@ /* 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 #define NDEBUG -#include +#include /* diff --git a/reactos/lib/crt/io/open.c b/reactos/lib/crt/io/open.c index 1921fa4ef06..79bb40bd957 100644 --- a/reactos/lib/crt/io/open.c +++ b/reactos/lib/crt/io/open.c @@ -8,87 +8,139 @@ * UPDATE HISTORY: * 28/12/98: Created */ - +/* + * Some stuff taken from active perl: perl\win32.c (ioinfo stuff) + * + * (c) 1995 Microsoft Corporation. All rights reserved. + * Developed by hip communications inc., http://info.hip.com/info/ + * Portions (c) 1993 Intergraph Corporation. All rights reserved. + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + */ +/* + * Some functions taken from/based on wine\dlls\msvcrt\file.c: + * split_oflags + * _open_osfhandle + * many more... + * + * Copyright 1996,1998 Marcus Meissner + * Copyright 1996 Jukka Iivonen + * Copyright 1997,2000 Uwe Bonnes + * Copyright 2000 Jon Griffiths + * Copyright 2004 Eric Pouech + * Copyright 2004 Juan Lang + */ + // rember to interlock the allocation of fileno when making this thread safe // possibly store extra information at the handle #include "precomp.h" + #if !defined(NDEBUG) && defined(DBG) -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include + +#include +#include +#include +#include +#include +#include +#include +#include #define NDEBUG -#include +#include -//#define _OLD_BUILD_ -#define STD_AUX_HANDLE 3 -#define STD_PRINTER_HANDLE 4 +FDINFO first_bucket[FDINFO_ENTRIES_PER_BUCKET]; +FDINFO* __pioinfo[FDINFO_BUCKETS] = {first_bucket}; + + +/* This critical section protects the tables MSVCRT_fdesc and MSVCRT_fstreams, + * and their related indexes, MSVCRT_fdstart, MSVCRT_fdend, + * and MSVCRT_stream_idx, from race conditions. + * It doesn't protect against race conditions manipulating the underlying files + * or flags; doing so would probably be better accomplished with per-file + * protection, rather than locking the whole table for every change. + */ +static CRITICAL_SECTION g_file_cs; +#define LOCK_FILES() do { EnterCriticalSection(&g_file_cs); } while (0) +#define UNLOCK_FILES() do { LeaveCriticalSection(&g_file_cs); } while (0) ///////////////////////////////////////// -#if 0 // from perl sources -#ifndef _INTPTR_T_DEFINED -typedef int intptr_t; -#define _INTPTR_T_DEFINED -#endif - -#ifndef _UINTPTR_T_DEFINED -typedef unsigned int uintptr_t; -#define _UINTPTR_T_DEFINED -#endif +static int g_fdstart = 3; /* first unallocated fd */ +static int g_fdend = 3; /* highest allocated fd */ /* - * Control structure for lowio file handles + * INTERNAL */ -typedef struct { - intptr_t osfhnd;/* underlying OS file HANDLE */ - char osfile; /* attributes of file (e.g., open in text mode?) */ - char pipech; /* one char buffer for handles opened on pipes */ - int lockinitflag; - //CRITICAL_SECTION lock; -} ioinfo; - -/* - * Array of arrays of control structures for lowio files. - */ -//ioinfo* __pioinfo[]; -//ioinfo* __pioinfo[] = { NULL }; - -#endif -///////////////////////////////////////// - -typedef struct _fileno_modes_type + /* +static inline FD_INFO* fdinfo(int fd) { - HANDLE hFile; - int mode; - char pipech; /* one char buffer for handles opened on pipes */ - int lockinitflag; - /*CRITICAL_SECTION*/int lock; - int fd; -} fileno_modes_type; + FD_INFO* bucket = __pioinfo[fd >> FDINFO_ENTRIES_PER_BUCKET_SHIFT]; + if (!bucket){ + bucket = alloc_init_bucket(fd); + } + return bucket + (fd & (FDINFO_ENTRIES_PER_BUCKET - 1)); +} +*/ -//static fileno_modes_type* fileno_modes = NULL; -fileno_modes_type* __pioinfo = NULL; -///////////////////////////////////////// -int maxfno = 0; +/* + * INTERNAL + */ +inline BOOL is_valid_fd(int fd) +{ + BOOL b = (fd >= 0 && fd < g_fdend && (fdinfo(fd)->fdflags & FOPEN)); + + if (!b){ + DPRINT1("not valid fd %i, g_fdend %i, fdinfo %x, bucket %x, fdflags %x\n", + fd,g_fdend,fdinfo(fd),fdinfo_bucket(fd),fdinfo(fd)->fdflags); + + } + + return b; +} +/* + * INTERNAL + */ +char split_oflags(int oflags) +{ + char fdflags = 0; + + if (oflags & _O_APPEND) fdflags |= FAPPEND; + + if (oflags & _O_BINARY) ; + else if (oflags & _O_TEXT) fdflags |= FTEXT; + else if (_fmode& _O_BINARY) ; + else fdflags |= FTEXT; /* default to TEXT*/ + + if (oflags & _O_NOINHERIT) fdflags |= FNOINHERIT; + + if (oflags & ~(_O_BINARY|_O_TEXT|_O_APPEND|_O_TRUNC| + _O_EXCL|_O_CREAT|_O_RDWR|_O_WRONLY| + _O_TEMPORARY|_O_NOINHERIT)) + DPRINT1(":unsupported oflags 0x%04x\n",oflags); + + return fdflags; +} + + + +/* + * INTERNAL + */ char __is_text_file(FILE* p) { - if ( p == NULL || __pioinfo == NULL ) + if ( p == NULL || fdinfo_bucket((p)->_file) == NULL ) return FALSE; - return (!((p)->_flag&_IOSTRG) && (__pioinfo[(p)->_file].mode&O_TEXT)); + return (!((p)->_flag&_IOSTRG) && (fdinfo((p)->_file)->fdflags & FTEXT)); } /* @@ -112,7 +164,9 @@ int _open(const char* _path, int _oflag,...) pmode = va_arg(arg, int); #endif -// DPRINT("_open('%s', %x, (%x))\n", _path, _oflag, pmode); + + TRACE("_open('%s', %x, (%x))\n", _path, _oflag); + if ((_oflag & S_IREAD ) == S_IREAD) dwShareMode = FILE_SHARE_READ; @@ -188,155 +242,304 @@ int _open(const char* _path, int _oflag,...) NULL); if (hFile == (HANDLE)-1) { _dosmaperr(GetLastError()); - return -1; + return( -1); } DPRINT("OK\n"); if (!(_oflag & (_O_TEXT|_O_BINARY))) { - _oflag |= __fmode; + _oflag |= _fmode; } - return __fileno_alloc(hFile,_oflag); + return(alloc_fd(hFile, split_oflags(_oflag))); } -int __fileno_alloc(HANDLE hFile, int mode) + +/* + * INTERNAL + */ +static void init_bucket(FDINFO* entry) { - int i; - /* Check for bogus values */ - if (hFile < 0) - return -1; - - for (i = 5; i < maxfno; i++) { - if (__pioinfo[i].fd == -1 ) { - __pioinfo[i].fd = i; - __pioinfo[i].mode = mode; - __pioinfo[i].hFile = hFile; - return i; - } - } - - /* See if we need to expand the tables. Check this BEFORE it might fail, - so that when we hit the count'th request, we've already up'd it. */ - if (i == maxfno) { - int oldcount = maxfno; - fileno_modes_type* old_fileno_modes = __pioinfo; - maxfno += 255; - __pioinfo = (fileno_modes_type*)malloc(maxfno * sizeof(fileno_modes_type)); - if (old_fileno_modes != NULL) { - memcpy(__pioinfo, old_fileno_modes, oldcount * sizeof(fileno_modes_type)); - free(old_fileno_modes); - } - memset(__pioinfo + oldcount, -1, (maxfno-oldcount)*sizeof(fileno_modes_type)); - } - - /* Fill in the value */ - __pioinfo[i].fd = i; - __pioinfo[i].mode = mode; - __pioinfo[i].hFile = hFile; - return i; + int i; + + for(i=0; + i < FDINFO_ENTRIES_PER_BUCKET; + i++, entry++) + { + entry->hFile = INVALID_HANDLE_VALUE; + entry->fdflags = 0; + entry->pipechar = LF; + entry->lockinitflag = 0; + } } -void* filehnd(int fileno) +/* + * INTERNAL + */ +static BOOL alloc_init_bucket(int fd) { - if (fileno < 0 || fileno >= maxfno || __pioinfo[fileno].fd == -1) { - return (void*)-1; - } - return __pioinfo[fileno].hFile; + fdinfo_bucket(fd) = malloc(FDINFO_ENTRIES_PER_BUCKET * sizeof(FDINFO)); + if (!fdinfo_bucket(fd)) return FALSE; + + init_bucket(fdinfo_bucket(fd)); + + return TRUE; } -int __fileno_setmode(int _fd, int _newmode) + + + +/* + * INTERNAL + * Allocate an fd slot from a Win32 HANDLE, starting from fd + * caller must hold the files lock + */ +static int alloc_fd_from(HANDLE hand, char flag, int fd) { - int m; - if (_fd < 0 || _fd >= maxfno) { + + if (fd >= FDINFO_ENTRIES) + { + DPRINT1("files exhausted!\n"); + return -1; + } + + if (!fdinfo_bucket(fd)) + { + if (!alloc_init_bucket(fd)){ + //errno = ENOMEM + return -1; + } + } + + fdinfo(fd)->hFile = hand; + fdinfo(fd)->fdflags = FOPEN | (flag & (FNOINHERIT | FAPPEND | FTEXT)); + fdinfo(fd)->pipechar = LF; + fdinfo(fd)->lockinitflag = 0; + //fdinfo(fd)->lock + + /* locate next free slot */ + if (fd == g_fdstart && fd == g_fdend) + { + g_fdstart = g_fdend + 1; + } + else + { +#if 0 /* alternate (untested) impl. maybe a tiny bit faster? -Gunnar */ + int i, bidx; + + for (bidx = fdinfo_bucket_idx(g_fdstart); bidx < FDINFO_BUCKETS && __pioinfo[bidx]; bidx++) + { + for (i = fdinfo_bucket_entry_idx(g_fdstart); + g_fdstart < g_fdend && fdinfo(g_fdstart)->fdflags & FOPEN && i < FDINFO_BUCKET_ENTRIES; + i++) + { + g_fdstart++; + } + } +#else + + while (g_fdstart < g_fdend && + fdinfo_bucket(g_fdstart) && + (fdinfo(g_fdstart)->fdflags & FOPEN)) + { + g_fdstart++; + } +#endif + } + + /* update last fd in use */ + if (fd >= g_fdend) + g_fdend = fd + 1; + + /* alloc more fdinfo buckets by demand. + * FIXME: should we dealloc buckets when they become unused also? */ + if (!fdinfo_bucket(g_fdstart) && g_fdstart < FDINFO_ENTRIES) + { + alloc_init_bucket(g_fdstart); + } + + DPRINT("fdstart is %d, fdend is %d\n", g_fdstart, g_fdend); + + switch (fd) + { + case 0: SetStdHandle(STD_INPUT_HANDLE, hand); break; + case 1: SetStdHandle(STD_OUTPUT_HANDLE, hand); break; + case 2: SetStdHandle(STD_ERROR_HANDLE, hand); break; + } + + return fd; +} + + +/* + * INTERNAL: Allocate an fd slot from a Win32 HANDLE + */ +int alloc_fd(HANDLE hand, char flag) +{ + int ret; + + LOCK_FILES(); + +// TRACE(":handle (%p) allocating fd (%d)\n",hand,MSVCRT_fdstart); + ret = alloc_fd_from(hand, flag, g_fdstart); + + UNLOCK_FILES(); + return ret; +} + + + +/* + * INTERNAL + */ +char __fileno_getmode(int fd) +{ + if (!is_valid_fd(fd)) { __set_errno(EBADF); return -1; } - m = __pioinfo[_fd].mode; - __pioinfo[_fd].mode = _newmode; - return m; -} - -int __fileno_getmode(int _fd) -{ - if (_fd < 0 || _fd >= maxfno) { - __set_errno(EBADF); - return -1; - } - return __pioinfo[_fd].mode; + return fdinfo(fd)->fdflags; } -int __fileno_close(int _fd) +/* + * INTERNAL + */ +void free_fd(int fd) { - if (_fd < 0 || _fd >= maxfno) { - __set_errno(EBADF); - return -1; - } - __pioinfo[_fd].fd = -1; - __pioinfo[_fd].hFile = (HANDLE)-1; - return 0; + LOCK_FILES(); + + + fdinfo(fd)->hFile = INVALID_HANDLE_VALUE; + fdinfo(fd)->fdflags = 0; + + if (fd < 3) /* don't use 0,1,2 for user files */ + { + switch (fd) + { + case 0: SetStdHandle(STD_INPUT_HANDLE, NULL); break; + case 1: SetStdHandle(STD_OUTPUT_HANDLE, NULL); break; + case 2: SetStdHandle(STD_ERROR_HANDLE, NULL); break; + } + } + else + { + if (fd == g_fdend - 1) + g_fdend--; + + if (fd < g_fdstart) + g_fdstart = fd; + } + + + UNLOCK_FILES(); } /* * @implemented */ -int _open_osfhandle(void* osfhandle, int flags) +int _open_osfhandle(long osfhandle, int oflags) { - return __fileno_alloc((HANDLE)osfhandle, flags); + /* + PREV: + The _open_osfhandle() function in MSVCRT is expected to take the absence + of either _O_TEXT or _O_BINARY to mean _O_BINARY. Currently it defaults to + _O_TEXT. + + An example of this is MFC's CStdioFile::Open in binary mode - it passes flags + of 0 when it wants to write a binary file - under WINE we do text mode conversions! + + The attached patch ensures that _O_BINARY is set if neither is set in the passed-in +flags. + + + * file, so set the write flag. It also only sets _O_TEXT if it wants + * text - it never sets _O_BINARY. + */ + /* FIXME: handle more flags */ +/* + flags |= MSVCRT__IOREAD|MSVCRT__IOWRT; + if ( !( flags & _O_TEXT ) ) flags |= _O_BINARY; + + fd = msvcrt_alloc_fd((HANDLE)hand,flags); + TRACE(":handle (%ld) fd (%d) flags 0x%08x\n",hand,fd, flags); +*/ + /* MSVCRT__O_RDONLY (0) always matches, so set the read flag + * MFC's CStdioFile clears O_RDONLY (0)! if it wants to write to the + * file, so set the write flag. It also only sets MSVCRT__O_TEXT if it wants + * text - it never sets MSVCRT__O_BINARY. + */ + /* FIXME: handle more flags */ + /* + LAG TEST SOM TESTER UT ALT DETTE flag tingern + */ + if (!(oflags & (_O_BINARY | _O_TEXT)) && (_fmode & _O_BINARY)) + oflags |= _O_BINARY; + else + oflags |= _O_TEXT; + + return alloc_fd((HANDLE)osfhandle, split_oflags(oflags)); } /* * @implemented */ -void* _get_osfhandle( int fileno ) +long _get_osfhandle(int fd) { - return filehnd(fileno); + TRACE("_get_osfhandle(%i)",fd); + + if (!is_valid_fd(fd)) { + return( -1 ); + } + return( (long)fdinfo(fd)->hFile ); } + + +/* + * INTERNAL + */ int __fileno_dup2(int handle1, int handle2) { HANDLE hProcess; BOOL result; - if (handle1 >= maxfno || handle1 < 0 || handle2 >= maxfno || handle2 < 0) { + + if (handle1 >= FDINFO_ENTRIES || handle1 < 0 || handle2 >= FDINFO_ENTRIES || handle2 < 0) { __set_errno(EBADF); return -1; } - if (__pioinfo[handle1].fd == -1) { +// if (_pioinfo[handle1]->fd == -1) { + if (fdinfo(handle1)->hFile == INVALID_HANDLE_VALUE) { __set_errno(EBADF); return -1; } if (handle1 == handle2) return handle1; - if (__pioinfo[handle2].fd != -1) { +// if (_pioinfo[handle2]->fd != -1) { + if (fdinfo(handle2)->hFile != INVALID_HANDLE_VALUE) { _close(handle2); } hProcess = GetCurrentProcess(); result = DuplicateHandle(hProcess, - __pioinfo[handle1].hFile, + fdinfo(handle1)->hFile, hProcess, - &__pioinfo[handle2].hFile, + &fdinfo(handle2)->hFile, 0, TRUE, DUPLICATE_SAME_ACCESS); if (result) { - __pioinfo[handle2].fd = handle2; - __pioinfo[handle2].mode = __pioinfo[handle1].mode; +// _pioinfo[handle2]->fd = handle2; + fdinfo(handle2)->fdflags = fdinfo(handle1)->fdflags; switch (handle2) { case 0: - SetStdHandle(STD_INPUT_HANDLE, __pioinfo[handle2].hFile); + SetStdHandle(STD_INPUT_HANDLE, fdinfo(handle2)->hFile); break; case 1: - SetStdHandle(STD_OUTPUT_HANDLE, __pioinfo[handle2].hFile); + SetStdHandle(STD_OUTPUT_HANDLE, fdinfo(handle2)->hFile); break; case 2: - SetStdHandle(STD_ERROR_HANDLE, __pioinfo[handle2].hFile); - break; - case 3: - SetStdHandle(STD_AUX_HANDLE, __pioinfo[handle2].hFile); - break; - case 4: - SetStdHandle(STD_AUX_HANDLE, __pioinfo[handle2].hFile); + SetStdHandle(STD_ERROR_HANDLE, fdinfo(handle2)->hFile); break; } + return handle1; } else { __set_errno(EMFILE); // Is this the correct error no.? @@ -347,77 +550,172 @@ int __fileno_dup2(int handle1, int handle2) void* malloc(size_t sizeObject); + + +/* + * INTERNAL + */ BOOL __fileno_init(void) { - ULONG count = 0, i; - HANDLE* pFile; - char* pmode; - STARTUPINFOA StInfo; + STARTUPINFOA si; + int i; - GetStartupInfoA(&StInfo); - if (StInfo.lpReserved2 && StInfo.cbReserved2 >= sizeof(ULONG)) { - count = *(ULONG*)StInfo.lpReserved2; -/* - if (sizeof(ULONG) + count * (sizeof(HANDLE) + sizeof(char)) != StInfo.cbReserved2) - { - count = 0; - } -*/ - } - maxfno = 255; - while(count >= maxfno) - maxfno += 255; + init_bucket(first_bucket); + GetStartupInfoA(&si); + + if (si.cbReserved2 != 0 && si.lpReserved2 != NULL) { -#ifdef _OLD_BUILD_ - // why was this here ???? - robd. - int result; - result = malloc(50); -#endif - } - //__pioinfo = (fileno_modes_type*)malloc(sizeof(fileno_modes_type) * maxfno); - __pioinfo = malloc(sizeof(fileno_modes_type) * maxfno); - if (__pioinfo == NULL) { - return FALSE; - } - memset(__pioinfo, -1, sizeof(fileno_modes_type) * maxfno); - if (count) { - pFile = (HANDLE*)(StInfo.lpReserved2 + sizeof(ULONG) + count * sizeof(char)); - pmode = (char*)(StInfo.lpReserved2 + sizeof(ULONG)); - for (i = 0; i < count; i++) { - if (*pFile != INVALID_HANDLE_VALUE) { - __pioinfo[i].fd = i; - __pioinfo[i].mode = ((*pmode << 8) & (_O_TEXT|_O_BINARY)) | (*pmode & _O_ACCMODE); - __pioinfo[i].hFile = *pFile; - } - pFile++; - pmode++; + char* fdflags_ptr; + HANDLE* handle_ptr; + + g_fdend = *(unsigned*)si.lpReserved2; + + fdflags_ptr= (char*)(si.lpReserved2 + sizeof(unsigned)); + handle_ptr = (HANDLE*)(fdflags_ptr + g_fdend * sizeof(char)); + + g_fdend = min(g_fdend, FDINFO_ENTRIES); + for (i = 0; i < g_fdend; i++) + { + if (!fdinfo_bucket(i)) + { + if (!alloc_init_bucket(i)){ + /* FIXME: free other buckets? */ + return FALSE; + } } + + if ((*fdflags_ptr & FOPEN) && *handle_ptr != INVALID_HANDLE_VALUE) + { + fdinfo(i)->fdflags = *fdflags_ptr; + fdinfo(i)->hFile = *handle_ptr; + } +/* + else + { + fdinfo(i)->fdflags = 0; + fdinfo(i)->hFile = INVALID_HANDLE_VALUE; + } +*/ + fdflags_ptr++; handle_ptr++; + } + for (g_fdstart = 3; g_fdstart < g_fdend; g_fdstart++) + if (fdinfo(g_fdstart)->hFile == INVALID_HANDLE_VALUE) break; } - if (__pioinfo[0].fd == -1) { - __pioinfo[0].fd = 0; - __pioinfo[0].hFile = GetStdHandle(STD_INPUT_HANDLE); - __pioinfo[0].mode = _O_RDONLY|_O_TEXT; + + InitializeCriticalSection(&g_file_cs); + + + if (fdinfo(0)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(0)->fdflags & FOPEN)) { + fdinfo(0)->hFile = GetStdHandle(STD_INPUT_HANDLE); + fdinfo(0)->fdflags = FOPEN|FTEXT; } - if (__pioinfo[1].fd == -1) { - __pioinfo[1].fd = 1; - __pioinfo[1].hFile = GetStdHandle(STD_OUTPUT_HANDLE); - __pioinfo[1].mode = _O_WRONLY|_O_TEXT; + if (fdinfo(1)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(1)->fdflags & FOPEN)) { + fdinfo(1)->hFile = GetStdHandle(STD_OUTPUT_HANDLE); + fdinfo(1)->fdflags = FOPEN|FTEXT; } - if (__pioinfo[2].fd == -1) { - __pioinfo[2].fd = 2; - __pioinfo[2].hFile = GetStdHandle(STD_ERROR_HANDLE); - __pioinfo[2].mode = _O_WRONLY|_O_TEXT; + if (fdinfo(2)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(2)->fdflags & FOPEN)) { + fdinfo(2)->hFile = GetStdHandle(STD_ERROR_HANDLE); + fdinfo(2)->fdflags = FOPEN|FTEXT; } - if (__pioinfo[3].fd == -1) { - __pioinfo[3].fd = 3; - __pioinfo[3].hFile = GetStdHandle(STD_AUX_HANDLE); - __pioinfo[3].mode = _O_WRONLY|_O_TEXT; - } - if (__pioinfo[4].fd == -1) { - __pioinfo[4].fd = 4; - __pioinfo[4].hFile = GetStdHandle(STD_PRINTER_HANDLE); - __pioinfo[4].mode = _O_WRONLY|_O_TEXT; + + + + + for (i = 0; i < 3; i++) + { + /* FILE structs for stdin/out/err are static and never deleted */ +// MSVCRT_fstreams[i] = &MSVCRT__iob[i]; } +// MSVCRT_stream_idx = 3; + return TRUE; } + + + +/* INTERNAL: Create an inheritance data block (for spawned process) + * The inheritance block is made of: + * 00 int nb of file descriptor (NBFD) + * 04 char file flags (wxflag): repeated for each fd + * 4+NBFD HANDLE file handle: repeated for each fd + */ +unsigned create_io_inherit_block(STARTUPINFOA* si) +{ + int fd; + char* fdflags_ptr; + HANDLE* handle_ptr; + + TRACE("create_io_inherit_block(%x)",si); + + si->cbReserved2 = sizeof(unsigned) + (sizeof(char) + sizeof(HANDLE)) * g_fdend; + si->lpReserved2 = calloc(si->cbReserved2, 1); + if (!si->lpReserved2) + { + si->cbReserved2 = 0; + return( FALSE ); + } + fdflags_ptr = (char*)si->lpReserved2 + sizeof(unsigned); + handle_ptr = (HANDLE*)(fdflags_ptr + g_fdend * sizeof(char)); + + *(unsigned*)si->lpReserved2 = g_fdend; + for (fd = 0; fd < g_fdend; fd++) + { + /* to be inherited, we need it to be open, and that DONTINHERIT isn't set */ + if ((fdinfo(fd)->fdflags & (FOPEN | FNOINHERIT)) == FOPEN) + { + *fdflags_ptr = fdinfo(fd)->fdflags; + *handle_ptr = fdinfo(fd)->hFile; + } + else + { + *fdflags_ptr = 0; + *handle_ptr = INVALID_HANDLE_VALUE; + } + fdflags_ptr++; handle_ptr++; + } + return( TRUE ); +} + + + + +/* + * @implemented + */ +int _setmode(int fd, int newmode) +{ + int prevmode; + + TRACE("_setmode(%d, %d)", fd, newmode); + + if (!is_valid_fd(fd)) + { + DPRINT1("_setmode: inval fd (%d)\n",fd); + //errno = EBADF; + return(-1); + } + + if (newmode & ~(_O_TEXT|_O_BINARY)) + { + DPRINT1("_setmode: fd (%d) mode (0x%08x) unknown\n",fd,newmode); + /* FIXME: Should we fail with EINVAL here? */ + } + + prevmode = fdinfo(fd)->fdflags & FTEXT ? _O_TEXT : _O_BINARY; + + if ((newmode & _O_TEXT) == _O_TEXT) + { + fdinfo(fd)->fdflags |= FTEXT; + } + else + { + /* FIXME: If both _O_TEXT and _O_BINARY are set, we get here. + * Should we fail with EINVAL instead? -Gunnar + */ + fdinfo(fd)->fdflags &= ~FTEXT; + } + + return(prevmode); +} + diff --git a/reactos/lib/crt/io/pipe.c b/reactos/lib/crt/io/pipe.c index d0fdb0247a7..fec88f74bf2 100644 --- a/reactos/lib/crt/io/pipe.c +++ b/reactos/lib/crt/io/pipe.c @@ -10,9 +10,12 @@ */ #include "precomp.h" -#include -#include -#include +#include +#include +#include + +#define NDEBUG +#include /* @@ -23,29 +26,31 @@ int _pipe(int _fildes[2], unsigned int size, int mode ) HANDLE hReadPipe, hWritePipe; SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; + TRACE("_pipe((%i,%i), %ui, %i)", _fildes[0], _fildes[1], size, mode); + if (mode & O_NOINHERIT) sa.bInheritHandle = FALSE; if (!CreatePipe(&hReadPipe,&hWritePipe,&sa,size)) { _dosmaperr(GetLastError()); - return -1; + return( -1); } - if ((_fildes[0] = __fileno_alloc(hReadPipe, mode)) < 0) + if ((_fildes[0] = alloc_fd(hReadPipe, split_oflags(mode))) < 0) { CloseHandle(hReadPipe); CloseHandle(hWritePipe); __set_errno(EMFILE); - return -1; + return(-1); } - if ((_fildes[1] = __fileno_alloc(hWritePipe, mode)) < 0) + if ((_fildes[1] = alloc_fd(hWritePipe, split_oflags(mode))) < 0) { - __fileno_close(_fildes[0]); + free_fd(_fildes[0]); CloseHandle(hReadPipe); CloseHandle(hWritePipe); __set_errno(EMFILE); - return -1; + return(-1); } - return 0; + return(0); } diff --git a/reactos/lib/crt/io/read.c b/reactos/lib/crt/io/read.c index 6e9229df1e8..a89275bf08a 100644 --- a/reactos/lib/crt/io/read.c +++ b/reactos/lib/crt/io/read.c @@ -13,16 +13,16 @@ */ #include -#include -#include +#include +#include #define NDEBUG -#include +#include /* * @implemented */ -size_t _read(int _fd, void *_buf, size_t _nbyte) +int _read(int _fd, void *_buf, unsigned int _nbyte) { DWORD _rbyte = 0, nbyte = _nbyte; char *bufp = (char*)_buf; @@ -35,7 +35,7 @@ size_t _read(int _fd, void *_buf, size_t _nbyte) if(_nbyte == 0) return 0; - hfile = _get_osfhandle(_fd); + hfile = (HANDLE)_get_osfhandle(_fd); istext = __fileno_getmode(_fd) & O_TEXT; /* read data */ diff --git a/reactos/lib/crt/io/setmode.c b/reactos/lib/crt/io/setmode.c index a64c9394fc7..b774018e606 100644 --- a/reactos/lib/crt/io/setmode.c +++ b/reactos/lib/crt/io/setmode.c @@ -9,19 +9,11 @@ * 28/12/98: Created */ -#include -#include -#include +#include +#include +#include #define NDEBUG -#include +#include -/* - * @implemented - */ -int _setmode(int _fd, int _newmode) -{ - DPRINT("_setmod(fd %d, newmode %x)\n", _fd, _newmode); - return __fileno_setmode(_fd, _newmode); -} diff --git a/reactos/lib/crt/io/sopen.c b/reactos/lib/crt/io/sopen.c index a28f374c256..d454f08a165 100644 --- a/reactos/lib/crt/io/sopen.c +++ b/reactos/lib/crt/io/sopen.c @@ -1,10 +1,11 @@ -#include +#include /* * @implemented */ -int _sopen(char *path, int access, int shflag, int mode) +int _sopen(const char *path, int access, int shflag, ... /*mode, permissin*/) { - return _open((path), (access)|(shflag), (mode)); + //FIXME: vararg + return _open((path), (access)|(shflag));//, (mode)); } diff --git a/reactos/lib/crt/io/tell.c b/reactos/lib/crt/io/tell.c index b21c29b4fb9..e12150c487b 100644 --- a/reactos/lib/crt/io/tell.c +++ b/reactos/lib/crt/io/tell.c @@ -1,6 +1,7 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include +#include /* diff --git a/reactos/lib/crt/io/telli64.c b/reactos/lib/crt/io/telli64.c index 9f584d8931d..1982ed167af 100644 --- a/reactos/lib/crt/io/telli64.c +++ b/reactos/lib/crt/io/telli64.c @@ -1,5 +1,6 @@ -#include -#include +#include +#include +#include /* diff --git a/reactos/lib/crt/io/umask.c b/reactos/lib/crt/io/umask.c index 58bc2f12db8..28a498ff1eb 100644 --- a/reactos/lib/crt/io/umask.c +++ b/reactos/lib/crt/io/umask.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include unsigned _unMode_dll = 022; diff --git a/reactos/lib/crt/io/unlink.c b/reactos/lib/crt/io/unlink.c index 48e777f233a..947b27256c7 100644 --- a/reactos/lib/crt/io/unlink.c +++ b/reactos/lib/crt/io/unlink.c @@ -9,10 +9,11 @@ */ #include "precomp.h" -#include +#include +#include #define NDEBUG -#include +#include /* diff --git a/reactos/lib/crt/io/utime.c b/reactos/lib/crt/io/utime.c index 326e1fdae1e..e43aef42b94 100644 --- a/reactos/lib/crt/io/utime.c +++ b/reactos/lib/crt/io/utime.c @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/io/waccess.c b/reactos/lib/crt/io/waccess.c index eb673ba14db..0ad50babfe8 100644 --- a/reactos/lib/crt/io/waccess.c +++ b/reactos/lib/crt/io/waccess.c @@ -1,32 +1,4 @@ -#include "precomp.h" -#include -#include -#define NDEBUG -#include +#define UNICODE +#define _UNICODE - -/* - * @implemented - */ -int _waccess(const wchar_t *_path, int _amode) -{ - DWORD Attributes = GetFileAttributesW(_path); - - if (Attributes == -1) { - _dosmaperr(GetLastError()); - return -1; - } - if ((_amode & W_OK) == W_OK) { - if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) { - __set_errno(EACCES); - return -1; - } - } - if ((_amode & D_OK) == D_OK) { - if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { - __set_errno(EACCES); - return -1; - } - } - return 0; -} +#include "access.c" diff --git a/reactos/lib/crt/io/wchmod.c b/reactos/lib/crt/io/wchmod.c index a4df3ed67c0..1a81c9e2a41 100644 --- a/reactos/lib/crt/io/wchmod.c +++ b/reactos/lib/crt/io/wchmod.c @@ -1,47 +1,4 @@ -#include "precomp.h" -#include +#define _UNICODE +#define UNICODE -#define NDEBUG -#include - -#define mode_t int - - -/* - * @implemented - */ -int _wchmod(const wchar_t* filename, mode_t mode) -{ - DWORD FileAttributes = 0; - BOOLEAN Set = FALSE; - - DPRINT("_wchmod('%S', %x)\n", filename, mode); - - FileAttributes = GetFileAttributesW(filename); - if ( FileAttributes == -1 ) { - _dosmaperr(GetLastError()); - return -1; - } - - if ( mode == 0 ) - return -1; - - if (mode & _S_IWRITE) { - if (FileAttributes & FILE_ATTRIBUTE_READONLY) { - FileAttributes &= ~FILE_ATTRIBUTE_READONLY; - Set = TRUE; - } - } else { - if (!(FileAttributes & FILE_ATTRIBUTE_READONLY)) { - FileAttributes |= FILE_ATTRIBUTE_READONLY; - Set = TRUE; - } - } - - if (Set && SetFileAttributesW(filename, FileAttributes) == FALSE) { - _dosmaperr(GetLastError()); - return -1; - } - - return 0; -} +#include "chmod.c" diff --git a/reactos/lib/crt/io/wcreate.c b/reactos/lib/crt/io/wcreate.c index b61d88f9e36..305d836c23d 100644 --- a/reactos/lib/crt/io/wcreate.c +++ b/reactos/lib/crt/io/wcreate.c @@ -1,8 +1,8 @@ -#include -#include +#include +#include #define NDEBUG -#include +#include /* diff --git a/reactos/lib/crt/io/wfind.c b/reactos/lib/crt/io/wfind.c index 4ade252ae3f..76c568f6c0e 100644 --- a/reactos/lib/crt/io/wfind.c +++ b/reactos/lib/crt/io/wfind.c @@ -1,226 +1,5 @@ -#include "precomp.h" -#include -#include -#include +#define UNICODE +#define _UNICODE -/* - * @implemented - */ -int _wfindfirst(const wchar_t* _name, struct _wfinddata_t* result) -{ - WIN32_FIND_DATAW FindFileData; - wchar_t dir[MAX_PATH]; - long hFindFile; - int len = 0; - - if ( _name == NULL || _name[0] == 0 ) { - len = GetCurrentDirectoryW(MAX_PATH-4, dir); - if (dir[len-1] != L'\\') { - dir[len] = L'\\'; - dir[len+1] = 0; - } - wcscat(dir, L"*.*"); - } else { - wcscpy(dir, _name); - } - - hFindFile = (long)FindFirstFileW(dir, &FindFileData); - if (hFindFile == -1) { - memset(result,0,sizeof(struct _wfinddata_t)); - _dosmaperr(GetLastError()); - return -1; - } - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = FindFileData.nFileSizeLow; - wcsncpy(result->name,FindFileData.cFileName,MAX_PATH); - - // if no wildcard the find file handle can be closed right away - // a return value of 0 can flag this. - if (!wcschr(dir, L'*') && !wcschr(dir, L'?')) { - _findclose(hFindFile); - return 0; - } - - return hFindFile; -} - -/* - * @implemented - */ -int _findfirsti64(const char *_name, struct _finddatai64_t *result) -{ - WIN32_FIND_DATAA FindFileData; - char dir[MAX_PATH]; - long hFindFile; - int len = 0; - - if ( _name == NULL || _name[0] == 0 ) - { - len = GetCurrentDirectoryA(MAX_PATH-4,dir); - if (dir[len-1] != '\\') - { - dir[len] = '\\'; - dir[len+1] = 0; - } - strcat(dir, "*.*"); - } - else - strcpy(dir, _name); - - hFindFile = (long)FindFirstFileA(dir, &FindFileData); - if (hFindFile == -1) - { - memset(result,0,sizeof(struct _finddatai64_t)); - _dosmaperr(GetLastError()); - return -1; - } - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = - (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow; - strncpy(result->name,FindFileData.cFileName,MAX_PATH); - - // if no wildcard the find file handle can be closed right away - // a return value of 0 can flag this. - - if (!strchr(dir,'*') && !strchr(dir,'?')) { - _findclose(hFindFile); - return 0; - } - return hFindFile; -} - -/* - * @implemented - */ -int _findnexti64(int handle, struct _finddatai64_t *result) -{ - WIN32_FIND_DATAA FindFileData; - - // check no wildcards or invalid handle - if (handle == 0 || handle == -1) - return 0; - - if (!FindNextFileA((void *)handle, &FindFileData)) { - _dosmaperr(GetLastError()); - return -1; - } - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = - (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow; - strncpy(result->name,FindFileData.cFileName,MAX_PATH); - - return 0; -} - -/* - * @implemented - */ -int _wfindfirsti64(const wchar_t *_name, struct _wfinddatai64_t *result) -{ - WIN32_FIND_DATAW FindFileData; - wchar_t dir[MAX_PATH]; - long hFindFile; - int len = 0; - - if (_name == NULL || _name[0] == 0) - { - len = GetCurrentDirectoryW(MAX_PATH-4,dir); - if (dir[len-1] != L'\\') - { - dir[len] = L'\\'; - dir[len+1] = 0; - } - wcscat(dir, L"*.*"); - } - else - wcscpy(dir, _name); - - hFindFile = (long)FindFirstFileW(dir, &FindFileData); - if (hFindFile == -1) - { - memset(result,0,sizeof(struct _wfinddatai64_t)); - _dosmaperr(GetLastError()); - return -1; - } - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = - (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow; - wcsncpy(result->name,FindFileData.cFileName,MAX_PATH); - - // if no wildcard the find file handle can be closed right away - // a return value of 0 can flag this. - - if (!wcschr(dir,L'*') && !wcschr(dir,L'?')) - { - _findclose(hFindFile); - return 0; - } - - return hFindFile; -} - -/* - * @implemented - */ -int _wfindnext(int handle, struct _wfinddata_t *result) -{ - WIN32_FIND_DATAW FindFileData; - - // check no wildcards or invalid handle - if (handle == 0 || handle == -1) - return 0; - - if (!FindNextFileW((void *)handle, &FindFileData)) - return -1; - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = FindFileData.nFileSizeLow; - wcsncpy(result->name,FindFileData.cFileName, MAX_PATH); - - return 0; -} - -/* - * @implemented - */ -int _wfindnexti64(int handle, struct _wfinddatai64_t *result) -{ - WIN32_FIND_DATAW FindFileData; - - // check no wildcards or invalid handle - if (handle == 0 || handle == -1) - return 0; - - if (!FindNextFileW((void *)handle, &FindFileData)) - return -1; - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = - (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow; - wcsncpy(result->name,FindFileData.cFileName,MAX_PATH); - - return 0; -} +#include "find.c" diff --git a/reactos/lib/crt/io/wmktemp.c b/reactos/lib/crt/io/wmktemp.c index 75edf72bbe9..9978878861e 100644 --- a/reactos/lib/crt/io/wmktemp.c +++ b/reactos/lib/crt/io/wmktemp.c @@ -13,12 +13,12 @@ /* 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 #define NDEBUG -#include +#include /* diff --git a/reactos/lib/crt/io/wopen.c b/reactos/lib/crt/io/wopen.c index f5c2fa398da..c804539fd44 100644 --- a/reactos/lib/crt/io/wopen.c +++ b/reactos/lib/crt/io/wopen.c @@ -14,19 +14,19 @@ #include "precomp.h" #if !defined(NDEBUG) && defined(DBG) -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #define NDEBUG -#include +#include /* @@ -136,13 +136,14 @@ int _wopen(const wchar_t* _path, int _oflag, ...) _dosmaperr(GetLastError()); return -1; } - return __fileno_alloc(hFile,_oflag); + return alloc_fd(hFile,split_oflags(_oflag)); } /* * @implemented */ -int _wsopen(wchar_t* path, int access, int shflag, int mode) +int _wsopen(const wchar_t* path, int access, int shflag,.../* int mode*/) { - return _wopen((path), (access)|(shflag), (mode)); + //FIXME: vararg + return _wopen((path), (access)|(shflag));//, (mode)); } diff --git a/reactos/lib/crt/io/write.c b/reactos/lib/crt/io/write.c index f17924ee955..0387fbde214 100644 --- a/reactos/lib/crt/io/write.c +++ b/reactos/lib/crt/io/write.c @@ -9,14 +9,14 @@ */ #include "precomp.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define NDEBUG -#include +#include #define BUFSIZE 4096 /* @@ -38,7 +38,7 @@ void ReportLastError(void) /* * @implemented */ -size_t _write(int _fd, const void* _buf, size_t _nbyte) +int _write(int _fd, const void* _buf, unsigned int _nbyte) { char *tmp, *in, *out; int result; @@ -61,7 +61,7 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte) *out++ = 0x0d; count--; if (count == 0) { - if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE, &wbyte, NULL)) { + if (!WriteFile((HANDLE)_get_osfhandle(_fd), tmp, BUFSIZE, &wbyte, NULL)) { //ReportLastError(); _dosmaperr(GetLastError()); result = -1; @@ -78,7 +78,7 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte) *out++ = *in++; count--; if (count == 0 || _nbyte == 0) { - if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE - count, &wbyte, NULL)) { + if (!WriteFile((HANDLE)_get_osfhandle(_fd), tmp, BUFSIZE - count, &wbyte, NULL)) { _dosmaperr(GetLastError()); result = -1; break; @@ -94,7 +94,7 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte) free(tmp); return result; } else { - if(!WriteFile(_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL)) { + if(!WriteFile((HANDLE)_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL)) { _dosmaperr(GetLastError()); return -1; } diff --git a/reactos/lib/crt/io/wunlink.c b/reactos/lib/crt/io/wunlink.c index c59186ddc58..00420a5b9a2 100644 --- a/reactos/lib/crt/io/wunlink.c +++ b/reactos/lib/crt/io/wunlink.c @@ -9,11 +9,11 @@ */ #include "precomp.h" -#include +#include +#include #define NDEBUG -#include -#include +#include /* * @implemented diff --git a/reactos/lib/crt/io/wutime.c b/reactos/lib/crt/io/wutime.c index 452769b884a..ef229923e97 100644 --- a/reactos/lib/crt/io/wutime.c +++ b/reactos/lib/crt/io/wutime.c @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/locale/locale.c b/reactos/lib/crt/locale/locale.c index 3486b70eb98..c3b21ddd6c0 100644 --- a/reactos/lib/crt/locale/locale.c +++ b/reactos/lib/crt/locale/locale.c @@ -5,15 +5,15 @@ */ #include "precomp.h" -#include -#include -#include +#include +#include +#include #include -#include -#include +#include +#include #define NDEBUG -#include +#include unsigned int __setlc_active; unsigned int __unguarded_readlc_active; diff --git a/reactos/lib/crt/makefile b/reactos/lib/crt/makefile index 053fc66731a..cd743ddcd9b 100644 --- a/reactos/lib/crt/makefile +++ b/reactos/lib/crt/makefile @@ -10,11 +10,14 @@ TARGET_NAME = crt TARGET_PCH = precomp.h -TARGET_CFLAGS = -D_MSVCRT_LIB_ -Wall -Werror +TARGET_CFLAGS = -D_MSVCRT_LIB_ -D__MSVCRT__ -Wall -Werror -I./include + +#-nostdinc # require os code to explicitly request A/W version of structs/functions TARGET_CFLAGS += \ -D_DISABLE_TIDENTS \ + -D__MINGW_IMPORT=extern \ -D__USE_W32API \ -D__REACTOS__ \ -D_WIN32_IE=0x600 \ @@ -26,7 +29,6 @@ CONIO_OBJECTS = \ conio/cgets.o \ conio/cprintf.o \ conio/cputs.o \ - conio/cscanf.o \ conio/getch.o \ conio/getche.o \ conio/kbhit.o \ @@ -238,6 +240,7 @@ PROCESS_OBJECTS = \ process/_system.o \ process/dll.o \ process/process.o \ + process/wprocess.o \ process/procid.o \ process/thread.o \ process/threadid.o \ @@ -275,12 +278,14 @@ STDIO_OBJECTS = \ stdio/fputc.o \ stdio/fputchar.o \ stdio/fputs.o \ + stdio/fputws.o \ stdio/fread.o \ stdio/freopen.o \ - stdio/fscanf.o \ + stdio/wfreopen.o \ stdio/fseek.o \ stdio/fsetpos.o \ stdio/fsopen.o \ + stdio/wfsopen.o \ stdio/ftell.o \ stdio/fwalk.o \ stdio/fwrite.o \ @@ -290,32 +295,35 @@ STDIO_OBJECTS = \ stdio/getw.o \ stdio/perror.o \ stdio/popen.o \ + stdio/wpopen.o \ stdio/printf.o \ + stdio/wprintf.o \ stdio/putc.o \ stdio/putchar.o \ + stdio/putwchar.o \ stdio/puts.o \ stdio/putw.o \ stdio/remove.o \ + stdio/wremove.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/swprintf.o \ stdio/stdhnd.o \ stdio/tempnam.o \ stdio/tmpfile.o \ stdio/tmpnam.o \ stdio/ungetc.o \ + stdio/ungetwc.o \ stdio/vfprintf.o \ - stdio/vfscanf.o \ stdio/vfwprint.o \ stdio/vprintf.o \ - stdio/vscanf.o \ + stdio/vwprintf.o \ stdio/vsprintf.o \ - stdio/vsscanf.o \ + stdio/vswprintf.o \ stdio/wfdopen.o \ stdio/wrename.o \ stdio/wtempnam.o \ @@ -330,6 +338,7 @@ STDLIB_OBJECTS = \ stdlib/atoi.o \ stdlib/atoi64.o \ stdlib/atol.o \ + stdlib/wtol.o \ stdlib/bsearch.o \ stdlib/div.o \ stdlib/ecvt.o \ @@ -437,7 +446,8 @@ WINE_OBJECTS = \ wine/cpp.o \ wine/cppexcept.o \ wine/heap.o \ - wine/thread.o + wine/thread.o \ + wine/scanf.o TARGET_OBJECTS = \ $(CONIO_OBJECTS) \ diff --git a/reactos/lib/crt/math/acos.c b/reactos/lib/crt/math/acos.c index 23376a6116c..ea25c1cabec 100644 --- a/reactos/lib/crt/math/acos.c +++ b/reactos/lib/crt/math/acos.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double acos(double __x) diff --git a/reactos/lib/crt/math/asin.c b/reactos/lib/crt/math/asin.c index fa57df2850c..5a64723ba38 100644 --- a/reactos/lib/crt/math/asin.c +++ b/reactos/lib/crt/math/asin.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double asin(double __x) diff --git a/reactos/lib/crt/math/atan.c b/reactos/lib/crt/math/atan.c index af0e219e728..7c5adcf3466 100644 --- a/reactos/lib/crt/math/atan.c +++ b/reactos/lib/crt/math/atan.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double atan (double __x); diff --git a/reactos/lib/crt/math/atan2.c b/reactos/lib/crt/math/atan2.c index 8ce57f1e433..8a24a3fadae 100644 --- a/reactos/lib/crt/math/atan2.c +++ b/reactos/lib/crt/math/atan2.c @@ -1,5 +1,5 @@ -#include +#include double atan2 (double __y, double __x); diff --git a/reactos/lib/crt/math/cabs.c b/reactos/lib/crt/math/cabs.c index ca9e8426c73..04a0bc578bc 100644 --- a/reactos/lib/crt/math/cabs.c +++ b/reactos/lib/crt/math/cabs.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/math/ceil.c b/reactos/lib/crt/math/ceil.c index 5a1b1113910..43dd120bad8 100644 --- a/reactos/lib/crt/math/ceil.c +++ b/reactos/lib/crt/math/ceil.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/math/cos.c b/reactos/lib/crt/math/cos.c index 131fa2dbdb0..95657c6e884 100644 --- a/reactos/lib/crt/math/cos.c +++ b/reactos/lib/crt/math/cos.c @@ -1,4 +1,4 @@ -#include +#include double cos (double __x); diff --git a/reactos/lib/crt/math/cosh.c b/reactos/lib/crt/math/cosh.c index a21e717cadc..e81fde563f8 100644 --- a/reactos/lib/crt/math/cosh.c +++ b/reactos/lib/crt/math/cosh.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* diff --git a/reactos/lib/crt/math/exp.c b/reactos/lib/crt/math/exp.c index 2707cf8ca3a..3a58be07ad8 100644 --- a/reactos/lib/crt/math/exp.c +++ b/reactos/lib/crt/math/exp.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double exp (double __x); diff --git a/reactos/lib/crt/math/fabs.c b/reactos/lib/crt/math/fabs.c index 5db505ad11b..3c61ab1ad17 100644 --- a/reactos/lib/crt/math/fabs.c +++ b/reactos/lib/crt/math/fabs.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double fabs (double __x); diff --git a/reactos/lib/crt/math/floor.c b/reactos/lib/crt/math/floor.c index 4635ad86b3f..684b7163c82 100644 --- a/reactos/lib/crt/math/floor.c +++ b/reactos/lib/crt/math/floor.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double floor (double __x); diff --git a/reactos/lib/crt/math/fmod.c b/reactos/lib/crt/math/fmod.c index 263d6878829..f1d6cb31dd5 100644 --- a/reactos/lib/crt/math/fmod.c +++ b/reactos/lib/crt/math/fmod.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double fmod (double __x, double __y); diff --git a/reactos/lib/crt/math/frexp.c b/reactos/lib/crt/math/frexp.c index 47e1800c98d..0b753e15969 100644 --- a/reactos/lib/crt/math/frexp.c +++ b/reactos/lib/crt/math/frexp.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/math/huge_val.c b/reactos/lib/crt/math/huge_val.c index aaa50d0e81e..66b5716bf80 100644 --- a/reactos/lib/crt/math/huge_val.c +++ b/reactos/lib/crt/math/huge_val.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include #undef _HUGE double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 }; diff --git a/reactos/lib/crt/math/hypot.c b/reactos/lib/crt/math/hypot.c index de078a140e8..18aefb51ea6 100644 --- a/reactos/lib/crt/math/hypot.c +++ b/reactos/lib/crt/math/hypot.c @@ -16,9 +16,9 @@ * */ -#include -#include -#include +#include +#include +#include /* Approximate square roots of DBL_MAX and DBL_MIN. Numbers between these two shouldn't neither overflow nor underflow diff --git a/reactos/lib/crt/math/j0_y0.c b/reactos/lib/crt/math/j0_y0.c index 01143ef3dcc..fd0923291aa 100644 --- a/reactos/lib/crt/math/j0_y0.c +++ b/reactos/lib/crt/math/j0_y0.c @@ -1,4 +1,4 @@ -#include +#include /* diff --git a/reactos/lib/crt/math/j1_y1.c b/reactos/lib/crt/math/j1_y1.c index 3c899886491..46c8d28567f 100644 --- a/reactos/lib/crt/math/j1_y1.c +++ b/reactos/lib/crt/math/j1_y1.c @@ -1,4 +1,4 @@ -#include +#include /* diff --git a/reactos/lib/crt/math/jn_yn.c b/reactos/lib/crt/math/jn_yn.c index a9304720a2e..89fbbdc66ff 100644 --- a/reactos/lib/crt/math/jn_yn.c +++ b/reactos/lib/crt/math/jn_yn.c @@ -1,4 +1,4 @@ -#include +#include /* diff --git a/reactos/lib/crt/math/ldexp.c b/reactos/lib/crt/math/ldexp.c index 9c603445509..ee2182161de 100644 --- a/reactos/lib/crt/math/ldexp.c +++ b/reactos/lib/crt/math/ldexp.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double ldexp (double __x, int __y); diff --git a/reactos/lib/crt/math/log.c b/reactos/lib/crt/math/log.c index 014c78a2304..bb1e524f520 100644 --- a/reactos/lib/crt/math/log.c +++ b/reactos/lib/crt/math/log.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double log (double __x); diff --git a/reactos/lib/crt/math/log10.c b/reactos/lib/crt/math/log10.c index 58e8cd6ebc9..5ed37f2a894 100644 --- a/reactos/lib/crt/math/log10.c +++ b/reactos/lib/crt/math/log10.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double log10 (double __x); diff --git a/reactos/lib/crt/math/math.c b/reactos/lib/crt/math/math.c index 157b72fd9b8..ff1d0e266f9 100644 --- a/reactos/lib/crt/math/math.c +++ b/reactos/lib/crt/math/math.c @@ -1,4 +1,4 @@ -#include +#include #pragma function(fmod,sqrt) #pragma function(log,log10,pow,exp) diff --git a/reactos/lib/crt/math/modf.c b/reactos/lib/crt/math/modf.c index fe1d80f4d02..2b7102657e2 100644 --- a/reactos/lib/crt/math/modf.c +++ b/reactos/lib/crt/math/modf.c @@ -10,10 +10,10 @@ * ==================================================== */ -#include -#include -#include - +#include +#include +#include +#include //static const double one = 1.0; diff --git a/reactos/lib/crt/math/pow.c b/reactos/lib/crt/math/pow.c index 91e07216944..d098efe9225 100644 --- a/reactos/lib/crt/math/pow.c +++ b/reactos/lib/crt/math/pow.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double pow (double __x, double __y); diff --git a/reactos/lib/crt/math/sin.c b/reactos/lib/crt/math/sin.c index db070a31d17..576a4dc3fd8 100644 --- a/reactos/lib/crt/math/sin.c +++ b/reactos/lib/crt/math/sin.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double sin (double __x); diff --git a/reactos/lib/crt/math/sinh.c b/reactos/lib/crt/math/sinh.c index f977a6acfa5..fa9e5f7586d 100644 --- a/reactos/lib/crt/math/sinh.c +++ b/reactos/lib/crt/math/sinh.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/math/sqrt.c b/reactos/lib/crt/math/sqrt.c index d414fcdbc2e..fbae29c9ce2 100644 --- a/reactos/lib/crt/math/sqrt.c +++ b/reactos/lib/crt/math/sqrt.c @@ -17,7 +17,7 @@ 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 +#include double sqrt (double __x); diff --git a/reactos/lib/crt/math/stubs.c b/reactos/lib/crt/math/stubs.c index 82fe881ebc0..c0fd78da106 100644 --- a/reactos/lib/crt/math/stubs.c +++ b/reactos/lib/crt/math/stubs.c @@ -1,4 +1,4 @@ -#include +#include double _CIsin(double x); diff --git a/reactos/lib/crt/math/tan.c b/reactos/lib/crt/math/tan.c index 1acc03619f9..1200eea6459 100644 --- a/reactos/lib/crt/math/tan.c +++ b/reactos/lib/crt/math/tan.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include double tan (double __x); diff --git a/reactos/lib/crt/math/tanh.c b/reactos/lib/crt/math/tanh.c index 88b9acca5ae..8c231c12c3a 100644 --- a/reactos/lib/crt/math/tanh.c +++ b/reactos/lib/crt/math/tanh.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/hanzen.c b/reactos/lib/crt/mbstring/hanzen.c index bbf22611f23..e3b3ac5b0eb 100644 --- a/reactos/lib/crt/mbstring/hanzen.c +++ b/reactos/lib/crt/mbstring/hanzen.c @@ -9,7 +9,7 @@ * 12/04/99: Created */ -#include +#include static unsigned short han_to_zen_ascii_table[0x5f] = { 0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166, diff --git a/reactos/lib/crt/mbstring/ischira.c b/reactos/lib/crt/mbstring/ischira.c index 7ea5d269bcb..7bc938f1963 100644 --- a/reactos/lib/crt/mbstring/ischira.c +++ b/reactos/lib/crt/mbstring/ischira.c @@ -8,8 +8,8 @@ * 12/04/99: Created */ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/mbstring/iskana.c b/reactos/lib/crt/mbstring/iskana.c index 0bdb7848554..a89aa25c44c 100644 --- a/reactos/lib/crt/mbstring/iskana.c +++ b/reactos/lib/crt/mbstring/iskana.c @@ -8,13 +8,14 @@ Modified from Taiji Yamada japanese code system utilities * 12/04/99: Created */ -#include -#include +#include +#include +#include /* * @implemented */ -int _ismbbkana(unsigned char c) +int _ismbbkana(unsigned int c) { - return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_M|_KNJ_P)); + return ((_mbctype+1)[(unsigned char)(c)] & (_KNJ_M|_KNJ_P)); } diff --git a/reactos/lib/crt/mbstring/iskmoji.c b/reactos/lib/crt/mbstring/iskmoji.c index c47d5badec1..a9c01ec0447 100644 --- a/reactos/lib/crt/mbstring/iskmoji.c +++ b/reactos/lib/crt/mbstring/iskmoji.c @@ -1,4 +1,4 @@ -#include +#include int _ismbbkalpha(unsigned char c) { diff --git a/reactos/lib/crt/mbstring/iskpun.c b/reactos/lib/crt/mbstring/iskpun.c index f3a12bbaf1a..bfa0cf2cfb3 100644 --- a/reactos/lib/crt/mbstring/iskpun.c +++ b/reactos/lib/crt/mbstring/iskpun.c @@ -7,12 +7,12 @@ * UPDATE HISTORY: * 12/04/99: Created */ -#include - +#include +#include /* * @implemented */ int _ismbbkpunct( unsigned int c ) { - return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P)); + return ((_mbctype+1)[(unsigned char)(c)] & (_KNJ_P)); } diff --git a/reactos/lib/crt/mbstring/islead.c b/reactos/lib/crt/mbstring/islead.c index f6c9e5bd0e1..98c4a0af28c 100644 --- a/reactos/lib/crt/mbstring/islead.c +++ b/reactos/lib/crt/mbstring/islead.c @@ -1,5 +1,5 @@ #include "precomp.h" -#include +#include /* * @unimplemented diff --git a/reactos/lib/crt/mbstring/islwr.c b/reactos/lib/crt/mbstring/islwr.c index e63c6aa1e3d..84785cb5bd0 100644 --- a/reactos/lib/crt/mbstring/islwr.c +++ b/reactos/lib/crt/mbstring/islwr.c @@ -8,8 +8,8 @@ * 12/04/99: Created */ -#include -#include +#include +#include /* * code page 952 only diff --git a/reactos/lib/crt/mbstring/ismbal.c b/reactos/lib/crt/mbstring/ismbal.c index f1bbd3bbbf6..0a3dc6d0645 100644 --- a/reactos/lib/crt/mbstring/ismbal.c +++ b/reactos/lib/crt/mbstring/ismbal.c @@ -7,13 +7,13 @@ * UPDATE HISTORY: * 12/04/99: Created */ -#include -#include +#include +#include /* * @implemented */ -int _ismbbalpha(unsigned char c) +int _ismbbalpha(unsigned int c) { return (isalpha(c) || _ismbbkalnum(c)); } diff --git a/reactos/lib/crt/mbstring/ismbaln.c b/reactos/lib/crt/mbstring/ismbaln.c index 71d263de87d..ac8948ef3a8 100644 --- a/reactos/lib/crt/mbstring/ismbaln.c +++ b/reactos/lib/crt/mbstring/ismbaln.c @@ -1,11 +1,11 @@ -#include -#include +#include +#include /* * @implemented */ -int _ismbbalnum(unsigned char c) +int _ismbbalnum(unsigned int c) { return (isalnum(c) || _ismbbkalnum(c)); } diff --git a/reactos/lib/crt/mbstring/ismbc.c b/reactos/lib/crt/mbstring/ismbc.c index 4035ff5580d..c19f9441cdb 100644 --- a/reactos/lib/crt/mbstring/ismbc.c +++ b/reactos/lib/crt/mbstring/ismbc.c @@ -1,4 +1,4 @@ -#include +#include int _ismbbalpha(unsigned char c); int _ismbbalnum(unsigned char c); diff --git a/reactos/lib/crt/mbstring/ismbgra.c b/reactos/lib/crt/mbstring/ismbgra.c index 8de506a2007..76afacaa85e 100644 --- a/reactos/lib/crt/mbstring/ismbgra.c +++ b/reactos/lib/crt/mbstring/ismbgra.c @@ -1,11 +1,11 @@ -#include -#include -#include +#include +#include +#include /* * @implemented */ -int _ismbbgraph(unsigned char c) +int _ismbbgraph(unsigned int c) { return (isgraph(c) || _ismbbkana(c)); } diff --git a/reactos/lib/crt/mbstring/ismbkaln.c b/reactos/lib/crt/mbstring/ismbkaln.c index 6840f59a33c..e8b0102f1ca 100644 --- a/reactos/lib/crt/mbstring/ismbkaln.c +++ b/reactos/lib/crt/mbstring/ismbkaln.c @@ -7,13 +7,13 @@ * UPDATE HISTORY: * 12/04/99: Created */ -#include -#include - +#include +#include +#include /* * @implemented */ int _ismbbkalnum( unsigned int c ) { - return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P)); + return ((_mbctype+1)[(unsigned char)(c)] & (_KNJ_P)); } diff --git a/reactos/lib/crt/mbstring/ismblead.c b/reactos/lib/crt/mbstring/ismblead.c index ca6da76883c..e441f0e0798 100644 --- a/reactos/lib/crt/mbstring/ismblead.c +++ b/reactos/lib/crt/mbstring/ismblead.c @@ -9,13 +9,14 @@ * 12/04/99: Created */ -#include -#include -#include +#include +#include +#include +#include size_t _mbclen2(const unsigned int s); -char _jctype[257] = { +unsigned char _mbctype[257] = { /*-1*/ ___, /*0x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, /*1x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, @@ -35,13 +36,13 @@ char _jctype[257] = { /*Fx*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,___,___,___ }; -char *_mbctype = _jctype; +//unsigned char _mbctype = _jctype; /* * @implemented */ int _ismbblead(unsigned int c) { - return ((_jctype+1)[(unsigned char)(c)] & _KNJ_1); + return ((_mbctype+1)[(unsigned char)(c)] & _KNJ_1); } //int _ismbblead(unsigned int byte) //{ diff --git a/reactos/lib/crt/mbstring/ismbpri.c b/reactos/lib/crt/mbstring/ismbpri.c index 637372086b6..b66063bab7c 100644 --- a/reactos/lib/crt/mbstring/ismbpri.c +++ b/reactos/lib/crt/mbstring/ismbpri.c @@ -1,11 +1,11 @@ -#include -#include -#include +#include +#include +#include /* * @implemented */ -int _ismbbprint(unsigned char c) +int _ismbbprint(unsigned int c) { return (isprint(c) || _ismbbkana(c)); } diff --git a/reactos/lib/crt/mbstring/ismbpun.c b/reactos/lib/crt/mbstring/ismbpun.c index f66eb4ea4ec..0c901ff1c5e 100644 --- a/reactos/lib/crt/mbstring/ismbpun.c +++ b/reactos/lib/crt/mbstring/ismbpun.c @@ -1,13 +1,13 @@ -#include -#include -#include +#include +#include +#include /* * @implemented */ -int _ismbbpunct(unsigned char c) +int _ismbbpunct(unsigned int c) { // (0xA1 <= c <= 0xA6) return (ispunct(c) || _ismbbkana(c)); diff --git a/reactos/lib/crt/mbstring/ismbtrl.c b/reactos/lib/crt/mbstring/ismbtrl.c index 865fd4de1b8..3d0cc1de87f 100644 --- a/reactos/lib/crt/mbstring/ismbtrl.c +++ b/reactos/lib/crt/mbstring/ismbtrl.c @@ -8,8 +8,9 @@ * 12/04/99: Created */ -#include -#include +#include +#include +#include size_t _mbclen2(const unsigned int s); @@ -20,7 +21,7 @@ size_t _mbclen2(const unsigned int s); */ int _ismbbtrail(unsigned int c) { - return ((_jctype+1)[(unsigned char)(c)] & _KNJ_2); + return ((_mbctype+1)[(unsigned char)(c)] & _KNJ_2); } //int _ismbbtrail( unsigned int b) diff --git a/reactos/lib/crt/mbstring/isuppr.c b/reactos/lib/crt/mbstring/isuppr.c index d68acc603db..3a9824a2696 100644 --- a/reactos/lib/crt/mbstring/isuppr.c +++ b/reactos/lib/crt/mbstring/isuppr.c @@ -8,8 +8,8 @@ * 12/04/99: Created */ -#include -#include +#include +#include /* * code page 952 only diff --git a/reactos/lib/crt/mbstring/jistojms.c b/reactos/lib/crt/mbstring/jistojms.c index c47b223a58a..bddb6caef00 100644 --- a/reactos/lib/crt/mbstring/jistojms.c +++ b/reactos/lib/crt/mbstring/jistojms.c @@ -1,9 +1,9 @@ -#include +#include /* * @implemented */ -unsigned short _mbcjistojms(unsigned short c) +unsigned int _mbcjistojms(unsigned int c) { int c1, c2; diff --git a/reactos/lib/crt/mbstring/jmstojis.c b/reactos/lib/crt/mbstring/jmstojis.c index cf349f673db..8e634c3e67d 100644 --- a/reactos/lib/crt/mbstring/jmstojis.c +++ b/reactos/lib/crt/mbstring/jmstojis.c @@ -1,9 +1,9 @@ -#include +#include /* * @implemented */ -unsigned short _mbcjmstojis(unsigned short c) +unsigned int _mbcjmstojis(unsigned int c) { int c1, c2; diff --git a/reactos/lib/crt/mbstring/mbbtype.c b/reactos/lib/crt/mbstring/mbbtype.c index e4e02b96546..876c0b284c5 100644 --- a/reactos/lib/crt/mbstring/mbbtype.c +++ b/reactos/lib/crt/mbstring/mbbtype.c @@ -8,8 +8,9 @@ * 12/04/99: Created */ -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbccpy.c b/reactos/lib/crt/mbstring/mbccpy.c index 1db6243c0ae..b48e1261485 100644 --- a/reactos/lib/crt/mbstring/mbccpy.c +++ b/reactos/lib/crt/mbstring/mbccpy.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include size_t _mbclen2(const unsigned int s); diff --git a/reactos/lib/crt/mbstring/mbclen.c b/reactos/lib/crt/mbstring/mbclen.c index d1e4c82ffa6..414852d04b4 100644 --- a/reactos/lib/crt/mbstring/mbclen.c +++ b/reactos/lib/crt/mbstring/mbclen.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/mbstring/mbscat.c b/reactos/lib/crt/mbstring/mbscat.c index 85c6aab86bd..65b481b7f55 100644 --- a/reactos/lib/crt/mbstring/mbscat.c +++ b/reactos/lib/crt/mbstring/mbscat.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbschr.c b/reactos/lib/crt/mbstring/mbschr.c index 5b359bbcb0c..e635e3f1ff7 100644 --- a/reactos/lib/crt/mbstring/mbschr.c +++ b/reactos/lib/crt/mbstring/mbschr.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbscmp.c b/reactos/lib/crt/mbstring/mbscmp.c index 8f5d0b3e4de..611d086cc45 100644 --- a/reactos/lib/crt/mbstring/mbscmp.c +++ b/reactos/lib/crt/mbstring/mbscmp.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbscoll.c b/reactos/lib/crt/mbstring/mbscoll.c index 86265316d94..6ef9f6689ce 100644 --- a/reactos/lib/crt/mbstring/mbscoll.c +++ b/reactos/lib/crt/mbstring/mbscoll.c @@ -8,7 +8,7 @@ * 12/04/99: Created */ -#include +#include int colldif(unsigned short c1, unsigned short c2); diff --git a/reactos/lib/crt/mbstring/mbscpy.c b/reactos/lib/crt/mbstring/mbscpy.c index 89007c27ffc..76abf442c73 100644 --- a/reactos/lib/crt/mbstring/mbscpy.c +++ b/reactos/lib/crt/mbstring/mbscpy.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbscspn.c b/reactos/lib/crt/mbstring/mbscspn.c index da27e5e9960..59936778fc6 100644 --- a/reactos/lib/crt/mbstring/mbscspn.c +++ b/reactos/lib/crt/mbstring/mbscspn.c @@ -1,4 +1,4 @@ -#include +#include /* * FIXME not correct diff --git a/reactos/lib/crt/mbstring/mbsdec.c b/reactos/lib/crt/mbstring/mbsdec.c index 14c228c81c5..e3a72b468d8 100644 --- a/reactos/lib/crt/mbstring/mbsdec.c +++ b/reactos/lib/crt/mbstring/mbsdec.c @@ -1,4 +1,5 @@ -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsdup.c b/reactos/lib/crt/mbstring/mbsdup.c index db251c1c342..2c3617b5ae8 100644 --- a/reactos/lib/crt/mbstring/mbsdup.c +++ b/reactos/lib/crt/mbstring/mbsdup.c @@ -9,8 +9,8 @@ * 12/04/99: Created */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsicmp.c b/reactos/lib/crt/mbstring/mbsicmp.c index 563b2a75dc0..607c794175d 100644 --- a/reactos/lib/crt/mbstring/mbsicmp.c +++ b/reactos/lib/crt/mbstring/mbsicmp.c @@ -7,9 +7,9 @@ * UPDATE HISTORY: * 12/04/99: Created */ -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsicoll.c b/reactos/lib/crt/mbstring/mbsicoll.c index d07f4a6afe6..206fae5750e 100644 --- a/reactos/lib/crt/mbstring/mbsicoll.c +++ b/reactos/lib/crt/mbstring/mbsicoll.c @@ -7,9 +7,9 @@ * UPDATE HISTORY: * 12/04/99: Created */ -#include -#include -#include +#include +#include +#include int colldif(unsigned short c1, unsigned short c2); /* diff --git a/reactos/lib/crt/mbstring/mbsinc.c b/reactos/lib/crt/mbstring/mbsinc.c index 98a5fb5dbd9..c1db061e241 100644 --- a/reactos/lib/crt/mbstring/mbsinc.c +++ b/reactos/lib/crt/mbstring/mbsinc.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbslen.c b/reactos/lib/crt/mbstring/mbslen.c index 8529fbf27f5..f73656fad3e 100644 --- a/reactos/lib/crt/mbstring/mbslen.c +++ b/reactos/lib/crt/mbstring/mbslen.c @@ -1,4 +1,4 @@ -#include +#include size_t _mbclen2(const unsigned int s); diff --git a/reactos/lib/crt/mbstring/mbslwr.c b/reactos/lib/crt/mbstring/mbslwr.c index 071a7659ca1..c5d24cb361f 100644 --- a/reactos/lib/crt/mbstring/mbslwr.c +++ b/reactos/lib/crt/mbstring/mbslwr.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include unsigned int _mbbtolower(unsigned int c) { diff --git a/reactos/lib/crt/mbstring/mbsncat.c b/reactos/lib/crt/mbstring/mbsncat.c index 4eb97b2349b..78a23e49af0 100644 --- a/reactos/lib/crt/mbstring/mbsncat.c +++ b/reactos/lib/crt/mbstring/mbsncat.c @@ -8,8 +8,8 @@ * 12/04/99: Created */ -#include -#include +#include +#include size_t _mbclen2(const unsigned int s); diff --git a/reactos/lib/crt/mbstring/mbsnccnt.c b/reactos/lib/crt/mbstring/mbsnccnt.c index af739200fd0..b66a3171fb9 100644 --- a/reactos/lib/crt/mbstring/mbsnccnt.c +++ b/reactos/lib/crt/mbstring/mbsnccnt.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsncmp.c b/reactos/lib/crt/mbstring/mbsncmp.c index d108898a438..3f8dfa8200d 100644 --- a/reactos/lib/crt/mbstring/mbsncmp.c +++ b/reactos/lib/crt/mbstring/mbsncmp.c @@ -8,7 +8,7 @@ * 12/04/99: Created */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsncoll.c b/reactos/lib/crt/mbstring/mbsncoll.c index f9af6ebce83..10b08e193d8 100644 --- a/reactos/lib/crt/mbstring/mbsncoll.c +++ b/reactos/lib/crt/mbstring/mbsncoll.c @@ -7,7 +7,7 @@ * UPDATE HISTORY: * 12/04/99: Created */ -#include +#include int colldif(unsigned short c1, unsigned short c2); diff --git a/reactos/lib/crt/mbstring/mbsncpy.c b/reactos/lib/crt/mbstring/mbsncpy.c index 5b4a2c9238d..3f236f598ae 100644 --- a/reactos/lib/crt/mbstring/mbsncpy.c +++ b/reactos/lib/crt/mbstring/mbsncpy.c @@ -8,7 +8,7 @@ * 12/04/99: Created */ -#include +#include /* diff --git a/reactos/lib/crt/mbstring/mbsnextc.c b/reactos/lib/crt/mbstring/mbsnextc.c index 4e163daabc3..ee75c6f915c 100644 --- a/reactos/lib/crt/mbstring/mbsnextc.c +++ b/reactos/lib/crt/mbstring/mbsnextc.c @@ -1,4 +1,5 @@ -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsnicmp.c b/reactos/lib/crt/mbstring/mbsnicmp.c index 0ece47523f9..0a554b2176c 100644 --- a/reactos/lib/crt/mbstring/mbsnicmp.c +++ b/reactos/lib/crt/mbstring/mbsnicmp.c @@ -1,4 +1,4 @@ -#include +#include size_t _mbclen2(const unsigned int s); diff --git a/reactos/lib/crt/mbstring/mbsnicoll.c b/reactos/lib/crt/mbstring/mbsnicoll.c index df778069f92..bfc67e5e1df 100644 --- a/reactos/lib/crt/mbstring/mbsnicoll.c +++ b/reactos/lib/crt/mbstring/mbsnicoll.c @@ -1,4 +1,4 @@ -#include +#include /* * @unimplemented diff --git a/reactos/lib/crt/mbstring/mbsninc.c b/reactos/lib/crt/mbstring/mbsninc.c index bf8a50caf5b..67f2fac2c87 100644 --- a/reactos/lib/crt/mbstring/mbsninc.c +++ b/reactos/lib/crt/mbstring/mbsninc.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsnset.c b/reactos/lib/crt/mbstring/mbsnset.c index 37be2754ffc..ae6a4603fa8 100644 --- a/reactos/lib/crt/mbstring/mbsnset.c +++ b/reactos/lib/crt/mbstring/mbsnset.c @@ -7,7 +7,7 @@ * UPDATE HISTORY: * 12/04/99: Created */ -#include +#include size_t _mbclen2(const unsigned int s); diff --git a/reactos/lib/crt/mbstring/mbspbrk.c b/reactos/lib/crt/mbstring/mbspbrk.c index ed0b9d4b6de..83b5b1085be 100644 --- a/reactos/lib/crt/mbstring/mbspbrk.c +++ b/reactos/lib/crt/mbstring/mbspbrk.c @@ -1,4 +1,5 @@ -#include +#include +#include int isleadbyte(int byte); diff --git a/reactos/lib/crt/mbstring/mbsrchr.c b/reactos/lib/crt/mbstring/mbsrchr.c index c0f66f36376..dfab3cdd7ea 100644 --- a/reactos/lib/crt/mbstring/mbsrchr.c +++ b/reactos/lib/crt/mbstring/mbsrchr.c @@ -7,8 +7,8 @@ * UPDATE HISTORY: * 12/04/99: Created */ - -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsrev.c b/reactos/lib/crt/mbstring/mbsrev.c index f30cb10cd04..bde5bdc11e4 100644 --- a/reactos/lib/crt/mbstring/mbsrev.c +++ b/reactos/lib/crt/mbstring/mbsrev.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsset.c b/reactos/lib/crt/mbstring/mbsset.c index d2af4d13264..ae09717fc5c 100644 --- a/reactos/lib/crt/mbstring/mbsset.c +++ b/reactos/lib/crt/mbstring/mbsset.c @@ -8,7 +8,7 @@ * 12/04/99: Created */ -#include +#include size_t _mbclen2(const unsigned int s); diff --git a/reactos/lib/crt/mbstring/mbsspn.c b/reactos/lib/crt/mbstring/mbsspn.c index 0eb8ec0238d..3d654feb0a7 100644 --- a/reactos/lib/crt/mbstring/mbsspn.c +++ b/reactos/lib/crt/mbstring/mbsspn.c @@ -1,4 +1,4 @@ -#include +#include /* * FIXME not correct diff --git a/reactos/lib/crt/mbstring/mbsspnp.c b/reactos/lib/crt/mbstring/mbsspnp.c index c82fcf8b9ca..07a698ae443 100644 --- a/reactos/lib/crt/mbstring/mbsspnp.c +++ b/reactos/lib/crt/mbstring/mbsspnp.c @@ -1,4 +1,4 @@ -#include +#include /* * FIXME not correct diff --git a/reactos/lib/crt/mbstring/mbsstr.c b/reactos/lib/crt/mbstring/mbsstr.c index cbf9f396925..318de319c70 100644 --- a/reactos/lib/crt/mbstring/mbsstr.c +++ b/reactos/lib/crt/mbstring/mbsstr.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbstok.c b/reactos/lib/crt/mbstring/mbstok.c index 79015a8b787..d575e73f3f5 100644 --- a/reactos/lib/crt/mbstring/mbstok.c +++ b/reactos/lib/crt/mbstring/mbstok.c @@ -1,9 +1,10 @@ -#include +#include +#include /* * @implemented */ -unsigned char * _mbstok(unsigned char *s, unsigned char *delim) +unsigned char * _mbstok(unsigned char *s, const unsigned char *delim) { const unsigned char *spanp; int c, sc; diff --git a/reactos/lib/crt/mbstring/mbstrlen.c b/reactos/lib/crt/mbstring/mbstrlen.c index b8c64cce6f1..e4411f1f708 100644 --- a/reactos/lib/crt/mbstring/mbstrlen.c +++ b/reactos/lib/crt/mbstring/mbstrlen.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/mbstring/mbsupr.c b/reactos/lib/crt/mbstring/mbsupr.c index 1899b7fcc3c..6cb5059010c 100644 --- a/reactos/lib/crt/mbstring/mbsupr.c +++ b/reactos/lib/crt/mbstring/mbsupr.c @@ -7,8 +7,8 @@ * UPDATE HISTORY: * 12/04/99: Created */ -#include -#include +#include +#include unsigned int _mbbtoupper(unsigned int c) { diff --git a/reactos/lib/crt/misc/amsg.c b/reactos/lib/crt/misc/amsg.c index b8b288afa23..a65b6675bef 100644 --- a/reactos/lib/crt/misc/amsg.c +++ b/reactos/lib/crt/misc/amsg.c @@ -8,8 +8,8 @@ * 28/12/98: Created */ -#include -#include +#include +#include static char *__rt_err_msg[] = diff --git a/reactos/lib/crt/misc/assert.c b/reactos/lib/crt/misc/assert.c index 0e416a894c7..f656976da1d 100644 --- a/reactos/lib/crt/misc/assert.c +++ b/reactos/lib/crt/misc/assert.c @@ -1,8 +1,8 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/misc/crtmain.c b/reactos/lib/crt/misc/crtmain.c index 61f66686c1b..5387202824b 100644 --- a/reactos/lib/crt/misc/crtmain.c +++ b/reactos/lib/crt/misc/crtmain.c @@ -6,7 +6,7 @@ #include "precomp.h" #define NDEBUG -#include +#include #ifndef __GNUC__ diff --git a/reactos/lib/crt/misc/environ.c b/reactos/lib/crt/misc/environ.c index 7847d2aa3bf..d99b3695657 100644 --- a/reactos/lib/crt/misc/environ.c +++ b/reactos/lib/crt/misc/environ.c @@ -6,12 +6,13 @@ */ #include "precomp.h" -#include -#include -#include +#include +#include +#include +#include #define NDEBUG -#include +#include unsigned int _osver = 0; diff --git a/reactos/lib/crt/misc/getargs.c b/reactos/lib/crt/misc/getargs.c index b68db68d6dc..4a8fa53de4c 100644 --- a/reactos/lib/crt/misc/getargs.c +++ b/reactos/lib/crt/misc/getargs.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include extern char*_acmdln; @@ -168,6 +168,15 @@ char*** __p___argv(void) return &__argv; } +/* + * @implemented + */ +wchar_t*** __p___wargv(void) +{ + return &__wargv; +} + + #if 0 int _chkstk(void) { diff --git a/reactos/lib/crt/misc/initterm.c b/reactos/lib/crt/misc/initterm.c index 26f66a1c924..54963ad9add 100644 --- a/reactos/lib/crt/misc/initterm.c +++ b/reactos/lib/crt/misc/initterm.c @@ -1,4 +1,4 @@ -#include +#include /* diff --git a/reactos/lib/crt/misc/lock.c b/reactos/lib/crt/misc/lock.c index 100cef02d54..775f9190486 100644 --- a/reactos/lib/crt/misc/lock.c +++ b/reactos/lib/crt/misc/lock.c @@ -19,8 +19,8 @@ #include "precomp.h" #define NDEBUG -#include -#include +#include +#include typedef struct { diff --git a/reactos/lib/crt/misc/purecall.c b/reactos/lib/crt/misc/purecall.c index 4b50cbfd528..28612a9aaf5 100644 --- a/reactos/lib/crt/misc/purecall.c +++ b/reactos/lib/crt/misc/purecall.c @@ -1,5 +1,5 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/misc/stubs.c b/reactos/lib/crt/misc/stubs.c index e2e40baa841..2e7dc702780 100644 --- a/reactos/lib/crt/misc/stubs.c +++ b/reactos/lib/crt/misc/stubs.c @@ -1,7 +1,7 @@ #include "precomp.h" #define NDEBUG -#include +#include /********************************************************************* * $I10_OUTPUT (MSVCRT.@) @@ -111,3 +111,34 @@ void _adj_fpatan(void) { DPRINT1("_adj_fpatan stub\n"); } + + +void __crtCompareStringA(void) +{ + DPRINT1("__crtCompareStringA stub\n"); +} + +void __crtGetLocaleInfoW(void) +{ + DPRINT1("__crtGetLocaleInfoW stub\n"); +} + +void __p__amblksiz(void) +{ + DPRINT1("__p__amblksiz stub\n"); +} + +void __p__dstbias(void) +{ + DPRINT1("__p__dstbias stub\n"); +} + +void __fileinfo(void) +{ + DPRINT1("__fileinfo stub\n"); +} + +void stub(void) +{ + DPRINT1("stub\n"); +} diff --git a/reactos/lib/crt/misc/tls.c b/reactos/lib/crt/misc/tls.c index 84938534acc..18ecade199e 100644 --- a/reactos/lib/crt/misc/tls.c +++ b/reactos/lib/crt/misc/tls.c @@ -1,7 +1,7 @@ #include "precomp.h" -#include -#include -#include +#include +#include +#include static unsigned long TlsIndex = (unsigned long)-1; diff --git a/reactos/lib/crt/process/_cwait.c b/reactos/lib/crt/process/_cwait.c index aa940452e21..f52dc44a36d 100644 --- a/reactos/lib/crt/process/_cwait.c +++ b/reactos/lib/crt/process/_cwait.c @@ -9,9 +9,9 @@ */ #include "precomp.h" -#include -#include -#include +#include +#include +#include /* diff --git a/reactos/lib/crt/process/_system.c b/reactos/lib/crt/process/_system.c index 9041e41bfc6..15c89d4241b 100644 --- a/reactos/lib/crt/process/_system.c +++ b/reactos/lib/crt/process/_system.c @@ -10,11 +10,11 @@ */ #include "precomp.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/process/dll.c b/reactos/lib/crt/process/dll.c index 5e3db761f6a..c9f3a53a6af 100644 --- a/reactos/lib/crt/process/dll.c +++ b/reactos/lib/crt/process/dll.c @@ -9,7 +9,7 @@ */ #include "precomp.h" -#include +#include /* diff --git a/reactos/lib/crt/process/process.c b/reactos/lib/crt/process/process.c index 8a375430aa3..6c7f06efb1e 100644 --- a/reactos/lib/crt/process/process.c +++ b/reactos/lib/crt/process/process.c @@ -1,622 +1,654 @@ #include "precomp.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #define NDEBUG -#include +#include -extern int maxfno; +#ifdef _UNICODE + #define find_execT find_execW + #define argvtosT argvtosW + #define do_spawnT do_spawnW + #define valisttosT valisttosW + #define extT extW +#else + #define find_execT find_execA + #define argvtosT argvtosA + #define do_spawnT do_spawnA + #define valisttosT valisttosA + #define extT extA +#endif -char const* ext[] = + +_TCHAR const* extT[] = + { + _T(""), + _T(".bat"), + _T(".cmd"), + _T(".com"), + _T(".exe") + }; + +const _TCHAR* find_execT(const _TCHAR* path, _TCHAR* rpath) { - "", - ".bat", - ".cmd", - ".com", - ".exe" -}; + _TCHAR *rp; + const _TCHAR *rd; + int i, found = 0; -const char* find_exec(const char* path, char* rpath) -{ - char *rp; - const char *rd; - int i, found = 0; + DPRINT(MK_STR(find_execT)"('%"sT"', %x)\n", path, rpath); - DPRINT("find_exec('%s', %x)\n", path, rpath); + if (path == NULL) + { + return NULL; + } + if (_tcslen(path) > FILENAME_MAX - 1) + { + return path; + } + /* copy path in rpath */ + for (rd = path, rp = rpath; *rd; *rp++ = *rd++) + ; + *rp = 0; + /* try first with the name as is */ + for (i = 0; i < sizeof(extT) / sizeof(*extT); i++) + { + _tcscpy(rp, extT[i]); - if (path == NULL) - { - return NULL; - } - if (strlen(path) > FILENAME_MAX - 1) - { - return path; - } - /* copy path in rpath */ - for (rd = path, rp = rpath; *rd; *rp++ = *rd++); - *rp = 0; - /* try first with the name as is */ - for (i = 0; i < sizeof(ext) / sizeof(*ext); i++) - { - strcpy(rp, ext[i]); + DPRINT("trying '%"sT"'\n", rpath); - DPRINT("trying '%s'\n", rpath); + if (_taccess(rpath, F_OK) == 0 && access_dirT(rpath) != 0) + { + found = 1; + break; + } + } + if (!found) + { + _TCHAR* env = _tgetenv(_T("PATH")); + if (env) + { + _TCHAR* ep = env; + while (*ep && !found) + { + if (*ep == ';') + ep++; + rp=rpath; + for (; *ep && (*ep != ';'); *rp++ = *ep++) + ; + if (rp > rpath) + { + rp--; + if (*rp != '/' && *rp != '\\') + { + *++rp = '\\'; + } + rp++; + } + for (rd=path; *rd; *rp++ = *rd++) + ; + for (i = 0; i < sizeof(extT) / sizeof(*extT); i++) + { + _tcscpy(rp, extT[i]); - if (_access(rpath, F_OK) == 0 && _access(rpath, D_OK) != 0) - { - found = 1; - break; - } - } - if (!found) - { - char* env = getenv("PATH"); - if (env) - { - char* ep = env; - while (*ep && !found) - { - if (*ep == ';') ep++; - rp=rpath; - for (; *ep && (*ep != ';'); *rp++ = *ep++); - if (rp > rpath) - { - rp--; - if (*rp != '/' && *rp != '\\') - { - *++rp = '\\'; - } - rp++; - } - for (rd=path; *rd; *rp++ = *rd++); - for (i = 0; i < sizeof(ext) / sizeof(*ext); i++) - { - strcpy(rp, ext[i]); + DPRINT("trying '%"sT"'\n", rpath); - DPRINT("trying '%s'\n", rpath); + if (_taccess(rpath, F_OK) == 0 && access_dirT(rpath) != 0) + { + found = 1; + break; + } + } + } + } + } - if (_access(rpath, F_OK) == 0 && _access(rpath, D_OK) != 0) - { - found = 1; - break; - } - } - } - } - } - - return found ? rpath : path; + return found ? rpath : path; } -static char* -argvtos(char* const* argv, char delim) +static _TCHAR* +argvtosT(const _TCHAR* const* argv, _TCHAR delim) { - int i, len; - char *ptr, *str; + int i, len; + _TCHAR *ptr, *str; - if (argv == NULL) - return NULL; + if (argv == NULL) + return NULL; - for (i = 0, len = 0; argv[i]; i++) - { - len += strlen(argv[i]) + 1; - } + for (i = 0, len = 0; argv[i]; i++) + { + len += _tcslen(argv[i]) + 1; + } - str = ptr = (char*) malloc(len + 1); - if (str == NULL) - return NULL; + str = ptr = (_TCHAR*) malloc(len + 1); + if (str == NULL) + return NULL; - for(i = 0; argv[i]; i++) - { - len = strlen(argv[i]); - memcpy(ptr, argv[i], len); - ptr += len; - *ptr++ = delim; - } - *ptr = 0; + for(i = 0; argv[i]; i++) + { + len = _tcslen(argv[i]); + memcpy(ptr, argv[i], len); + ptr += len; + *ptr++ = delim; + } + *ptr = 0; - return str; + return str; } -static char* -valisttos(const char* arg0, va_list alist, char delim) +static _TCHAR* +valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim) { - va_list alist2 = alist; - char *ptr, *str; - int len; + va_list alist2 = alist; + _TCHAR *ptr, *str; + int len; - if (arg0 == NULL) - return NULL; + if (arg0 == NULL) + return NULL; - ptr = (char*)arg0; - len = 0; - do - { - len += strlen(ptr) + 1; - ptr = va_arg(alist, char*); - } - while(ptr != NULL); + ptr = (_TCHAR*)arg0; + len = 0; + do + { + len += _tcslen(ptr) + 1; + ptr = va_arg(alist, _TCHAR*); + } + while(ptr != NULL); - str = (char*) malloc(len + 1); - if (str == NULL) - return NULL; + str = (_TCHAR*) malloc(len + 1); + if (str == NULL) + return NULL; - ptr = str; - do - { - len = strlen(arg0); - memcpy(ptr, arg0, len); - ptr += len; - *ptr++ = delim; - arg0 = va_arg(alist2, char*); - } - while(arg0 != NULL); - *ptr = 0; + ptr = str; + do + { + len = _tcslen(arg0); + memcpy(ptr, arg0, len); + ptr += len; + *ptr++ = delim; + arg0 = va_arg(alist2, _TCHAR*); + } + while(arg0 != NULL); + *ptr = 0; - return str; + return str; } static int -do_spawn(int mode, const char* cmdname, const char* args, const char* envp) +do_spawnT(int mode, const _TCHAR* cmdname, const _TCHAR* args, const _TCHAR* envp) { - STARTUPINFOA StartupInfo; - PROCESS_INFORMATION ProcessInformation; - char* fmode; - HANDLE* hFile; - int i, last; - BOOL bResult; - DWORD dwExitCode; - DWORD dwError; + STARTUPINFO StartupInfo = {0}; + PROCESS_INFORMATION ProcessInformation; +// char* fmode; +// HANDLE* hFile; +// int i, last; + BOOL bResult; + DWORD dwExitCode; + DWORD dwError; - DPRINT("do_spawn('%s')\n", cmdname); + TRACE(MK_STR(do_spawnT)"(%i,'%"sT"','%"sT"','%"sT"')",mode,cmdname,args,envp); + - if (mode != _P_NOWAIT && mode != _P_NOWAITO && mode != _P_WAIT && mode != _P_DETACH && mode != _P_OVERLAY) - { - __set_errno ( EINVAL ); - return -1; - } + if (mode != _P_NOWAIT && mode != _P_NOWAITO && mode != _P_WAIT && mode != _P_DETACH && mode != _P_OVERLAY) + { + __set_errno ( EINVAL ); + return( -1); + } - if (0 != _access(cmdname, F_OK)) - { - __set_errno ( ENOENT ); - return -1; - } - if (0 == _access(cmdname, D_OK)) - { - __set_errno ( EISDIR ); - return -1; - } + if (0 != _taccess(cmdname, F_OK)) + { + __set_errno ( ENOENT ); + return(-1); + } + if (0 == access_dirT(cmdname)) + { + __set_errno ( EISDIR ); + return(-1); + } + + //memset (&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(StartupInfo); + +#if 0 - memset (&StartupInfo, 0, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(StartupInfo); + for (last = i = 0; i < FDINFO_FD_MAX; i++) + { + if ((void*)-1 != _get_osfhandle(i)) + { + last = i + 1; + } + } - for (last = i = 0; i < maxfno; i++) - { - if ((void*)-1 != _get_osfhandle(i)) - { - last = i + 1; - } - } + if (last) + { + StartupInfo.cbReserved2 = sizeof(ULONG) + last * (sizeof(char) + sizeof(HANDLE)); + StartupInfo.lpReserved2 = malloc(StartupInfo.cbReserved2); + if (StartupInfo.lpReserved2 == NULL) + { + __set_errno ( ENOMEM ); + return -1; + } - if (last) - { - StartupInfo.cbReserved2 = sizeof(ULONG) + last * (sizeof(char) + sizeof(HANDLE)); - StartupInfo.lpReserved2 = malloc(StartupInfo.cbReserved2); - if (StartupInfo.lpReserved2 == NULL) - { - __set_errno ( ENOMEM ); - return -1; - } + *(DWORD*)StartupInfo.lpReserved2 = last; + fmode = (char*)(StartupInfo.lpReserved2 + sizeof(ULONG)); + hFile = (HANDLE*)(StartupInfo.lpReserved2 + sizeof(ULONG) + last * sizeof(char)); + for (i = 0; i < last; i++) + { + int _mode = __fileno_getmode(i); + HANDLE h = _get_osfhandle(i); + /* FIXME: The test of console handles (((ULONG)Handle) & 0x10000003) == 0x3) + * is possible wrong + */ + if ((((ULONG)h) & 0x10000003) == 0x3 || _mode & _O_NOINHERIT || (i < 3 && mode == _P_DETACH)) + { + *hFile = INVALID_HANDLE_VALUE; + *fmode = 0; + } + else + { + DWORD dwFlags; + BOOL bFlag; + bFlag = GetHandleInformation(h, &dwFlags); + if (bFlag && (dwFlags & HANDLE_FLAG_INHERIT)) + { + *hFile = h; + *fmode = (_O_ACCMODE & _mode) | (((_O_TEXT | _O_BINARY) & _mode) >> 8); + } + else + { + *hFile = INVALID_HANDLE_VALUE; + *fmode = 0; + } + } + fmode++; + hFile++; + } + } +#endif - *(DWORD*)StartupInfo.lpReserved2 = last; - fmode = (char*)(StartupInfo.lpReserved2 + sizeof(ULONG)); - hFile = (HANDLE*)(StartupInfo.lpReserved2 + sizeof(ULONG) + last * sizeof(char)); - for (i = 0; i < last; i++) - { - int _mode = __fileno_getmode(i); - HANDLE h = _get_osfhandle(i); - /* FIXME: The test of console handles (((ULONG)Handle) & 0x10000003) == 0x3) - * is possible wrong - */ - if ((((ULONG)h) & 0x10000003) == 0x3 || _mode & _O_NOINHERIT || (i < 3 && mode == _P_DETACH)) - { - *hFile = INVALID_HANDLE_VALUE; - *fmode = 0; - } - else - { - DWORD dwFlags; - BOOL bFlag; - bFlag = GetHandleInformation(h, &dwFlags); - if (bFlag && (dwFlags & HANDLE_FLAG_INHERIT)) - { - *hFile = h; - *fmode = (_O_ACCMODE & _mode) | (((_O_TEXT | _O_BINARY) & _mode) >> 8); - } - else - { - *hFile = INVALID_HANDLE_VALUE; - *fmode = 0; - } - } - fmode++; - hFile++; - } - } + create_io_inherit_block((STARTUPINFOA*) &StartupInfo); + + bResult = CreateProcess((_TCHAR *)cmdname, + (_TCHAR *)args, + NULL, + NULL, + TRUE, + mode == _P_DETACH ? DETACHED_PROCESS : 0, + (LPVOID)envp, + NULL, + &StartupInfo, + &ProcessInformation); + + if (StartupInfo.lpReserved2) + { + free(StartupInfo.lpReserved2); + } - bResult = CreateProcessA((char *)cmdname, - (char *)args, - NULL, - NULL, - TRUE, - mode == _P_DETACH ? DETACHED_PROCESS : 0, - (LPVOID)envp, - NULL, - &StartupInfo, - &ProcessInformation); - if (StartupInfo.lpReserved2) - { - free(StartupInfo.lpReserved2); - } - - if (!bResult) - { - dwError = GetLastError(); - DPRINT("%x\n", dwError); - __set_errno(dwError); - return -1; - } - CloseHandle(ProcessInformation.hThread); - switch(mode) - { - case _P_OVERLAY: - _exit(0); - case _P_WAIT: - WaitForSingleObject(ProcessInformation.hProcess, INFINITE); - GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode); - CloseHandle(ProcessInformation.hProcess); - return (int)dwExitCode; - case _P_DETACH: - CloseHandle(ProcessInformation.hProcess); - return 0; - } - return (int)ProcessInformation.hProcess; + if (!bResult) + { + dwError = GetLastError(); + DPRINT("%x\n", dwError); + __set_errno(dwError); + return(-1); + } + CloseHandle(ProcessInformation.hThread); + switch(mode) + { + case _P_NOWAIT: + case _P_NOWAITO: + CloseHandle(ProcessInformation.hThread); + return((int)ProcessInformation.hProcess); + case _P_OVERLAY: + _exit(0); + case _P_WAIT: + WaitForSingleObject(ProcessInformation.hProcess, INFINITE); + GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode); + CloseHandle(ProcessInformation.hProcess); + CloseHandle(ProcessInformation.hThread); + return( (int)dwExitCode); //CORRECT? + case _P_DETACH: + CloseHandle(ProcessInformation.hProcess); + CloseHandle(ProcessInformation.hThread); + return( 0); + } + return( (int)ProcessInformation.hProcess); } /* * @implemented */ -int _spawnl(int mode, const char *cmdname, const char* arg0, ...) +int _tspawnl(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ...) { - va_list argp; - char* args; - int ret = -1; + va_list argp; + _TCHAR* args; + int ret = -1; - DPRINT("_spawnl('%s')\n", cmdname); + DPRINT(MK_STR(_tspawnl)"('%"sT"')\n", cmdname); - va_start(argp, arg0); - args = valisttos(arg0, argp, ' '); + va_start(argp, arg0); + args = valisttosT(arg0, argp, ' '); - if (args) - { - ret = do_spawn(mode, cmdname, args, NULL); - free(args); - } - return ret; + if (args) + { + ret = do_spawnT(mode, cmdname, args, NULL); + free(args); + } + return ret; } /* * @implemented */ -int _spawnv(int mode, const char *cmdname, char* const* argv) +int _tspawnv(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv) { - char* args; - int ret = -1; + _TCHAR* args; + int ret = -1; - DPRINT("_spawnv('%s')\n", cmdname); + DPRINT(MK_STR(_tspawnv)"('%"sT"')\n", cmdname); - args = argvtos(argv, ' '); + args = argvtosT(argv, ' '); - if (args) - { - ret = do_spawn(mode, cmdname, args, NULL); - free(args); - } - return ret; + if (args) + { + ret = do_spawnT(mode, cmdname, args, NULL); + free(args); + } + return ret; } /* * @implemented */ -int _spawnle(int mode, const char *cmdname, const char* arg0, ... /*, NULL, const char* const* envp*/) +int _tspawnle(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ... /*, NULL, const char* const* envp*/) { - va_list argp; - char* args; - char* envs; - char* const* ptr; - int ret = -1; + va_list argp; + _TCHAR* args; + _TCHAR* envs; + _TCHAR const * const* ptr; + int ret = -1; - DPRINT("_spawnle('%s')\n", cmdname); + DPRINT(MK_STR(_tspawnle)"('%"sT"')\n", cmdname); + + va_start(argp, arg0); + args = valisttosT(arg0, argp, ' '); + do + { + ptr = (_TCHAR const* const*)va_arg(argp, _TCHAR*); + } + while (ptr != NULL); + ptr = (_TCHAR const* const*)va_arg(argp, _TCHAR*); + envs = argvtosT(ptr, 0); + if (args) + { + ret = do_spawnT(mode, cmdname, args, envs); + free(args); + } + if (envs) + { + free(envs); + } + return ret; - va_start(argp, arg0); - args = valisttos(arg0, argp, ' '); - do - { - ptr = (char* const*)va_arg(argp, char*); - } - while (ptr != NULL); - ptr = (char* const*)va_arg(argp, char*); - envs = argvtos(ptr, 0); - if (args) - { - ret = do_spawn(mode, cmdname, args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; - } /* * @implemented */ -int _spawnve(int mode, const char *cmdname, char* const* argv, char* const* envp) +int _tspawnve(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp) { - char *args; - char *envs; - int ret = -1; + _TCHAR *args; + _TCHAR *envs; + int ret = -1; - DPRINT("_spawnve('%s')\n", cmdname); + DPRINT(MK_STR(_tspawnve)"('%"sT"')\n", cmdname); - args = argvtos(argv, ' '); - envs = argvtos(envp, 0); + args = argvtosT(argv, ' '); + envs = argvtosT(envp, 0); - if (args) - { - ret = do_spawn(mode, cmdname, args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; + if (args) + { + ret = do_spawnT(mode, cmdname, args, envs); + free(args); + } + if (envs) + { + free(envs); + } + return ret; } /* * @implemented */ -int _spawnvp(int mode, const char* cmdname, char* const* argv) +int _tspawnvp(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv) { - char pathname[FILENAME_MAX]; - - DPRINT("_spawnvp('%s')\n", cmdname); + _TCHAR pathname[FILENAME_MAX]; - return _spawnv(mode, find_exec(cmdname, pathname), argv); + DPRINT(MK_STR(_tspawnvp)"('%"sT"')\n", cmdname); + + return _tspawnv(mode, find_execT(cmdname, pathname), argv); } /* * @implemented */ -int _spawnlp(int mode, const char* cmdname, const char* arg0, .../*, NULL*/) +int _tspawnlp(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL*/) { - va_list argp; - char* args; - int ret = -1; - char pathname[FILENAME_MAX]; + va_list argp; + _TCHAR* args; + int ret = -1; + _TCHAR pathname[FILENAME_MAX]; - DPRINT("_spawnlp('%s')\n", cmdname); + DPRINT(MK_STR(_tspawnlp)"('%"sT"')\n", cmdname); - va_start(argp, arg0); - args = valisttos(arg0, argp, ' '); - if (args) - { - ret = do_spawn(mode, find_exec(cmdname, pathname), args, NULL); - free(args); - } - return ret; + va_start(argp, arg0); + args = valisttosT(arg0, argp, ' '); + if (args) + { + ret = do_spawnT(mode, find_execT(cmdname, pathname), args, NULL); + free(args); + } + return ret; } /* * @implemented */ -int _spawnlpe(int mode, const char* cmdname, const char* arg0, .../*, NULL, const char* const* envp*/) +int _tspawnlpe(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL, const char* const* envp*/) { - va_list argp; - char* args; - char* envs; - char* const * ptr; - int ret = -1; - char pathname[FILENAME_MAX]; + va_list argp; + _TCHAR* args; + _TCHAR* envs; + _TCHAR const* const * ptr; + int ret = -1; + _TCHAR pathname[FILENAME_MAX]; - DPRINT("_spawnlpe('%s')\n", cmdname); + DPRINT(MK_STR(_tspawnlpe)"('%"sT"')\n", cmdname); - va_start(argp, arg0); - args = valisttos(arg0, argp, ' '); - do - { - ptr = (char* const*)va_arg(argp, char*); - } - while (ptr != NULL); - ptr = (char* const*)va_arg(argp, char*); - envs = argvtos(ptr, 0); - if (args) - { - ret = do_spawn(mode, find_exec(cmdname, pathname), args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; + va_start(argp, arg0); + args = valisttosT(arg0, argp, ' '); + do + { + ptr = (_TCHAR const* const*)va_arg(argp, _TCHAR*); + } + while (ptr != NULL); + ptr = (_TCHAR const* const*)va_arg(argp, _TCHAR*); + envs = argvtosT(ptr, 0); + if (args) + { + ret = do_spawnT(mode, find_execT(cmdname, pathname), args, envs); + free(args); + } + if (envs) + { + free(envs); + } + return ret; } /* * @implemented */ -int _spawnvpe(int mode, const char* cmdname, char* const* argv, char* const* envp) +int _tspawnvpe(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp) { - char pathname[FILENAME_MAX]; - - DPRINT("_spawnvpe('%s')\n", cmdname); + _TCHAR pathname[FILENAME_MAX]; - return _spawnve(mode, find_exec(cmdname, pathname), argv, envp); + DPRINT(MK_STR(_tspawnvpe)"('%"sT"')\n", cmdname); + + return _tspawnve(mode, find_execT(cmdname, pathname), argv, envp); } /* * @implemented */ -int _execl(const char* cmdname, const char* arg0, ...) +int _texecl(const _TCHAR* cmdname, const _TCHAR* arg0, ...) { - char* args; - va_list argp; - int ret = -1; + _TCHAR* args; + va_list argp; + int ret = -1; - DPRINT("_execl('%s')\n", cmdname); + DPRINT(MK_STR(_texecl)"('%"sT"')\n", cmdname); - va_start(argp, arg0); - args = valisttos(arg0, argp, ' '); + va_start(argp, arg0); + args = valisttosT(arg0, argp, ' '); - if (args) - { - ret = do_spawn(P_OVERLAY, cmdname, args, NULL); - free(args); - } - return ret; + if (args) + { + ret = do_spawnT(P_OVERLAY, cmdname, args, NULL); + free(args); + } + return ret; } /* * @implemented */ -int _execv(const char* cmdname, char* const* argv) +int _texecv(const _TCHAR* cmdname, const _TCHAR* const* argv) { - DPRINT("_execv('%s')\n", cmdname); - return _spawnv(P_OVERLAY, cmdname, argv); + DPRINT(MK_STR(_texecv)"('%"sT"')\n", cmdname); + return _tspawnv(P_OVERLAY, cmdname, argv); } /* * @implemented */ -int _execle(const char* cmdname, const char* arg0, ... /*, NULL, char* const* envp */) +int _texecle(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* const* envp */) { - va_list argp; - char* args; - char* envs; - char* const* ptr; - int ret = -1; + va_list argp; + _TCHAR* args; + _TCHAR* envs; + _TCHAR const* const* ptr; + int ret = -1; - DPRINT("_execle('%s')\n", cmdname); + DPRINT(MK_STR(_texecle)"('%"sT"')\n", cmdname); - va_start(argp, arg0); - args = valisttos(arg0, argp, ' '); - do - { - ptr = (char* const*)va_arg(argp, char*); - } - while (ptr != NULL); - ptr = (char* const*)va_arg(argp, char*); - envs = argvtos(ptr, 0); - if (args) - { - ret = do_spawn(P_OVERLAY, cmdname, args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; + va_start(argp, arg0); + args = valisttosT(arg0, argp, ' '); + do + { + ptr = (_TCHAR const* const*)va_arg(argp, _TCHAR*); + } + while (ptr != NULL); + ptr = (_TCHAR const* const*)va_arg(argp, _TCHAR*); + envs = argvtosT(ptr, 0); + if (args) + { + ret = do_spawnT(P_OVERLAY, cmdname, args, envs); + free(args); + } + if (envs) + { + free(envs); + } + return ret; } /* * @implemented */ -int _execve(const char* cmdname, char* const* argv, char* const* envp) +int _texecve(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp) { - DPRINT("_execve('%s')\n", cmdname); - return _spawnve(P_OVERLAY, cmdname, argv, envp); + DPRINT(MK_STR(_texecve)"('%"sT"')\n", cmdname); + return _tspawnve(P_OVERLAY, cmdname, argv, envp); } /* * @implemented */ -int _execlp(const char* cmdname, const char* arg0, ...) +int _texeclp(const _TCHAR* cmdname, const _TCHAR* arg0, ...) { - char* args; - va_list argp; - int ret = -1; - char pathname[FILENAME_MAX]; + _TCHAR* args; + va_list argp; + int ret = -1; + _TCHAR pathname[FILENAME_MAX]; - DPRINT("_execlp('%s')\n", cmdname); + DPRINT(MK_STR(_texeclp)"('%"sT"')\n", cmdname); - va_start(argp, arg0); - args = valisttos(arg0, argp, ' '); + va_start(argp, arg0); + args = valisttosT(arg0, argp, ' '); - if (args) - { - ret = do_spawn(P_OVERLAY, find_exec(cmdname, pathname), args, NULL); - free(args); - } - return ret; + if (args) + { + ret = do_spawnT(P_OVERLAY, find_execT(cmdname, pathname), args, NULL); + free(args); + } + return ret; } /* * @implemented */ -int _execvp(const char* cmdname, char* const* argv) +int _texecvp(const _TCHAR* cmdname, const _TCHAR* const* argv) { - DPRINT("_execvp('%s')\n", cmdname); - return _spawnvp(P_OVERLAY, cmdname, argv); + DPRINT(MK_STR(_texecvp)"('%"sT"')\n", cmdname); + return _tspawnvp(P_OVERLAY, cmdname, argv); } /* * @implemented */ -int _execlpe(const char* cmdname, const char* arg0, ... /*, NULL, char* const* envp */) +int _texeclpe(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* const* envp */) { - va_list argp; - char* args; - char* envs; - char* const* ptr; - int ret = -1; - char pathname[FILENAME_MAX]; + va_list argp; + _TCHAR* args; + _TCHAR* envs; + _TCHAR const* const* ptr; + int ret = -1; + _TCHAR pathname[FILENAME_MAX]; - DPRINT("_execlpe('%s')\n", cmdname); + DPRINT(MK_STR(_texeclpe)"('%"sT"')\n", cmdname); - va_start(argp, arg0); - args = valisttos(arg0, argp, ' '); - do - { - ptr = (char* const*)va_arg(argp, char*); - } - while (ptr != NULL); - ptr = (char* const*)va_arg(argp, char*); - envs = argvtos(ptr, 0); - if (args) - { - ret = do_spawn(P_OVERLAY, find_exec(cmdname, pathname), args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; + va_start(argp, arg0); + args = valisttosT(arg0, argp, ' '); + do + { + ptr = (_TCHAR const* const*)va_arg(argp, _TCHAR*); + } + while (ptr != NULL); + ptr = (_TCHAR const* const*)va_arg(argp, _TCHAR*); + envs = argvtosT(ptr, 0); + if (args) + { + ret = do_spawnT(P_OVERLAY, find_execT(cmdname, pathname), args, envs); + free(args); + } + if (envs) + { + free(envs); + } + return ret; } /* * @implemented */ -int _execvpe(const char* cmdname, char* const* argv, char* const* envp) +int _texecvpe(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp) { - DPRINT("_execvpe('%s')\n", cmdname); - return _spawnvpe(P_OVERLAY, cmdname, argv, envp); + DPRINT(MK_STR(_texecvpe)"('%"sT"')\n", cmdname); + return _tspawnvpe(P_OVERLAY, cmdname, argv, envp); } + diff --git a/reactos/lib/crt/process/procid.c b/reactos/lib/crt/process/procid.c index 87c145828c6..09c1a830573 100644 --- a/reactos/lib/crt/process/procid.c +++ b/reactos/lib/crt/process/procid.c @@ -1,5 +1,5 @@ #include "precomp.h" -#include +#include /* * @implemented diff --git a/reactos/lib/crt/process/thread.c b/reactos/lib/crt/process/thread.c index 1c601745c3f..fd59896dae5 100644 --- a/reactos/lib/crt/process/thread.c +++ b/reactos/lib/crt/process/thread.c @@ -1,7 +1,7 @@ #include "precomp.h" -#include -#include -#include +#include +#include +#include #if 0 /* diff --git a/reactos/lib/crt/process/threadid.c b/reactos/lib/crt/process/threadid.c index 5d225c73f33..7e68e94402a 100644 --- a/reactos/lib/crt/process/threadid.c +++ b/reactos/lib/crt/process/threadid.c @@ -1,5 +1,5 @@ #include "precomp.h" -#include +#include /* diff --git a/reactos/lib/crt/process/threadx.c b/reactos/lib/crt/process/threadx.c index d86d62e27e7..8dc630110be 100644 --- a/reactos/lib/crt/process/threadx.c +++ b/reactos/lib/crt/process/threadx.c @@ -1,7 +1,7 @@ #include "precomp.h" -#include -#include -#include +#include +#include +#include /* diff --git a/reactos/lib/crt/process/wprocess.c b/reactos/lib/crt/process/wprocess.c new file mode 100644 index 00000000000..9bee2c8df4e --- /dev/null +++ b/reactos/lib/crt/process/wprocess.c @@ -0,0 +1,4 @@ +#define _UNICODE +#define UNICODE + +#include "process.c" diff --git a/reactos/lib/crt/search/lfind.c b/reactos/lib/crt/search/lfind.c index e89efa63c9b..72a7ceea1d2 100644 --- a/reactos/lib/crt/search/lfind.c +++ b/reactos/lib/crt/search/lfind.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/search/lsearch.c b/reactos/lib/crt/search/lsearch.c index a8465ae7853..37df9ffb003 100644 --- a/reactos/lib/crt/search/lsearch.c +++ b/reactos/lib/crt/search/lsearch.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/signal/signal.c b/reactos/lib/crt/signal/signal.c index 6272b2f6854..3df1deee360 100644 --- a/reactos/lib/crt/signal/signal.c +++ b/reactos/lib/crt/signal/signal.c @@ -1,77 +1,85 @@ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void _default_handler(int signal); -typedef struct _sig_element +//typedef void (*_p_sig_fn_t)(int); + + +typedef struct _sig_element { - int signal; - char *signame; - _p_sig_fn_t handler; -} sig_element; + int signal; + char *signame; + __p_sig_fn_t handler; +} +sig_element; -static sig_element signal_list[SIGMAX] = - { - { 0, "Signal 0", SIG_DFL }, - { SIGABRT, "Aborted",SIG_DFL }, - { SIGFPE, "Erroneous arithmetic operation",SIG_DFL }, - { SIGILL, "Illegal instruction",SIG_DFL }, - { SIGINT, "Interrupt",SIG_DFL }, - { SIGSEGV, "Invalid access to storage",SIG_DFL }, - { SIGTERM, "Terminated",SIG_DFL }, - { SIGHUP, "Hangup",SIG_DFL }, - { SIGQUIT, "Quit",SIG_DFL }, - { SIGPIPE, "Broken pipe",SIG_DFL }, - { SIGKILL, "Killed",SIG_DFL }, - { SIGALRM, "Alarm clock",SIG_DFL }, - { 0, "Stopped (signal)",SIG_DFL }, - { 0, "Stopped",SIG_DFL }, - { 0, "Continued",SIG_DFL }, - { 0, "Child exited",SIG_DFL }, - { 0, "Stopped (tty input)",SIG_DFL }, - { 0, "Stopped (tty output)",SIG_DFL }, - { 0, NULL, SIG_DFL } - }; -int nsignal = 21; +static sig_element signal_list[] = + { + { SIGINT, "CTRL+C",SIG_DFL }, + { SIGILL, "Illegal instruction",SIG_DFL }, + { SIGFPE, "Floating-point exception",SIG_DFL }, + { SIGSEGV, "Illegal storage access",SIG_DFL }, + { SIGTERM, "Termination request",SIG_DFL }, + { SIGBREAK, "CTRL+BREAK",SIG_DFL }, + { SIGABRT, "Abnormal termination",SIG_DFL } + }; + +//int nsignal = 21; /* * @implemented */ -_p_sig_fn_t signal(int sig, _p_sig_fn_t func) +//void ( *signal( int sig, void (__cdecl *func) ( int sig [, int subcode ] )) ) ( int sig ); + + + + +__p_sig_fn_t signal(int sig, __p_sig_fn_t func) { - _p_sig_fn_t temp; - int i; - if(sig <= 0 || sig > SIGMAX || sig == SIGKILL) - { - __set_errno(EINVAL); - return SIG_ERR; - } -// check with IsBadCodePtr + __p_sig_fn_t temp; + int i; - if ( func < (_p_sig_fn_t)4096 ) { - __set_errno(EINVAL); - return SIG_ERR; - } + switch (sig) + { + case SIGINT: + case SIGILL: + case SIGFPE: + case SIGSEGV: + case SIGTERM: + case SIGBREAK: + case SIGABRT: + break; - for(i=0;i SIGMAX) - return -1; - for(i=0;i SIGMAX) + // return -1; + + for(i=0;i +#include /* * @unimplemented diff --git a/reactos/lib/crt/stdio/allocfil.c b/reactos/lib/crt/stdio/allocfil.c index d1e08f2f2c7..d8fc1b24e3c 100644 --- a/reactos/lib/crt/stdio/allocfil.c +++ b/reactos/lib/crt/stdio/allocfil.c @@ -1,11 +1,10 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include +#include +#include +#include +#include -FILE * __alloc_file(void); char __validfp (FILE *f) { diff --git a/reactos/lib/crt/stdio/clearerr.c b/reactos/lib/crt/stdio/clearerr.c index 29ff9120475..48aaeeae78d 100644 --- a/reactos/lib/crt/stdio/clearerr.c +++ b/reactos/lib/crt/stdio/clearerr.c @@ -1,7 +1,8 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include + #ifdef clearerr #undef clearerr diff --git a/reactos/lib/crt/stdio/fclose.c b/reactos/lib/crt/stdio/fclose.c index f39c21f1a91..62591986cd0 100644 --- a/reactos/lib/crt/stdio/fclose.c +++ b/reactos/lib/crt/stdio/fclose.c @@ -1,12 +1,14 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + // changed check for writable stream @@ -31,17 +33,17 @@ fclose(FILE *f) if ( OPEN4WRITING(f) ) r = fflush(f); - if (_close(fileno(f)) < 0) + if (_close(_fileno(f)) < 0) r = EOF; if (f->_flag&_IOMYBUF) free(f->_base); // Kernel might do this later - if (f->_flag & _IORMONCL && f->_name_to_remove) + if (f->_flag & _IORMONCL && f->_tmpfname) { - remove(f->_name_to_remove); - free(f->_name_to_remove); - f->_name_to_remove = 0; + remove(f->_tmpfname); + free(f->_tmpfname); + f->_tmpfname = 0; } } f->_cnt = 0; diff --git a/reactos/lib/crt/stdio/fdopen.c b/reactos/lib/crt/stdio/fdopen.c index f6d44ace5b4..198fad78397 100644 --- a/reactos/lib/crt/stdio/fdopen.c +++ b/reactos/lib/crt/stdio/fdopen.c @@ -1,13 +1,22 @@ -#include -#include -FILE* __alloc_file(void); + +#include +#include +#include + + + + /* * @implemented */ -FILE* _fdopen(int handle, char* mode) +FILE* _tfdopen(int handle, +#ifndef _UNICODE + const +#endif + _TCHAR* mode) { FILE* file; int rw; @@ -21,12 +30,6 @@ FILE* _fdopen(int handle, char* mode) if (handle == 2) return stderr; - if (handle == 3) - return stdaux; - - if (handle == 4) - return stdprn; - file = __alloc_file(); if (file == NULL) return NULL; @@ -55,3 +58,5 @@ FILE* _fdopen(int handle, char* mode) return file; } + + diff --git a/reactos/lib/crt/stdio/feof.c b/reactos/lib/crt/stdio/feof.c index 9591e213705..60aa3b5cb26 100644 --- a/reactos/lib/crt/stdio/feof.c +++ b/reactos/lib/crt/stdio/feof.c @@ -1,7 +1,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include #ifdef feof #undef feof diff --git a/reactos/lib/crt/stdio/ferror.c b/reactos/lib/crt/stdio/ferror.c index f9381703ca8..b1aeb084d2b 100644 --- a/reactos/lib/crt/stdio/ferror.c +++ b/reactos/lib/crt/stdio/ferror.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include #ifdef ferror #undef ferror diff --git a/reactos/lib/crt/stdio/fflush.c b/reactos/lib/crt/stdio/fflush.c index e70e4cf41ef..8327160be61 100644 --- a/reactos/lib/crt/stdio/fflush.c +++ b/reactos/lib/crt/stdio/fflush.c @@ -11,13 +11,14 @@ /* 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 -#include +#include +#include +#include +#include +#include +#include +#include +#include /* @@ -75,7 +76,7 @@ int fflush(FILE *f) if ((f->_flag & _IOFBF) == _IOFBF) { if ( (f->_flag & _IOAHEAD) == _IOAHEAD ) - _lseek(fileno(f),-rn, SEEK_CUR); + _lseek(_fileno(f),-rn, SEEK_CUR); } f->_flag &= ~_IOAHEAD; @@ -89,7 +90,7 @@ int fflush(FILE *f) // better open the file in write through mode while (rn > 0) { - n = _write(fileno(f), base, rn); + n = _write(_fileno(f), base, rn); if (n <= 0) { f->_flag |= _IOERR; return EOF; @@ -100,7 +101,7 @@ int fflush(FILE *f) f->_flag &= ~_IODIRTY; // commit flushed data -// _commit(fileno(f)); +// _commit(_fileno(f)); } if (OPEN4READING(f) && OPEN4WRITING(f) ) { diff --git a/reactos/lib/crt/stdio/fgetc.c b/reactos/lib/crt/stdio/fgetc.c index e26fe17615d..7d02b2add8f 100644 --- a/reactos/lib/crt/stdio/fgetc.c +++ b/reactos/lib/crt/stdio/fgetc.c @@ -9,8 +9,8 @@ 25/02/99: Added fgetwc */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdio/fgetchar.c b/reactos/lib/crt/stdio/fgetchar.c index 7dd752a82d5..d7200f14ced 100644 --- a/reactos/lib/crt/stdio/fgetchar.c +++ b/reactos/lib/crt/stdio/fgetchar.c @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include +#include +#include int _fgetchar(void) { diff --git a/reactos/lib/crt/stdio/fgetpos.c b/reactos/lib/crt/stdio/fgetpos.c index b4b61247e98..5ff194fbb6e 100644 --- a/reactos/lib/crt/stdio/fgetpos.c +++ b/reactos/lib/crt/stdio/fgetpos.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdio/fgets.c b/reactos/lib/crt/stdio/fgets.c index 403f4629ea9..8b721eb9c47 100644 --- a/reactos/lib/crt/stdio/fgets.c +++ b/reactos/lib/crt/stdio/fgets.c @@ -25,8 +25,8 @@ */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include char* fgets(char* s, int n, FILE* f) diff --git a/reactos/lib/crt/stdio/fgetws.c b/reactos/lib/crt/stdio/fgetws.c index 0f2dae645dd..fece814b605 100644 --- a/reactos/lib/crt/stdio/fgetws.c +++ b/reactos/lib/crt/stdio/fgetws.c @@ -25,8 +25,8 @@ */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include //#include diff --git a/reactos/lib/crt/stdio/filbuf.c b/reactos/lib/crt/stdio/filbuf.c index 64b2134f5c3..db07a54135a 100644 --- a/reactos/lib/crt/stdio/filbuf.c +++ b/reactos/lib/crt/stdio/filbuf.c @@ -2,14 +2,14 @@ /* 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 -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include int _readcnv(int fn, void* buf, size_t siz); @@ -57,7 +57,7 @@ int _filbuf(FILE* f) - f->_cnt = _read(fileno(f), f->_base, f->_flag & _IONBF ? 1 : f->_bufsiz ); + f->_cnt = _read(_fileno(f), f->_base, f->_flag & _IONBF ? 1 : f->_bufsiz ); f->_flag |= _IOAHEAD; if(__is_text_file(f) && f->_cnt>0) @@ -67,7 +67,7 @@ int _filbuf(FILE* f) if(cz) { int newcnt = cz - f->_base; - lseek(fileno(f), -(f->_cnt - newcnt), SEEK_CUR); + _lseek(_fileno(f), -(f->_cnt - newcnt), SEEK_CUR); f->_cnt = newcnt; } } diff --git a/reactos/lib/crt/stdio/fileno.c b/reactos/lib/crt/stdio/fileno.c index 9c6900ed71b..454615c1c4c 100644 --- a/reactos/lib/crt/stdio/fileno.c +++ b/reactos/lib/crt/stdio/fileno.c @@ -1,12 +1,7 @@ -#include +#include +#include -#if 0 -#undef fileno -int fileno(FILE *f) -{ - return f->_file; -} -#endif +#undef _fileno /* * @implemented diff --git a/reactos/lib/crt/stdio/flsbuf.c b/reactos/lib/crt/stdio/flsbuf.c index 2ca113c15be..7875a2312a6 100644 --- a/reactos/lib/crt/stdio/flsbuf.c +++ b/reactos/lib/crt/stdio/flsbuf.c @@ -1,14 +1,13 @@ /* 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 -#include - +#include +#include +#include +#include +#include +#include +#include int cntcr(char* bufp, int bufsiz); int convert(char* endp, int bufsiz, int n); @@ -31,7 +30,7 @@ int _flsbuf(int c, FILE* f) } // no file associated with buffer, this is a memory stream - if (fileno(f) == -1) { + if (_fileno(f) == -1) { return c; } @@ -46,7 +45,7 @@ int _flsbuf(int c, FILE* f) f->_cnt = f->_bufsiz = size; f->_ptr = base; rn = 0; - if (f == stdout && isatty(fileno(stdout))) { + if (f == stdout && _isatty(_fileno(stdout))) { f->_flag |= _IO_LBF; } } @@ -76,13 +75,13 @@ int _flsbuf(int c, FILE* f) rn = f->_ptr - base; f->_ptr = base; if ((f->_flag & _IOAHEAD) == _IOAHEAD) - _lseek(fileno(f), -(rn+f->_cnt), SEEK_CUR); + _lseek(_fileno(f), -(rn+f->_cnt), SEEK_CUR); f->_cnt = f->_bufsiz; f->_flag &= ~_IOAHEAD; } f->_flag &= ~_IODIRTY; while (rn > 0) { - n = _write(fileno(f), base, rn); + n = _write(_fileno(f), base, rn); if (n <= 0) { f->_flag |= _IOERR; return EOF; diff --git a/reactos/lib/crt/stdio/fopen.c b/reactos/lib/crt/stdio/fopen.c index eb309c9f798..3de3c2cb434 100644 --- a/reactos/lib/crt/stdio/fopen.c +++ b/reactos/lib/crt/stdio/fopen.c @@ -25,16 +25,15 @@ */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include //might change fopen(file,mode) -> fsopen(file,mode,_SH_DENYNO); -FILE* __alloc_file(void); FILE* fopen(const char *file, const char *mode) @@ -63,7 +62,7 @@ FILE* fopen(const char *file, const char *mode) else if (strchr(mode, 'b')) oflags |= O_BINARY; else - oflags |= (__fmode & (O_TEXT|O_BINARY)); + oflags |= (_fmode& (O_TEXT|O_BINARY)); fd = _open(file, oflags, 0); if (fd < 0) @@ -73,7 +72,7 @@ FILE* fopen(const char *file, const char *mode) // we just move the file pointer to the end of file initially if (strchr(mode, 'a')) - lseek(fd, 0, SEEK_END); + _lseek(fd, 0, SEEK_END); f->_cnt = 0; f->_file = fd; @@ -89,7 +88,7 @@ FILE* fopen(const char *file, const char *mode) f->_flag |= _IOTEXT; else if (strchr(mode, 'b')) f->_flag |= _IOBINARY; - else if (__fmode & O_BINARY) + else if (_fmode& O_BINARY) f->_flag |= _IOBINARY; f->_base = f->_ptr = NULL; @@ -125,7 +124,7 @@ FILE* _wfopen(const wchar_t *file, const wchar_t *mode) else if (wcschr(mode, L'b')) oflags |= O_BINARY; else - oflags |= (__fmode & (O_TEXT|O_BINARY)); + oflags |= (_fmode& (O_TEXT|O_BINARY)); fd = _wopen(file, oflags, 0); if (fd < 0) @@ -134,7 +133,7 @@ FILE* _wfopen(const wchar_t *file, const wchar_t *mode) // msvcrt 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 (wcschr(mode, 'a')) - lseek(fd, 0, SEEK_END); + _lseek(fd, 0, SEEK_END); f->_cnt = 0; f->_file = fd; @@ -150,7 +149,7 @@ FILE* _wfopen(const wchar_t *file, const wchar_t *mode) f->_flag |= _IOTEXT; else if (wcschr(mode, L'b')) f->_flag |= _IOBINARY; - else if (__fmode & O_BINARY) + else if (_fmode& O_BINARY) f->_flag |= _IOBINARY; f->_base = f->_ptr = NULL; diff --git a/reactos/lib/crt/stdio/fprintf.c b/reactos/lib/crt/stdio/fprintf.c index a5589b6de6a..dc56b3aba26 100644 --- a/reactos/lib/crt/stdio/fprintf.c +++ b/reactos/lib/crt/stdio/fprintf.c @@ -1,7 +1,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdio/fputc.c b/reactos/lib/crt/stdio/fputc.c index c08cccec557..55dde146538 100644 --- a/reactos/lib/crt/stdio/fputc.c +++ b/reactos/lib/crt/stdio/fputc.c @@ -1,7 +1,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdio/fputchar.c b/reactos/lib/crt/stdio/fputchar.c index 7faa7be615b..8ec8edb312c 100644 --- a/reactos/lib/crt/stdio/fputchar.c +++ b/reactos/lib/crt/stdio/fputchar.c @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include int _fputchar(int c) @@ -32,7 +32,7 @@ int _fputchar(int c) /* * @implemented */ -int _fputwchar(wchar_t c) +wint_t _fputwchar(wint_t c) { return putwc(c, stdout); } diff --git a/reactos/lib/crt/stdio/fputs.c b/reactos/lib/crt/stdio/fputs.c index de54fd02ebc..36c082bbda3 100644 --- a/reactos/lib/crt/stdio/fputs.c +++ b/reactos/lib/crt/stdio/fputs.c @@ -26,51 +26,18 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include "precomp.h" -#include -#include -#include +#include +#include +#include +#include int -fputs(const char *s, FILE *f) +_fputts(const _TCHAR *s, FILE *f) { int r = 0; int c; int unbuffered; - char localbuf[BUFSIZ]; - - unbuffered = f->_flag & _IONBF; - if (unbuffered) - { - f->_flag &= ~_IONBF; - f->_ptr = f->_base = localbuf; - f->_bufsiz = BUFSIZ; - } - - while ((c = *s++)) - r = putc(c, f); - - if (unbuffered) - { - fflush(f); - f->_flag |= _IONBF; - f->_base = NULL; - f->_bufsiz = 0; - f->_cnt = 0; - } - - return(r); -} - -/* - * @implemented - */ -int -fputws(const wchar_t* s, FILE* f) -{ - int r = 0; - int unbuffered; - wchar_t c; - wchar_t localbuf[BUFSIZ]; + _TCHAR localbuf[BUFSIZ]; unbuffered = f->_flag & _IONBF; if (unbuffered) @@ -81,7 +48,7 @@ fputws(const wchar_t* s, FILE* f) } while ((c = *s++)) - r = putwc(c, f); + r = _puttc(c, f); if (unbuffered) { @@ -91,5 +58,7 @@ fputws(const wchar_t* s, FILE* f) f->_bufsiz = 0; f->_cnt = 0; } + return(r); } + diff --git a/reactos/lib/crt/stdio/fputws.c b/reactos/lib/crt/stdio/fputws.c new file mode 100644 index 00000000000..e024d58220c --- /dev/null +++ b/reactos/lib/crt/stdio/fputws.c @@ -0,0 +1,5 @@ + +#define UNICODE +#define _UNICODE + +#include "fputs.c" diff --git a/reactos/lib/crt/stdio/fread.c b/reactos/lib/crt/stdio/fread.c index 8f6136cc629..905e74e76f6 100644 --- a/reactos/lib/crt/stdio/fread.c +++ b/reactos/lib/crt/stdio/fread.c @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* @@ -60,7 +60,7 @@ size_t fread(void *vptr, size_t size, size_t count, FILE *iop) if (to_read >= iop->_bufsiz) { - n_read = _read(fileno(iop), ptr, to_read); + n_read = _read(_fileno(iop), ptr, to_read); if (n_read < 0) iop->_flag |= _IOERR; else if (n_read == 0) diff --git a/reactos/lib/crt/stdio/freopen.c b/reactos/lib/crt/stdio/freopen.c index 881e765e889..738eb199a3c 100644 --- a/reactos/lib/crt/stdio/freopen.c +++ b/reactos/lib/crt/stdio/freopen.c @@ -1,19 +1,20 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* * @implemented */ -FILE *freopen(const char *file, const char *mode, FILE *f) +FILE *_tfreopen(const _TCHAR *file, const _TCHAR *mode, FILE *f) { int fd, rw, oflags=0; - char tbchar; + _TCHAR tbchar; if (file == 0 || mode == 0 || f == 0) return 0; @@ -44,14 +45,14 @@ FILE *freopen(const char *file, const char *mode, FILE *f) else if (tbchar == 'b') oflags |= O_BINARY; else - oflags |= (__fmode & (O_TEXT|O_BINARY)); + oflags |= (_fmode& (O_TEXT|O_BINARY)); - fd = _open(file, oflags, 0666); + fd = _topen(file, oflags, 0666); if (fd < 0) return NULL; if (*mode == 'a') - lseek(fd, 0, SEEK_END); + _lseek(fd, 0, SEEK_END); f->_cnt = 0; f->_file = fd; @@ -67,62 +68,3 @@ FILE *freopen(const char *file, const char *mode, FILE *f) return f; } -/* - * @implemented - */ -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/crt/stdio/fscanf.c b/reactos/lib/crt/stdio/fscanf.c deleted file mode 100644 index 8170ce1603f..00000000000 --- a/reactos/lib/crt/stdio/fscanf.c +++ /dev/null @@ -1,65 +0,0 @@ -/* 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 -#include -#include -#include -#include - - -/* Read formatted input from STREAM according to the format string FORMAT. */ -/* VARARGS2 */ -/* - * @implemented - */ -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; -} - -/* - * @implemented - */ -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 -#include -#include -#include -#include +#include +#include +#include +#include +#include /* @@ -42,7 +42,7 @@ int fseek(FILE *f, long offset, int ptrname) } } - p = lseek(fileno(f), offset, ptrname); + p = _lseek(_fileno(f), offset, ptrname); f->_cnt = 0; f->_ptr = f->_base; f->_flag &= ~_IOUNGETC; @@ -50,7 +50,7 @@ int fseek(FILE *f, long offset, int ptrname) else { p = fflush(f); - return lseek(fileno(f), offset, ptrname) == -1 || p == EOF ? + return _lseek(_fileno(f), offset, ptrname) == -1 || p == EOF ? -1 : 0; } return p==-1 ? -1 : 0; diff --git a/reactos/lib/crt/stdio/fsetpos.c b/reactos/lib/crt/stdio/fsetpos.c index 9bb8e56ca27..0c7fe1daf2b 100644 --- a/reactos/lib/crt/stdio/fsetpos.c +++ b/reactos/lib/crt/stdio/fsetpos.c @@ -1,7 +1,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdio/fsopen.c b/reactos/lib/crt/stdio/fsopen.c index 94d39aa1c90..571dacbc322 100644 --- a/reactos/lib/crt/stdio/fsopen.c +++ b/reactos/lib/crt/stdio/fsopen.c @@ -9,25 +9,26 @@ */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -FILE * __alloc_file(void); /* * @implemented */ -FILE* _fsopen(const char *file, const char *mode, int shflag) +FILE* _tfsopen(const _TCHAR *file, const _TCHAR *mode, int shflag) { FILE *f; int fd, rw, oflags = 0; - char tbchar; + _TCHAR tbchar; int shf; @@ -65,7 +66,7 @@ FILE* _fsopen(const char *file, const char *mode, int shflag) else if (tbchar == 'b') oflags |= O_BINARY; else - oflags |= (__fmode & (O_TEXT|O_BINARY)); + oflags |= (_fmode& (O_TEXT|O_BINARY)); if ( shflag == _SH_DENYNO ) shf = _S_IREAD | _S_IWRITE; @@ -78,14 +79,14 @@ FILE* _fsopen(const char *file, const char *mode, int shflag) else shf = _S_IREAD | _S_IWRITE; - fd = _open(file, oflags, shf); + fd = _topen(file, oflags, shf); if (fd < 0) return NULL; // msvcrt 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); + _lseek(fd, 0, SEEK_END); f->_cnt = 0; f->_file = fd; @@ -101,83 +102,3 @@ FILE* _fsopen(const char *file, const char *mode, int shflag) return f; } -/* - * @implemented - */ -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; - -// msvcrt 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/crt/stdio/ftell.c b/reactos/lib/crt/stdio/ftell.c index 93c048c7daf..c93bc1c7bf9 100644 --- a/reactos/lib/crt/stdio/ftell.c +++ b/reactos/lib/crt/stdio/ftell.c @@ -1,11 +1,11 @@ /* 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 +#include +#include +#include +#include /* @@ -36,7 +36,7 @@ long ftell(FILE *f) else return -1; - tres = lseek(fileno(f), 0L, SEEK_CUR); + tres = _lseek(_fileno(f), 0L, SEEK_CUR); if (tres<0) return tres; tres += adjust; diff --git a/reactos/lib/crt/stdio/fwalk.c b/reactos/lib/crt/stdio/fwalk.c index f1e117ffd1b..f30d438b730 100644 --- a/reactos/lib/crt/stdio/fwalk.c +++ b/reactos/lib/crt/stdio/fwalk.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include // not exported by msvcrt or crtdll diff --git a/reactos/lib/crt/stdio/fwrite.c b/reactos/lib/crt/stdio/fwrite.c index 24d5739a01c..4203526717d 100644 --- a/reactos/lib/crt/stdio/fwrite.c +++ b/reactos/lib/crt/stdio/fwrite.c @@ -1,10 +1,12 @@ -#include -#include -#include -#include -#include + +#include +#include +#include +#include +#include + #define NDEBUG -#include +#include /* @@ -16,32 +18,32 @@ size_t fwrite(const void *vptr, size_t size, size_t count, FILE *iop) unsigned char *ptr = (unsigned char *)vptr; int copy; - DPRINT("fwrite(%x, %d, %d, %x)\n", vptr, size, count, iop); + TRACE("fwrite(%x, %d, %d, %x)", vptr, size, count, iop); to_write = size*count; if (!OPEN4WRITING(iop)) { __set_errno (EINVAL); - return 0; + return(0); } if (iop == NULL) { __set_errno (EINVAL); - return 0; + return(0); } if (ferror (iop)) - return 0; + return(0); if (vptr == NULL || to_write == 0) - return 0; + return(0); if (iop->_base == NULL && !(iop->_flag&_IONBF)) { if (EOF == _flsbuf(*ptr++, iop)) - return 0; + return(0); if (--to_write == 0) - return 1; + return(1); } if (iop->_flag & _IO_LBF) @@ -78,7 +80,7 @@ size_t fwrite(const void *vptr, size_t size, size_t count, FILE *iop) { while (to_write > 0) { - n_written = _write(fileno(iop), ptr, to_write); + n_written = _write(_fileno(iop), ptr, to_write); if (n_written <= 0) { iop->_flag |= _IOERR; @@ -103,12 +105,12 @@ size_t fwrite(const void *vptr, size_t size, size_t count, FILE *iop) iop->_ptr += to_write; iop->_cnt -= to_write; iop->_flag |= _IODIRTY; - return count; + return(count); } } } } } - return count - (to_write/size); + return(count - (to_write/size)); } diff --git a/reactos/lib/crt/stdio/getc.c b/reactos/lib/crt/stdio/getc.c index 83a30053152..5c0392fd10d 100644 --- a/reactos/lib/crt/stdio/getc.c +++ b/reactos/lib/crt/stdio/getc.c @@ -22,10 +22,10 @@ */ #include "precomp.h" -#include -#include -#include -#include +#include +#include +#include +#include //getc can be a macro #undef getc diff --git a/reactos/lib/crt/stdio/getchar.c b/reactos/lib/crt/stdio/getchar.c index 31aecbfd89a..e20e4391233 100644 --- a/reactos/lib/crt/stdio/getchar.c +++ b/reactos/lib/crt/stdio/getchar.c @@ -24,8 +24,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include +#include +#include #undef getchar #undef getwchar diff --git a/reactos/lib/crt/stdio/gets.c b/reactos/lib/crt/stdio/gets.c index 579590928ba..734f586db0c 100644 --- a/reactos/lib/crt/stdio/gets.c +++ b/reactos/lib/crt/stdio/gets.c @@ -25,7 +25,7 @@ */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include char* gets(char* s) { diff --git a/reactos/lib/crt/stdio/getw.c b/reactos/lib/crt/stdio/getw.c index e5eff56ecfe..1960d5149b4 100644 --- a/reactos/lib/crt/stdio/getw.c +++ b/reactos/lib/crt/stdio/getw.c @@ -16,7 +16,7 @@ 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 /* diff --git a/reactos/lib/crt/stdio/perror.c b/reactos/lib/crt/stdio/perror.c index 369e5053e5f..e3511f12d7a 100644 --- a/reactos/lib/crt/stdio/perror.c +++ b/reactos/lib/crt/stdio/perror.c @@ -1,7 +1,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include #ifdef perror diff --git a/reactos/lib/crt/stdio/popen.c b/reactos/lib/crt/stdio/popen.c index 2959fb439d9..803104141ba 100644 --- a/reactos/lib/crt/stdio/popen.c +++ b/reactos/lib/crt/stdio/popen.c @@ -1,58 +1,60 @@ #include "precomp.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include + #define NDEBUG -#include +#include /* * @implemented */ -FILE *_popen (const char *cm, const char *md) /* program name, pipe mode */ +FILE *_tpopen (const _TCHAR *cm, const _TCHAR *md) /* program name, pipe mode */ { - char *szCmdLine=NULL; - char *szComSpec=NULL; - char *s; + _TCHAR *szCmdLine=NULL; + _TCHAR *szComSpec=NULL; + _TCHAR *s; FILE *pf; HANDLE hReadPipe, hWritePipe; BOOL result; - STARTUPINFOA StartupInfo; + STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; - DPRINT("_popen('%s', '%s')\n", cm, md); + TRACE(MK_STR(_tpopen)"('%"sT"', '%"sT"')\n", cm, md); if (cm == NULL) - return NULL; + return( NULL ); - szComSpec = getenv("COMSPEC"); + szComSpec = _tgetenv(_T("COMSPEC")); if (szComSpec == NULL) { - szComSpec = "cmd.exe"; + szComSpec = _T("cmd.exe"); } - s = max(strrchr(szComSpec, '\\'), strrchr(szComSpec, '/')); + s = max(_tcsrchr(szComSpec, '\\'), _tcsrchr(szComSpec, '/')); if (s == NULL) s = szComSpec; else s++; - szCmdLine = malloc(strlen(s) + 4 + strlen(cm) + 1); + szCmdLine = malloc((_tcslen(s) + 4 + _tcslen(cm) + 1) * sizeof(_TCHAR)); if (szCmdLine == NULL) { return NULL; } - strcpy(szCmdLine, s); - s = strrchr(szCmdLine, '.'); + _tcscpy(szCmdLine, s); + s = _tcsrchr(szCmdLine, '.'); if (s) *s = 0; - strcat(szCmdLine, " /C "); - strcat(szCmdLine, cm); + _tcscat(szCmdLine, _T(" /C ")); + _tcscat(szCmdLine, cm); if ( !CreatePipe(&hReadPipe,&hWritePipe,&sa,1024)) { @@ -60,8 +62,8 @@ FILE *_popen (const char *cm, const char *md) /* program name, pipe mode */ return NULL; } - memset(&StartupInfo, 0, sizeof(STARTUPINFOA)); - StartupInfo.cb = sizeof(STARTUPINFOA); + memset(&StartupInfo, 0, sizeof(STARTUPINFO)); + StartupInfo.cb = sizeof(STARTUPINFO); if (*md == 'r' ) { StartupInfo.hStdOutput = hWritePipe; @@ -72,7 +74,7 @@ FILE *_popen (const char *cm, const char *md) /* program name, pipe mode */ StartupInfo.dwFlags |= STARTF_USESTDHANDLES; } - result = CreateProcessA(szComSpec, + result = CreateProcess(szComSpec, szCmdLine, NULL, NULL, @@ -95,130 +97,34 @@ FILE *_popen (const char *cm, const char *md) /* program name, pipe mode */ if ( *md == 'r' ) { - pf = _fdopen(__fileno_alloc(hReadPipe, __fmode) , "r"); + pf = _tfdopen(alloc_fd(hReadPipe, split_oflags(_fmode)) , _T("r")); CloseHandle(hWritePipe); } else { - pf = _fdopen( __fileno_alloc(hWritePipe, __fmode) , "w"); + pf = _tfdopen( alloc_fd(hWritePipe, split_oflags(_fmode)) , _T("w")); CloseHandle(hReadPipe); } - pf->_name_to_remove = ProcessInformation.hProcess; + pf->_tmpfname = ProcessInformation.hProcess; - return pf; + return( pf ); } +#ifndef _UNICODE /* * @implemented */ int _pclose (FILE *pp) { + TRACE("_pclose(%x)",pp); + fclose(pp); - if (!TerminateProcess(pp->_name_to_remove,0)) - return -1; - return 0; + if (!TerminateProcess(pp->_tmpfname ,0)) + return( -1 ); + return( 0 ); } +#endif -/* - * @implemented - */ -FILE *_wpopen (const wchar_t *cm, const wchar_t *md) /* program name, pipe mode */ -{ - wchar_t *szCmdLine=NULL; - wchar_t *szComSpec=NULL; - wchar_t *s; - FILE *pf; - HANDLE hReadPipe, hWritePipe; - BOOL result; - STARTUPINFOW StartupInfo; - PROCESS_INFORMATION ProcessInformation; - SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; - - DPRINT("_wpopen('%S', '%S')\n", cm, md); - - if (cm == NULL) - return NULL; - - szComSpec = _wgetenv(L"COMSPEC"); - - if (szComSpec == NULL) - { - szComSpec = L"cmd.exe"; - } - - s = max(wcsrchr(szComSpec, L'\\'), wcsrchr(szComSpec, L'/')); - if (s == NULL) - s = szComSpec; - else - s++; - - szCmdLine = malloc((wcslen(s) + 4 + wcslen(cm) + 1) * sizeof(wchar_t)); - if (szCmdLine == NULL) - { - return NULL; - } - - wcscpy(szCmdLine, s); - s = wcsrchr(szCmdLine, L'.'); - if (s) - *s = 0; - wcscat(szCmdLine, L" /C "); - wcscat(szCmdLine, cm); - - if ( !CreatePipe(&hReadPipe,&hWritePipe,&sa,1024)) - { - free (szCmdLine); - return NULL; - } - - memset(&StartupInfo, 0, sizeof(STARTUPINFOW)); - StartupInfo.cb = sizeof(STARTUPINFOW); - - if (*md == L'r' ) { - StartupInfo.hStdOutput = hWritePipe; - StartupInfo.dwFlags |= STARTF_USESTDHANDLES; - } - else if ( *md == L'w' ) { - StartupInfo.hStdInput = hReadPipe; - StartupInfo.dwFlags |= STARTF_USESTDHANDLES; - } - - result = CreateProcessW(szComSpec, - szCmdLine, - NULL, - NULL, - TRUE, - 0, - NULL, - NULL, - &StartupInfo, - &ProcessInformation); - free (szCmdLine); - - if (result == FALSE) - { - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - return NULL; - } - - CloseHandle(ProcessInformation.hThread); - - if ( *md == L'r' ) - { - pf = _wfdopen(__fileno_alloc(hReadPipe, __fmode) , L"r"); - CloseHandle(hWritePipe); - } - else - { - pf = _wfdopen( __fileno_alloc(hWritePipe, __fmode) , L"w"); - CloseHandle(hReadPipe); - } - - pf->_name_to_remove = ProcessInformation.hProcess; - - return pf; -} diff --git a/reactos/lib/crt/stdio/printf.c b/reactos/lib/crt/stdio/printf.c index 9d57e14c1c9..d67eb38586e 100644 --- a/reactos/lib/crt/stdio/printf.c +++ b/reactos/lib/crt/stdio/printf.c @@ -16,35 +16,21 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include - +#include +#include +#include +#include /* * @implemented */ -int printf(const char* format, ...) +int _tprintf(const _TCHAR* format, ...) { va_list arg; int done; va_start(arg, format); - done = vprintf(format, arg); - va_end(arg); - return done; -} - -/* - * @implemented - */ -int wprintf(const wchar_t* format, ...) -{ - va_list arg; - int done; - - va_start(arg, format); - done = vwprintf(format, arg); + done = _vtprintf(format, arg); va_end(arg); return done; } diff --git a/reactos/lib/crt/stdio/putc.c b/reactos/lib/crt/stdio/putc.c index 99915bb8e6e..3d6ba61f234 100644 --- a/reactos/lib/crt/stdio/putc.c +++ b/reactos/lib/crt/stdio/putc.c @@ -25,10 +25,10 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include "precomp.h" -#include -#include -#include -#include +#include +#include +#include +#include // putc can be a macro #undef putc @@ -65,7 +65,7 @@ int putc(int c, FILE* fp) /* * @implemented */ -int putwc(wint_t c, FILE* fp) +wint_t putwc(wint_t c, FILE* fp) { // valid stream macro should check that fp is dword aligned if (!__validfp(fp)) { diff --git a/reactos/lib/crt/stdio/putchar.c b/reactos/lib/crt/stdio/putchar.c index 7c3030cc9c4..be4b5161bbd 100644 --- a/reactos/lib/crt/stdio/putchar.c +++ b/reactos/lib/crt/stdio/putchar.c @@ -8,7 +8,9 @@ * UPDATE HISTORY: * 28/12/98: Created */ -#include +#include +#include +#include #undef putc #undef putchar @@ -18,21 +20,11 @@ /* * @implemented */ -int putchar(int c) +_TINT _puttchar(_TINT c) { - int r = putc(c, stdout); + _TINT r = _puttc(c, stdout); if (stdout->_flag & _IO_LBF) fflush(stdout); return r; } -/* - * @implemented - */ -wint_t putwchar(wint_t c) -{ - wint_t r = putwc(c, stdout); - if (stdout->_flag & _IO_LBF) - fflush(stdout); - return r; -} diff --git a/reactos/lib/crt/stdio/puts.c b/reactos/lib/crt/stdio/puts.c index 6b1867c1706..87ca5661734 100644 --- a/reactos/lib/crt/stdio/puts.c +++ b/reactos/lib/crt/stdio/puts.c @@ -1,8 +1,8 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include "precomp.h" -#include -#include -#include +#include +#include +#include #undef putchar #undef putwchar diff --git a/reactos/lib/crt/stdio/putw.c b/reactos/lib/crt/stdio/putw.c index dab2f31ee0c..10d2b888283 100644 --- a/reactos/lib/crt/stdio/putw.c +++ b/reactos/lib/crt/stdio/putw.c @@ -17,7 +17,7 @@ * Cambridge, MA 02139, USA. */ -#include +#include /* diff --git a/reactos/lib/crt/stdio/putwchar.c b/reactos/lib/crt/stdio/putwchar.c new file mode 100644 index 00000000000..cdf1386ce75 --- /dev/null +++ b/reactos/lib/crt/stdio/putwchar.c @@ -0,0 +1,4 @@ +#define UNICODE +#define _UNICODE + +#include "putchar.c" diff --git a/reactos/lib/crt/stdio/remove.c b/reactos/lib/crt/stdio/remove.c index 3f946b400f0..37909173cbc 100644 --- a/reactos/lib/crt/stdio/remove.c +++ b/reactos/lib/crt/stdio/remove.c @@ -1,30 +1,21 @@ #include "precomp.h" -#include -#include +#include +#include +#include #define NDEBUG -#include +#include /* * @implemented */ -int remove(const char *fn) +int _tremove(const _TCHAR *fn) { int result = 0; - DPRINT("remove('%s')\n", fn); - if (!DeleteFileA(fn)) + DPRINT(MK_STR(_tremove)"('%"sT"')\n", fn); + if (!DeleteFile(fn)) result = -1; DPRINT("%d\n", result); return result; } -/* - * @implemented - */ -int _wremove(const wchar_t *fn) -{ - DPRINT("_wremove('%S')\n", fn); - if (!DeleteFileW(fn)) - return -1; - return 0; -} diff --git a/reactos/lib/crt/stdio/rename.c b/reactos/lib/crt/stdio/rename.c index fff877c8eb9..962ed2f46b4 100644 --- a/reactos/lib/crt/stdio/rename.c +++ b/reactos/lib/crt/stdio/rename.c @@ -1,17 +1,17 @@ #include "precomp.h" -#include -#include - +#include +#include +#include /* * @implemented */ -int rename(const char* old_, const char* new_) +int _trename(const _TCHAR* old_, const _TCHAR* new_) { if (old_ == NULL || new_ == NULL) return -1; - if (!MoveFileA(old_, new_)) + if (!MoveFile(old_, new_)) return -1; return 0; diff --git a/reactos/lib/crt/stdio/rewind.c b/reactos/lib/crt/stdio/rewind.c index e3b6703e43e..7e5acce69b4 100644 --- a/reactos/lib/crt/stdio/rewind.c +++ b/reactos/lib/crt/stdio/rewind.c @@ -1,8 +1,8 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* @@ -11,7 +11,7 @@ void rewind(FILE *f) { fflush(f); - lseek(fileno(f), 0L, SEEK_SET); + _lseek(_fileno(f), 0L, SEEK_SET); f->_cnt = 0; f->_ptr = f->_base; f->_flag &= ~(_IOERR|_IOEOF|_IOAHEAD); diff --git a/reactos/lib/crt/stdio/rmtmp.c b/reactos/lib/crt/stdio/rmtmp.c index 1d2a8c51c99..14926b8921e 100644 --- a/reactos/lib/crt/stdio/rmtmp.c +++ b/reactos/lib/crt/stdio/rmtmp.c @@ -9,25 +9,10 @@ * NOTE Not tested. */ -#include -#include -#include +#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; @@ -35,7 +20,7 @@ extern __file_rec *__file_rec_list; int _rmtmp( void ) { /* -loop files and check for name_to_remove +loop files and check for _tmpfname */ __file_rec *fr = __file_rec_list; __file_rec **last_fr = &__file_rec_list; @@ -51,9 +36,9 @@ loop files and check for name_to_remove /* 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); + if (fr->files[i]->_tmpfname != NULL) { + if ( _access(fr->files[i]->_tmpfname ,W_OK) ) { + strcpy(temp_name,fr->files[i]->_tmpfname ); fclose(fr->files[i]); remove(temp_name); total_closed++; diff --git a/reactos/lib/crt/stdio/scanf.c b/reactos/lib/crt/stdio/scanf.c deleted file mode 100644 index 9cdc4d82172..00000000000 --- a/reactos/lib/crt/stdio/scanf.c +++ /dev/null @@ -1,64 +0,0 @@ -/* 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 -#include -#include -#include -#include - - -/* Read formatted input from stdin according to the format string FORMAT. */ -/* VARARGS1 */ -/* - * @implemented - */ -int scanf(const char *format, ...) -{ - va_list arg; - int done; - - va_start(arg, format); - done = __vscanf(format, arg); - va_end(arg); - - return done; -} - -/* - * @implemented - */ -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 -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdio/setvbuf.c b/reactos/lib/crt/stdio/setvbuf.c index d0dadf0c786..3b4ea652da5 100644 --- a/reactos/lib/crt/stdio/setvbuf.c +++ b/reactos/lib/crt/stdio/setvbuf.c @@ -1,11 +1,11 @@ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/stdio/sprintf.c b/reactos/lib/crt/stdio/sprintf.c index 6a020ae06d8..1e35c0fb0f4 100644 --- a/reactos/lib/crt/stdio/sprintf.c +++ b/reactos/lib/crt/stdio/sprintf.c @@ -18,46 +18,32 @@ 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 +#include +#include +#include #include -#include +#include +#include #undef sprintf #undef wsprintf -/* - * @implemented - */ -int -sprintf(char *str, const char *fmt, ...) -{ - va_list arg; - int done; - - va_start (arg, fmt); - done = vsprintf (str, fmt, arg); - va_end (arg); - return done; -} /* * @implemented */ int -swprintf(wchar_t *str, const wchar_t *fmt, ...) +_stprintf(_TCHAR *str, const _TCHAR *fmt, ...) { va_list arg; int done; va_start (arg, fmt); - done = vswprintf (str, fmt, arg); + done = _vstprintf (str, fmt, arg); va_end (arg); return done; } - /* Write formatted output into S, according to the format string FORMAT, writing no more than MAXLEN characters. */ /* VARARGS3 */ @@ -65,29 +51,13 @@ swprintf(wchar_t *str, const wchar_t *fmt, ...) * @implemented */ int -_snprintf (char *s, size_t maxlen,const char *format, ...) +_sntprintf (_TCHAR *s, size_t maxlen,const _TCHAR *format, ...) { va_list arg; int done; va_start (arg, format); - done = _vsnprintf (s, maxlen, format, arg); - va_end (arg); - - return done; -} - -/* - * @implemented - */ -int -_snwprintf (wchar_t *s, size_t maxlen,const wchar_t *format, ...) -{ - va_list arg; - int done; - - va_start (arg, format); - done = _vsnwprintf (s, maxlen, format, arg); + done = _vsntprintf(s, maxlen, format, arg); va_end (arg); return done; diff --git a/reactos/lib/crt/stdio/sscanf.c b/reactos/lib/crt/stdio/sscanf.c deleted file mode 100644 index 7868addf516..00000000000 --- a/reactos/lib/crt/stdio/sscanf.c +++ /dev/null @@ -1,71 +0,0 @@ -/* 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 -#include -#include -#include -#include - - -/* Read formatted input from S, according to the format string FORMAT. */ -/* VARARGS2 */ -/* - * @implemented - */ -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; -} - -/* - * @implemented - */ -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 -#include +#include +#include -FILE _iob[5] = +FILE _iob[20] = { // stdin { @@ -21,18 +21,6 @@ FILE _iob[5] = NULL, 0, NULL, _IOWRT | _IONBF, 2,0,0, NULL -}, - // stdaux -{ - NULL, 0, NULL, - _IOREAD | _IOWRT | _IONBF, - 3,0,0, NULL -}, - // stdprn -{ - NULL, 0, NULL, - _IOWRT | _IONBF, - 4, 0,0,NULL } }; diff --git a/reactos/lib/crt/stdio/swprintf.c b/reactos/lib/crt/stdio/swprintf.c new file mode 100644 index 00000000000..81205d770ac --- /dev/null +++ b/reactos/lib/crt/stdio/swprintf.c @@ -0,0 +1,4 @@ +#define UNICODE +#define _UNICODE + +#include "sprintf.c" diff --git a/reactos/lib/crt/stdio/tempnam.c b/reactos/lib/crt/stdio/tempnam.c index 294a51cc202..56ab13fcf1e 100644 --- a/reactos/lib/crt/stdio/tempnam.c +++ b/reactos/lib/crt/stdio/tempnam.c @@ -1,25 +1,25 @@ #include "precomp.h" -#include -#include - +#include +#include +#include /* * @implemented */ -char* _tempnam(const char* dir,const char* prefix) +_TCHAR* _ttempnam(const _TCHAR* dir,const _TCHAR* prefix) { - char* TempFileName = malloc(MAX_PATH); - char* d; + _TCHAR* TempFileName = malloc(MAX_PATH*sizeof(_TCHAR)); + _TCHAR* d; if (dir == NULL) - d = getenv("TMP"); + d = _tgetenv(_T("TMP")); else - d = (char*)dir; + d = (_TCHAR*)dir; #ifdef _MSVCRT_LIB_ // TODO: check on difference? - if (GetTempFileNameA(d, prefix, 1, TempFileName) == 0) { + if (GetTempFileName(d, prefix, 1, TempFileName) == 0) { #else// TODO: FIXME: review which is correct - if (GetTempFileNameA(d, prefix, 0, TempFileName) == 0) { + if (GetTempFileName(d, prefix, 0, TempFileName) == 0) { #endif /*_MSVCRT_LIB_*/ free(TempFileName); diff --git a/reactos/lib/crt/stdio/tmpfile.c b/reactos/lib/crt/stdio/tmpfile.c index b188dece4a3..dc92d175cbd 100644 --- a/reactos/lib/crt/stdio/tmpfile.c +++ b/reactos/lib/crt/stdio/tmpfile.c @@ -3,15 +3,15 @@ /* 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 +#include //#include -#include -#include -#include +#include +#include +#include FILE * __alloc_file(void); @@ -56,13 +56,13 @@ tmpfile(void) 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->_tmpfname = n_t_r; + strcpy(f->_tmpfname , temp_name); f->_base = f->_ptr = NULL; } else { - close(temp_fd); + _close(temp_fd); remove(temp_name); free(n_t_r); } diff --git a/reactos/lib/crt/stdio/tmpnam.c b/reactos/lib/crt/stdio/tmpnam.c index b59075335c6..7b50a8121ee 100644 --- a/reactos/lib/crt/stdio/tmpnam.c +++ b/reactos/lib/crt/stdio/tmpnam.c @@ -1,19 +1,19 @@ #include "precomp.h" -#include -#include - +#include +#include +#include /* * @implemented */ -char* tmpnam(char* s) +_TCHAR* _ttmpnam(_TCHAR* s) { - char PathName[MAX_PATH]; - static char static_buf[MAX_PATH]; + _TCHAR PathName[MAX_PATH]; + static _TCHAR static_buf[MAX_PATH]; - GetTempPathA(MAX_PATH, PathName); - GetTempFileNameA(PathName, "ARI", 007, static_buf); - strcpy(s,static_buf); + GetTempPath(MAX_PATH, PathName); + GetTempFileName(PathName, _T("ARI"), 007, static_buf); + _tcscpy(s,static_buf); return s; } diff --git a/reactos/lib/crt/stdio/ungetc.c b/reactos/lib/crt/stdio/ungetc.c index cb5340bd66e..ef2ee127869 100644 --- a/reactos/lib/crt/stdio/ungetc.c +++ b/reactos/lib/crt/stdio/ungetc.c @@ -1,76 +1,51 @@ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include +#include +#include +#include +#include +#include /* * @implemented */ -int ungetc(int c, FILE *f) +_TINT _ungettc(_TINT c, FILE *f) { if (!__validfp (f) || !OPEN4READING(f)) { __set_errno (EINVAL); - return EOF; + return _TEOF; } - if (c == EOF) - return EOF; + if (c == _TEOF) + return _TEOF; if (f->_ptr == NULL || f->_base == NULL) - return EOF; + return _TEOF; if (f->_ptr == f->_base) { if (f->_cnt == 0) - f->_ptr++; + f->_ptr+=sizeof(_TCHAR); else - return EOF; + return _TEOF; } - f->_cnt++; - f->_ptr--; - if (*f->_ptr != c) + f->_cnt+=sizeof(_TCHAR); + f->_ptr-=sizeof(_TCHAR); + +#if 1 + if (*((_TCHAR*)(f->_ptr)) != c) { f->_flag |= _IOUNGETC; - *f->_ptr = c; + *((_TCHAR*)(f->_ptr)) = c; } - return c; -} - - -/* - * @implemented - */ -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); - +#else + /* This is the old unicode version. Dunno what version is most correct. -Gunnar */ f->_flag |= _IOUNGETC; - *((wchar_t *)(f->_ptr)) = c; + *((_TCHAR*)(f->_ptr)) = c; +#endif return c; } + diff --git a/reactos/lib/crt/stdio/ungetwc.c b/reactos/lib/crt/stdio/ungetwc.c new file mode 100644 index 00000000000..1ff851fca98 --- /dev/null +++ b/reactos/lib/crt/stdio/ungetwc.c @@ -0,0 +1,4 @@ +#define UNICODE +#define _UNICODE + +#include "ungetc.c" diff --git a/reactos/lib/crt/stdio/vfprintf.c b/reactos/lib/crt/stdio/vfprintf.c index 8d2c0f3d510..70e6568cc69 100644 --- a/reactos/lib/crt/stdio/vfprintf.c +++ b/reactos/lib/crt/stdio/vfprintf.c @@ -1,17 +1,16 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -#include -#include -#include +#include +#include +#include #ifdef __USE_W32API #include #endif -int _isnanl(double x); -int _isinfl(double x); -int _isnan(double x); -int _isinf(double x); + + +extern int __mb_cur_max; @@ -27,7 +26,7 @@ int vfprintf(FILE* f, const char* fmt, va_list ap) char localbuf[BUFSIZ]; #if 0 - __fileno_lock(fileno(f)); + __fileno_lock(_fileno(f)); #endif if (f->_flag & _IONBF) { f->_flag &= ~_IONBF; @@ -43,7 +42,7 @@ int vfprintf(FILE* f, const char* fmt, va_list ap) len = __vfprintf(f,fmt, ap); } #if 0 - __fileno_unlock(fileno(f)); + __fileno_unlock(_fileno(f)); #endif return (ferror(f) ? EOF : len); } @@ -64,14 +63,13 @@ int vfprintf(FILE* f, const char* fmt, va_list ap) * Appropiated for the reactos kernel, March 1998 -- David Welch */ -#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define ZEROPAD 1 /* pad with zero */ @@ -485,7 +483,7 @@ static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int pre } for (i = 0; i < len; ++i) { -#define MB_CUR_MAX 1 +//#define MB_CUR_MAX 1 char mb[MB_CUR_MAX]; int mbcount, j; mbcount = wctomb(mb, *sw++); diff --git a/reactos/lib/crt/stdio/vfscanf.c b/reactos/lib/crt/stdio/vfscanf.c deleted file mode 100644 index d4e7de6cb5d..00000000000 --- a/reactos/lib/crt/stdio/vfscanf.c +++ /dev/null @@ -1,1229 +0,0 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 "precomp.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#ifdef __USE_W32API -int __set_errno(int err); -#else -#include -#endif - -/* The internal entry points for `strtoX' take an extra flag argument - saying whether or not to parse locale-dependent number grouping. */ - -double __strtod_internal (const char *__nptr,char **__endptr, int __group); -float __strtof_internal (const char *__nptr, char **__endptr,int __group); -long double __strtold_internal (const char *__nptr,char **__endptr, int __group); -long int __strtol_internal (const char *__nptr, char **__endptr, int __base, int __group); -unsigned long int __strtoul_internal (const char *__nptr, char **__endptr, int __base, int __group); - - -#include // robd -//#ifdef __GNUC__ -//#define HAVE_LONGLONG -//#define LONGLONG LONGLONG -//#else -//#define LONGLONG long -//#endif - -/* Those are flags in the conversion format. */ -# define LONG 0x001 /* l: long or double */ -# define LONGDBL 0x002 /* L: LONGLONG or long double */ -# define SHORT 0x004 /* h: short */ -# define SUPPRESS 0x008 /* *: suppress assignment */ -# define POINTER 0x010 /* weird %p pointer (`fake hex') */ -# define NOSKIP 0x020 /* do not skip blanks */ -# define WIDTH 0x040 /* width was given */ -# define GROUP 0x080 /* ': group numbers */ -# define MALLOC 0x100 /* a: malloc strings */ - -# define TYPEMOD (LONG|LONGDBL|SHORT) - - -# define UNGETC(c, s) ((void) (((wint_t)c) != ((wint_t)EOF) && --read_in), ungetc (c, s)) -# define inchar() ((c = getc (s)), (void) (c != EOF && ++read_in), c) -# define encode_error() do { \ - funlockfile (s); \ - __set_errno (EILSEQ); \ - return done; \ - } while (0) -# define conv_error() do { \ - funlockfile (s); \ - return done; \ - } while (0) -# define input_error() do { \ - funlockfile (s); \ - return done ? 0 : EOF; \ - } while (0) -# define memory_error() do { \ - funlockfile (s); \ - __set_errno (ENOMEM); \ - return EOF; \ - } while (0) -# define ARGCHECK(s, format) \ - do \ - { \ - /* Check file argument for consistence. */ \ - if (!__validfp (s) || !s->__mode.__read) \ - { \ - __set_errno (EBADF); \ - return EOF; \ - } \ - else if (format == NULL) \ - { \ - __set_errno (EINVAL); \ - return EOF; \ - } \ - } while (0) - -# define flockfile(S) /* nothing */ -# define funlockfile(S) /* nothing */ - -# define ADDW(Ch) \ -do{ \ - if (wpsize == wpmax) \ - { \ - char *old = wp; \ - wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax; \ - wp = (char *) malloc (wpmax); \ - if (old != NULL) \ - { \ - memcpy (wp, old, wpsize); \ - free(old); \ - } \ - } \ - wp[wpsize++] = (Ch); \ -}while(0) - - -int __vfscanf (FILE *s, const char *format, va_list argptr) -{ - va_list arg; - register const char *f = format; - register unsigned char fc; /* Current character of the format. */ - register size_t done = 0; /* Assignments done. */ - register size_t read_in = 0; /* Chars read in. */ - register int c = 0; /* Last char read. */ - register int width; /* Maximum field width. */ - register int flags; /* Modifiers for current format element. */ - - /* Status for reading F-P nums. */ - char got_dot, got_e, negative; - /* If a [...] is a [^...]. */ - char not_in; - /* Base for integral numbers. */ - int base; - /* Signedness for integral numbers. */ - int number_signed; - /* Decimal point character. */ - wchar_t decimal = '.'; - /* The thousands character of the current locale. */ - wchar_t thousands = ','; - /* Integral holding variables. */ - union - { - LONGLONG q; - ULONGLONG uq; - long int l; - unsigned long int ul; - } num; - /* Character-buffer pointer. */ - char *str = NULL; - wchar_t *wstr = NULL; - char **strptr = NULL; - size_t strsize = 0; - /* We must not react on white spaces immediately because they can - possibly be matched even if in the input stream no character is - available anymore. */ - int skip_space = 0; - /* Workspace. */ - char *wp = NULL; /* Workspace. */ - size_t wpmax = 0; /* Maximal size of workspace. */ - size_t wpsize = 0; /* Currently used bytes in workspace. */ - char *tw; /* Temporary pointer. */ - -#ifdef __va_copy - - __va_copy (arg, argptr); -#else - - arg = (va_list) argptr; -#endif - - - - /* Run through the format string. */ - while (*f != '\0') - { - unsigned int argpos; - /* Extract the next argument, which is of type TYPE. - For a %N$... spec, this is the Nth argument from the beginning; - otherwise it is the next argument after the state now in ARG. */ -#define ARG(type) va_arg(argptr,type) - - if (!isascii (*f)) - { - /* Non-ASCII, may be a multibyte. */ - // int len = mblen (f, strlen (f)); - int len =1; - if (len > 0) - { - do - { - c = inchar (); - if (c == EOF) - input_error (); - else if (c != *f++) - { - UNGETC (c, s); - conv_error (); - } - } - while (--len > 0); - continue; - } - } - - fc = *f++; - if (fc != '%') - { - /* Remember to skip spaces. */ - if (isspace (fc)) - { - skip_space = 1; - continue; - } - - /* Read a character. */ - c = inchar (); - - /* Characters other than format specs must just match. */ - if (c == EOF) - input_error (); - - /* We saw white space char as the last character in the format - string. Now it's time to skip all leading white space. */ - if (skip_space) - { - while (isspace (c)) - if (inchar () == EOF && *_errno() == EINTR) - conv_error (); - skip_space = 0; - } - - if (c != fc) - { - UNGETC (c, s); - conv_error (); - } - - continue; - } - - /* This is the start of the conversion string. */ - flags = 0; - - /* Initialize state of modifiers. */ - argpos = 0; - - /* Prepare temporary buffer. */ - wpsize = 0; - - /* Check for a positional parameter specification. */ - if (isdigit (*f)) - { - argpos = *f++ - '0'; - while (isdigit (*f)) - argpos = argpos * 10 + (*f++ - '0'); - if (*f == '$') - ++f; - else - { - /* Oops; that was actually the field width. */ - width = argpos; - flags |= WIDTH; - argpos = 0; - goto got_width; - } - } - - /* Check for the assignment-suppressing and the number grouping flag. */ - while (*f == '*' || *f == '\'') - switch (*f++) - { - case '*': - flags |= SUPPRESS; - break; - case '\'': - flags |= GROUP; - break; - } - - /* We have seen width. */ - if (isdigit (*f)) - flags |= WIDTH; - - /* Find the maximum field width. */ - width = 0; - while (isdigit (*f)) - { - width *= 10; - width += *f++ - '0'; - } -got_width: - if (width == 0) - width = -1; - - /* Check for type modifiers. */ - while (*f == 'h' || *f == 'l' || *f == 'L' || *f == 'a' || *f == 'q') - switch (*f++) - { - case 'h': - /* int's are short int's. */ - if (flags & TYPEMOD) - /* Signal illegal format element. */ - conv_error (); - flags |= SHORT; - break; - case 'l': - if (flags & (SHORT|LONGDBL)) - conv_error (); - else if (flags & LONG) - { - /* A double `l' is equivalent to an `L'. */ - flags &= ~LONG; - flags |= LONGDBL; - } - else - /* int's are long int's. */ - flags |= LONG; - break; - case 'q': - case 'L': - /* double's are long double's, and int's are LONGLONG int's. */ - if (flags & TYPEMOD) - /* Signal illegal format element. */ - conv_error (); - flags |= LONGDBL; - break; - case 'a': - if (flags & TYPEMOD) - /* Signal illegal format element. */ - conv_error (); - /* String conversions (%s, %[) take a `char **' - arg and fill it in with a malloc'd pointer. */ - flags |= MALLOC; - break; - } - - /* End of the format string? */ - if (*f == '\0') - conv_error (); - - /* We must take care for EINTR errors. */ - if (c == EOF && *_errno() == EINTR) - input_error (); - - /* Find the conversion specifier. */ - fc = *f++; - if (skip_space || (fc != '[' && fc != 'c' && fc != 'C' && fc != 'n')) - { - /* Eat whitespace. */ - do - if (inchar () == EOF && *_errno() == EINTR) - input_error (); - while (isspace (c)) - ; - UNGETC (c, s); - skip_space = 0; - } - - switch (fc) - { - case '%': /* Must match a literal '%'. */ - c = inchar (); - if (c != fc) - { - UNGETC (c, s); - conv_error (); - } - break; - - case 'n': /* Answer number of assignments done. */ - /* Corrigendum 1 to ISO C 1990 describes the allowed flags - with the 'n' conversion specifier. */ - if (!(flags & SUPPRESS)) - { - /* Don't count the read-ahead. */ - if (flags & LONGDBL) - *ARG (long int *) = read_in; - else if (flags & LONG) - *ARG (long int *) = read_in; - else if (flags & SHORT) - *ARG (short int *) = read_in; - else - *ARG (int *) = read_in; - -#ifdef NO_BUG_IN_ISO_C_CORRIGENDUM_1 - /* We have a severe problem here. The ISO C standard - contradicts itself in explaining the effect of the %n - format in `scanf'. While in ISO C:1990 and the ISO C - Amendement 1:1995 the result is described as - - Execution of a %n directive does not effect the - assignment count returned at the completion of - execution of the f(w)scanf function. - - in ISO C Corrigendum 1:1994 the following was added: - - Subclause 7.9.6.2 - Add the following fourth example: - In: - #include - int d1, d2, n1, n2, i; - i = sscanf("123", "%d%n%n%d", &d1, &n1, &n2, &d2); - the value 123 is assigned to d1 and the value3 to n1. - Because %n can never get an input failure the value - of 3 is also assigned to n2. The value of d2 is not - affected. The value 3 is assigned to i. - - We go for now with the historically correct code fro ISO C, - i.e., we don't count the %n assignments. When it ever - should proof to be wrong just remove the #ifdef above. */ - ++done; -#endif - - } - break; - - case 'c': /* Match characters. */ - if ((flags & LONG) == 0) - { - if (!(flags & SUPPRESS)) - { - str = ARG (char *); - if (str == NULL) - conv_error (); - } - - c = inchar (); - if (c == EOF) - input_error (); - - if (width == -1) - width = 1; - - if (!(flags & SUPPRESS)) - { - do - *str++ = c; - while (--width > 0 && inchar () != EOF); - } - else - while (--width > 0 && inchar () != EOF) - ; - - if (width > 0) - /* I.e., EOF was read. */ - --read_in; - - if (!(flags & SUPPRESS)) - ++done; - - break; - } - /* FALLTHROUGH */ - case 'C': - /* Get UTF-8 encoded wide character. Here we assume (as in - other parts of the libc) that we only have to handle - UTF-8. */ - { - wint_t val; - size_t cnt = 0; - int first = 1; - - if (!(flags & SUPPRESS)) - { - wstr = ARG (wchar_t *); - if (str == NULL) - conv_error (); - } - - do - { -#define NEXT_WIDE_CHAR(First) \ - c = inchar (); \ - if (c == EOF) { \ - /* EOF is only an error for the first character. */ \ - if (First) { \ - input_error (); \ - } \ - else \ - { \ - --read_in; \ - break; \ - } \ - } \ - val = c; \ - if (val >= 0x80) \ - { \ - if ((c & 0xc0) == 0x80 || (c & 0xfe) == 0xfe) \ - encode_error (); \ - if ((c & 0xe0) == 0xc0) \ - { \ - /* We expect two bytes. */ \ - cnt = 1; \ - val &= 0x1f; \ - } \ - else if ((c & 0xf0) == 0xe0) \ - { \ - /* We expect three bytes. */ \ - cnt = 2; \ - val &= 0x0f; \ - } \ - else if ((c & 0xf8) == 0xf0) \ - { \ - /* We expect four bytes. */ \ - cnt = 3; \ - val &= 0x07; \ - } \ - else if ((c & 0xfc) == 0xf8) \ - { \ - /* We expect five bytes. */ \ - cnt = 4; \ - val &= 0x03; \ - } \ - else \ - { \ - /* We expect six bytes. */ \ - cnt = 5; \ - val &= 0x01; \ - } \ - \ - do \ - { \ - c = inchar (); \ - if (c == EOF \ - || (c & 0xc0) == 0x80 || (c & 0xfe) == 0xfe) \ - encode_error (); \ - val <<= 6; \ - val |= c & 0x3f; \ - } \ - while (--cnt > 0); \ - } \ - \ - if (!(flags & SUPPRESS)) \ - *wstr++ = val; \ - first = 0 - - NEXT_WIDE_CHAR (first); - } - while (--width > 0); - - if (width > 0) - /* I.e., EOF was read. */ - --read_in; - - if (!(flags & SUPPRESS)) - ++done; - } - break; - - case 's': /* Read a string. */ - if (flags & LONG) - /* We have to process a wide character string. */ - goto wide_char_string; - -#define STRING_ARG(Str, Type) \ - if (!(flags & SUPPRESS)) \ - { \ - if (flags & MALLOC) \ - { \ - /* The string is to be stored in a malloc'd buffer. */ \ - strptr = ARG (char **); \ - if (strptr == NULL) \ - conv_error (); \ - /* Allocate an initial buffer. */ \ - strsize = 100; \ - *strptr = malloc (strsize * sizeof (Type)); \ - Str = (Type *) *strptr; \ - } \ - else \ - Str = ARG (Type *); \ - if (Str == NULL) \ - conv_error (); \ - } - - STRING_ARG (str, char); - - c = inchar (); - if (c == EOF) - input_error (); - - do - { - if (isspace (c)) - { - UNGETC (c, s); - break; - } -#define STRING_ADD_CHAR(Str, c, Type) \ - if (!(flags & SUPPRESS)) \ - { \ - *Str++ = c; \ - if ((flags & MALLOC) && (char *) Str == *strptr + strsize) \ - { \ - /* Enlarge the buffer. */ \ - Str = realloc (*strptr, strsize * 2 * sizeof (Type)); \ - if (Str == NULL) \ - { \ - /* Can't allocate that much. Last-ditch effort. */\ - Str = realloc (*strptr, \ - (strsize + 1) * sizeof (Type)); \ - if (Str == NULL) \ - { \ - /* We lose. Oh well. \ - Terminate the string and stop converting, \ - so at least we don't skip any input. */ \ - ((Type *) (*strptr))[strsize] = '\0'; \ - ++done; \ - conv_error (); \ - } \ - else \ - { \ - *strptr = (char *) Str; \ - Str = ((Type *) *strptr) + strsize; \ - ++strsize; \ - } \ - } \ - else \ - { \ - *strptr = (char *) Str; \ - Str = ((Type *) *strptr) + strsize; \ - strsize *= 2; \ - } \ - } \ - } - - STRING_ADD_CHAR (str, c, char); - } - while ((width <= 0 || --width > 0) && inchar () != EOF); - - if (!(flags & SUPPRESS)) - { - *str = '\0'; - ++done; - } - break; - - case 'S': - /* Wide character string. */ -wide_char_string: - { - wint_t val; - int first = 1; - STRING_ARG (wstr, wchar_t); - - do - { - size_t cnt = 0; - NEXT_WIDE_CHAR (first); - - if (iswspace (val)) - { - /* XXX We would have to push back the whole wide char - with possibly many bytes. But since scanf does - not make a difference for white space characters - we can simply push back a simple which is - guaranteed to be in the [:space:] class. */ - UNGETC (' ', s); - break; - } - - STRING_ADD_CHAR (wstr, val, wchar_t); - first = 0; - } - while (width <= 0 || --width > 0); - - if (!(flags & SUPPRESS)) - { - *wstr = L'\0'; - ++done; - } - } - break; - - case 'x': /* Hexadecimal integer. */ - case 'X': /* Ditto. */ - base = 16; - number_signed = 0; - goto number; - - case 'o': /* Octal integer. */ - base = 8; - number_signed = 0; - goto number; - - case 'u': /* Unsigned decimal integer. */ - base = 10; - number_signed = 0; - goto number; - - case 'd': /* Signed decimal integer. */ - base = 10; - number_signed = 1; - goto number; - - case 'i': /* Generic number. */ - base = 0; - number_signed = 1; - -number: - c = inchar (); - if (c == EOF) - input_error (); - - /* Check for a sign. */ - if (c == '-' || c == '+') - { - ADDW (c); - if (width > 0) - --width; - c = inchar (); - } - - /* Look for a leading indication of base. */ - if (width != 0 && c == '0') - { - if (width > 0) - --width; - - ADDW (c); - c = inchar (); - - if (width != 0 && tolower (c) == 'x') - { - if (base == 0) - base = 16; - if (base == 16) - { - if (width > 0) - --width; - c = inchar (); - } - } - else if (base == 0) - base = 8; - } - - if (base == 0) - base = 10; - - /* Read the number into workspace. */ - while (c != EOF && width != 0) - { - if (base == 16 ? !isxdigit (c) : - ((!isdigit (c) || c - '0' >= base) && - !((flags & GROUP) && base == 10 && c == thousands))) - break; - ADDW (c); - if (width > 0) - --width; - - c = inchar (); - } - - /* The just read character is not part of the number anymore. */ - UNGETC (c, s); - - if (wpsize == 0 || - (wpsize == 1 && (wp[0] == '+' || wp[0] == '-'))) - /* There was no number. */ - conv_error (); - - /* Convert the number. */ - ADDW ('\0'); - if (flags & LONGDBL) - { - // if (number_signed) - // num.q = __strtoq_internal (wp, &tw, base, flags & GROUP); - // else - // num.uq = __strtouq_internal (wp, &tw, base, flags & GROUP); - } - else - { - if (number_signed) - num.l = __strtol_internal (wp, &tw, base, flags & GROUP); - else - num.ul = __strtoul_internal (wp, &tw, base, flags & GROUP); - } - if (wp == tw) - conv_error (); - - if (!(flags & SUPPRESS)) - { - if (! number_signed) - { - if (flags & LONGDBL) - { - *ARG (ULONGLONG*) = num.uq; - } - else if (flags & LONG) - *ARG (unsigned long int*) = num.ul; - else if (flags & SHORT) - *ARG (unsigned short int*) = (unsigned short int) num.ul; - else - *ARG (unsigned int*) = (unsigned int) num.ul; - } - else - { - if (flags & LONGDBL) - { - *ARG (LONGLONG*) = num.q; - } - else if (flags & LONG) - *ARG (long int *) = num.l; - else if (flags & SHORT) - *ARG (short int *) = (short int) num.l; - else - *ARG (int *) = (int) num.l; - } - ++done; - } - break; - - case 'e': /* Floating-point numbers. */ - case 'E': - case 'f': - case 'g': - case 'G': - c = inchar (); - if (c == EOF) - input_error (); - - /* Check for a sign. */ - if (c == '-' || c == '+') - { - negative = c == '-'; - if (inchar () == EOF) - /* EOF is only an input error before we read any chars. */ - conv_error (); - if (width > 0) - --width; - } - else - negative = 0; - - got_dot = got_e = 0; - do - { - if (isdigit (c)) - ADDW (c); - else if (got_e && wp[wpsize - 1] == 'e' - && (c == '-' || c == '+')) - ADDW (c); - else if (wpsize > 0 && !got_e && tolower (c) == 'e') - { - ADDW ('e'); - got_e = got_dot = 1; - } - else if (c == decimal && !got_dot) - { - ADDW (c); - got_dot = 1; - } - else if ((flags & GROUP) && c == thousands && !got_dot) - ADDW (c); - else - { - /* The last read character is not part of the number - anymore. */ - UNGETC (c, s); - break; - } - if (width > 0) - --width; - } - while (width != 0 && inchar () != EOF); - - if (wpsize == 0) - conv_error (); - - /* Convert the number. */ - ADDW ('\0'); -#if 0 - - if (flags & LONGDBL) - { - long double d = __strtold_internal (wp, &tw, flags & GROUP); - if (!(flags & SUPPRESS) && tw != wp) - *ARG (long double *) = negative ? -d : d; - } -#endif - /* - double = long double in windows world. -Gunnar - */ - if (flags & (LONG|LONGDBL)) - { - double d = __strtod_internal (wp, &tw, flags & GROUP); - if (!(flags & SUPPRESS) && tw != wp){ - *ARG (double *) = negative ? -d : d; - } - } - else - { - float d = __strtof_internal (wp, &tw, flags & GROUP); - if (!(flags & SUPPRESS) && tw != wp){ - *ARG (float *) = negative ? -d : d; - } - } - - if (tw == wp) - conv_error (); - - if (!(flags & SUPPRESS)) - ++done; - break; - - case '[': /* Character class. */ - if (flags & LONG) - { - STRING_ARG (wstr, wchar_t); - c = '\0'; /* This is to keep gcc quiet. */ - } - else - { - STRING_ARG (str, char); - - c = inchar (); - if (c == EOF) - input_error (); - } - - if (*f == '^') - { - ++f; - not_in = 1; - } - else - not_in = 0; - - /* Fill WP with byte flags indexed by character. - We will use this flag map for matching input characters. */ - if (wpmax < UCHAR_MAX) - { - wpmax = UCHAR_MAX; - wp = (char *) alloca (wpmax); - } - memset (wp, 0, UCHAR_MAX); - - fc = *f; - if (fc == ']' || fc == '-') - { - /* If ] or - appears before any char in the set, it is not - the terminator or separator, but the first char in the - set. */ - wp[fc] = 1; - ++f; - } - - while ((fc = *f++) != '\0' && fc != ']') - { - if (fc == '-' && *f != '\0' && *f != ']' && - (unsigned char) f[-2] <= (unsigned char) *f) - { - /* Add all characters from the one before the '-' - up to (but not including) the next format char. */ - for (fc = f[-2]; fc < *f; ++fc) - wp[fc] = 1; - } - else - /* Add the character to the flag map. */ - wp[fc] = 1; - } - if (fc == '\0') - { - if (!(flags & LONG)) - UNGETC (c, s); - conv_error(); - } - - if (flags & LONG) - { - wint_t val; - int first = 1; - - do - { - size_t cnt = 0; - NEXT_WIDE_CHAR (first); - if (val > 255 || wp[val] == not_in) - { - /* XXX We have a problem here. We read a wide - character and this possibly took several - bytes. But we can only push back one single - character. To be sure we don't create wrong - input we push it back only in case it is - representable within one byte. */ - if (val < 0x80) - UNGETC (val, s); - break; - } - STRING_ADD_CHAR (wstr, val, wchar_t); - if (width > 0) - --width; - first = 0; - } - while (width != 0); - - if (first) - conv_error (); - - if (!(flags & SUPPRESS)) - { - *wstr = L'\0'; - ++done; - } - } - else - { - num.ul = read_in - 1; /* -1 because we already read one char. */ - do - { - if (wp[c] == not_in) - { - UNGETC (c, s); - break; - } - STRING_ADD_CHAR (str, c, char); - if (width > 0) - --width; - } - while (width != 0 && inchar () != EOF); - - if (read_in == num.ul) - conv_error (); - - if (!(flags & SUPPRESS)) - { - *str = '\0'; - ++done; - } - } - break; - - case 'p': /* Generic pointer. */ - base = 16; - /* A PTR must be the same size as a `long int'. */ - flags &= ~(SHORT|LONGDBL); - flags |= LONG; - number_signed = 0; - goto number; - } - } - - /* The last thing we saw int the format string was a white space. - Consume the last white spaces. */ - if (skip_space) - { - do - c = inchar (); - while (isspace (c)); - UNGETC (c, s); - } - - - return done; -} - - - -int -xfscanf(FILE *f, const char *fmt, ...) -{ - int r; - va_list a=0; - va_start(a, fmt); - r = __vfscanf(f, fmt, a); - va_end(a); - return r; -} - - -double __strtod_internal (const char *__nptr,char **__endptr, int __group) -{ - return strtod(__nptr,__endptr); -} -float __strtof_internal (const char *__nptr, char **__endptr,int __group) -{ - return (float)strtod(__nptr,__endptr); -} -static double powten[] = - { - 1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L, -#ifdef __GNUC__ - 1e512L, 1e512L*1e512L, 1e2048L, 1e4096L -#else - 1e256L, 1e256L, 1e256L, 1e256L -#endif - }; - -long double __strtold_internal (const char *s,char **sret, int __group) -{ - - long double r; /* result */ - int e, ne; /* exponent */ - int sign; /* +- 1.0 */ - int esign; - int flags=0; - int l2powm1; - - r = 0.0L; - sign = 1; - e = ne = 0; - esign = 1; - - while(*s && isspace(*s)) - s++; - - if (*s == '+') - s++; - else if (*s == '-') - { - sign = -1; - s++; - } - - while ((*s >= '0') && (*s <= '9')) - { - flags |= 1; - r *= 10.0L; - r += *s - '0'; - s++; - } - - if (*s == '.') - { - s++; - while ((*s >= '0') && (*s <= '9')) - { - flags |= 2; - r *= 10.0L; - r += *s - '0'; - s++; - ne++; - } - } - if (flags == 0) - { - if (sret) - *sret = (char *)s; - return 0.0L; - } - - if ((*s == 'e') || (*s == 'E')) - { - s++; - if (*s == '+') - s++; - else if (*s == '-') - { - s++; - esign = -1; - } - while ((*s >= '0') && (*s <= '9')) - { - e *= 10; - e += *s - '0'; - s++; - } - } - if (esign < 0) - { - esign = -esign; - e = -e; - } - e = e - ne; - if (e < -4096) - { - /* possibly subnormal number, 10^e would overflow */ - r *= 1.0e-2048L; - e += 2048; - } - if (e < 0) - { - e = -e; - esign = -esign; - } - if (e >= 8192) - e = 8191; - if (e) - { - double d = 1.0L; - l2powm1 = 0; - while (e) - { - if (e & 1) - d *= powten[l2powm1]; - e >>= 1; - l2powm1++; - } - if (esign > 0) - r *= d; - else - r /= d; - } - if (sret) - *sret = (char *)s; - return r * sign; - - return 0; -} -long int __strtol_internal (const char *__nptr, char **__endptr, int __base, int __group) -{ - return strtol(__nptr,__endptr, __base); -} -unsigned long int __strtoul_internal (const char *__nptr, char **__endptr, int __base, int __group) -{ - return strtoul(__nptr,__endptr, __base); -} - - - - - - - - - diff --git a/reactos/lib/crt/stdio/vfwprint.c b/reactos/lib/crt/stdio/vfwprint.c index 4e58b29bf95..262b2d18e97 100644 --- a/reactos/lib/crt/stdio/vfwprint.c +++ b/reactos/lib/crt/stdio/vfwprint.c @@ -4,13 +4,10 @@ #undef __USE_W32API #endif -//#include -#include // robd -#include // robd - -#include -#include -#include +#include +#include +#include +#include int _isnanl(double x); @@ -33,7 +30,7 @@ vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) wchar_t localbuf[BUFSIZ]; #if 0 - __fileno_lock(fileno(f)); + __fileno_lock(_fileno(f)); #endif if (f->_flag & _IONBF) { f->_flag &= ~_IONBF; @@ -48,7 +45,7 @@ vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) } else len = __vfwprintf(f,fmt,ap); #if 0 - __fileno_unlock(fileno(f)); + __fileno_unlock(_fileno(f)); #endif return (ferror(f) ? EOF : len); } @@ -70,14 +67,13 @@ vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) * Appropiated for the reactos kernel, March 1998 -- David Welch */ -#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define ZEROPAD 1 /* pad with zero */ diff --git a/reactos/lib/crt/stdio/vprintf.c b/reactos/lib/crt/stdio/vprintf.c index f487414ec8f..009245029e4 100644 --- a/reactos/lib/crt/stdio/vprintf.c +++ b/reactos/lib/crt/stdio/vprintf.c @@ -16,11 +16,11 @@ 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 #undef __OPTIMIZE__ /* Avoid inline `vprintf' function. */ -#include -#include - +#include +#include +#include #undef vprintf #undef vwprintf @@ -32,52 +32,28 @@ Cambridge, MA 02139, USA. */ /* * @implemented */ -int vprintf(const char* format, va_list arg) +int _vtprintf(const _TCHAR* format, va_list arg) { int ret; - ret = vfprintf(stdout, format, arg); - fflush(stdout); - return ret; -} - -/* - * @implemented - */ -int vwprintf(const wchar_t* format, va_list arg) -{ - int ret; - - ret = vfwprintf(stdout, format, arg); + ret = _vftprintf(stdout, format, arg); fflush(stdout); return ret; } #else -int vprintf(const char* format, ...) +int _vtprintf(const _TCHAR* format, ...) { va_list arg; int ret; va_start(arg, format); - ret = vfprintf(stdout, format, arg); + ret = _vftprintf(stdout, format, arg); va_end(arg); fflush(stdout); return ret; } -int vwprintf(const wchar_t* format, ...) -{ - va_list arg; - int ret; - - va_start(arg, format); - ret = vfwprintf(stdout, format, arg); - va_end(arg); - fflush(stdout); - return ret; -} - #endif diff --git a/reactos/lib/crt/stdio/vscanf.c b/reactos/lib/crt/stdio/vscanf.c deleted file mode 100644 index 4c6b7968964..00000000000 --- a/reactos/lib/crt/stdio/vscanf.c +++ /dev/null @@ -1,34 +0,0 @@ -/* 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 -#include -#include -#include - - -#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); -} - diff --git a/reactos/lib/crt/stdio/vsprintf.c b/reactos/lib/crt/stdio/vsprintf.c index 9209bb1b3f3..0fadd4881d5 100644 --- a/reactos/lib/crt/stdio/vsprintf.c +++ b/reactos/lib/crt/stdio/vsprintf.c @@ -1,42 +1,25 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include #include -#include +#include +#include /* * @implemented */ int -vsprintf(char *str, const char *fmt, va_list ap) +_vstprintf(_TCHAR *str, const _TCHAR *fmt, va_list ap) { - FILE f; - int len; - - f._flag = _IOWRT|_IOSTRG|_IOBINARY; - f._ptr = str; - f._cnt = INT_MAX; - f._file = -1; - len = vfprintf(&f,fmt, ap); - *f._ptr = 0; - return len; -} - -/* - * @implemented - */ -int -vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap) -{ - FILE f; + FILE f = {0}; int len; f._flag = _IOWRT|_IOSTRG|_IOBINARY; f._ptr = (char*)str; f._cnt = INT_MAX; f._file = -1; - len = vfwprintf(&f,fmt, ap); - *(wchar_t*)f._ptr = 0; + len = _vftprintf(&f,fmt, ap); + *(_TCHAR*)f._ptr = 0; return len; } @@ -45,36 +28,17 @@ vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap) * @implemented */ int -_vsnprintf(char *str, size_t maxlen, const char *fmt, va_list ap) +_vsntprintf(_TCHAR *str, size_t maxlen, const _TCHAR *fmt, va_list ap) { - FILE f; - int len; - f._flag = _IOWRT|_IOSTRG|_IOBINARY; - f._ptr = str; - f._cnt = maxlen; - f._file = -1; - len = vfprintf(&f,fmt, ap); - // what if the buffer is full ?? - *f._ptr = 0; - return len; -} - -/* - * @implemented - */ -int -_vsnwprintf(wchar_t *str, size_t maxlen, const wchar_t *fmt, va_list ap) -{ - FILE f; + FILE f = {0}; int len; + f._flag = _IOWRT|_IOSTRG|_IOBINARY; f._ptr = (char*)str; f._cnt = maxlen; f._file = -1; - len = vfwprintf(&f,fmt, ap); + len = _vftprintf(&f,fmt, ap); // what if the buffer is full ?? - *(wchar_t*)f._ptr = 0; + *(_TCHAR *)f._ptr = 0; return len; } - - diff --git a/reactos/lib/crt/stdio/vsscanf.c b/reactos/lib/crt/stdio/vsscanf.c deleted file mode 100644 index b24fe72f620..00000000000 --- a/reactos/lib/crt/stdio/vsscanf.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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 -#include -#include -#include -#include -#include - -#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|_IOSTRG|_IOBINARY; - f._ptr = (char *)s; - f._base = (char *)s; - f._bufsiz = strlen(s); - f._cnt = f._bufsiz; - - return __vfscanf(&f, format, arg); -} - diff --git a/reactos/lib/crt/stdio/vswprintf.c b/reactos/lib/crt/stdio/vswprintf.c new file mode 100644 index 00000000000..646e937fee7 --- /dev/null +++ b/reactos/lib/crt/stdio/vswprintf.c @@ -0,0 +1,4 @@ +#define UNICODE +#define _UNICODE + +#include "vsprintf.c" diff --git a/reactos/lib/crt/stdio/vwprintf.c b/reactos/lib/crt/stdio/vwprintf.c new file mode 100644 index 00000000000..80e54674f88 --- /dev/null +++ b/reactos/lib/crt/stdio/vwprintf.c @@ -0,0 +1,5 @@ +#define _UNICODE +#define UNICODE + +#include "vprintf.c" + diff --git a/reactos/lib/crt/stdio/wfdopen.c b/reactos/lib/crt/stdio/wfdopen.c index 08bbeb9455c..aa1fcc7bc47 100644 --- a/reactos/lib/crt/stdio/wfdopen.c +++ b/reactos/lib/crt/stdio/wfdopen.c @@ -1,57 +1,7 @@ -#include -#include - -FILE* __alloc_file(void); -/* - * @implemented - */ -FILE* _wfdopen(int handle, wchar_t* mode) -{ - FILE* file; - int rw; +#define _UNICODE +#define UNICODE - if (handle == 0) - return stdin; +#include "fdopen.c" - 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/crt/stdio/wfreopen.c b/reactos/lib/crt/stdio/wfreopen.c new file mode 100644 index 00000000000..933968368c0 --- /dev/null +++ b/reactos/lib/crt/stdio/wfreopen.c @@ -0,0 +1,6 @@ + +#define UNICODE +#define _UNICODE + +#include "freopen.c" + diff --git a/reactos/lib/crt/stdio/wfsopen.c b/reactos/lib/crt/stdio/wfsopen.c new file mode 100644 index 00000000000..90020ae9f1d --- /dev/null +++ b/reactos/lib/crt/stdio/wfsopen.c @@ -0,0 +1,5 @@ +#define _UNICODE +#define UNICODE + +#include "fsopen.c" + diff --git a/reactos/lib/crt/stdio/wpopen.c b/reactos/lib/crt/stdio/wpopen.c new file mode 100644 index 00000000000..bf1d111475f --- /dev/null +++ b/reactos/lib/crt/stdio/wpopen.c @@ -0,0 +1,5 @@ +#define _UNICODE +#define UNICODE + +#include "popen.c" + diff --git a/reactos/lib/crt/stdio/wprintf.c b/reactos/lib/crt/stdio/wprintf.c new file mode 100644 index 00000000000..5bf927f20e8 --- /dev/null +++ b/reactos/lib/crt/stdio/wprintf.c @@ -0,0 +1,5 @@ +#define _UNICODE +#define UNICODE + +#include "printf.c" + diff --git a/reactos/lib/crt/stdio/wremove.c b/reactos/lib/crt/stdio/wremove.c new file mode 100644 index 00000000000..959802a67a1 --- /dev/null +++ b/reactos/lib/crt/stdio/wremove.c @@ -0,0 +1,4 @@ +#define UNICODE +#define _UNICODE + +#include "remove.c" diff --git a/reactos/lib/crt/stdio/wrename.c b/reactos/lib/crt/stdio/wrename.c index 1c78865ea2d..bb6eda1d144 100644 --- a/reactos/lib/crt/stdio/wrename.c +++ b/reactos/lib/crt/stdio/wrename.c @@ -1,18 +1,6 @@ -#include "precomp.h" -#include -#include +#define _UNICODE +#define UNICODE -/* - * @implemented - */ -int _wrename(const wchar_t* old_, const wchar_t* new_) -{ - if (old_ == NULL || new_ == NULL) - return -1; +#include "rename.c" - if (!MoveFileW(old_, new_)) - return -1; - - return 0; -} diff --git a/reactos/lib/crt/stdio/wtempnam.c b/reactos/lib/crt/stdio/wtempnam.c index 4f73f8c9d0d..ec9e2bd9053 100644 --- a/reactos/lib/crt/stdio/wtempnam.c +++ b/reactos/lib/crt/stdio/wtempnam.c @@ -1,25 +1,6 @@ -#include "precomp.h" -#include -#include +#define _UNICODE +#define UNICODE -/* - * @implemented - */ -wchar_t* _wtempnam(const wchar_t* dir, const wchar_t* prefix) -{ - wchar_t* TempFileName = malloc(MAX_PATH); - wchar_t* d; +#include "tempnam.c" - if (dir == NULL) - d = _wgetenv(L"TMP"); - else - d = (wchar_t*)dir; - - if (GetTempFileNameW(d, prefix, 1, TempFileName) == 0) { - free(TempFileName); - return NULL; - } - - return TempFileName; -} diff --git a/reactos/lib/crt/stdio/wtmpnam.c b/reactos/lib/crt/stdio/wtmpnam.c index 770e6ecacb0..dca653f8e0e 100644 --- a/reactos/lib/crt/stdio/wtmpnam.c +++ b/reactos/lib/crt/stdio/wtmpnam.c @@ -1,19 +1,5 @@ -#include "precomp.h" -#include -#include +#define _UNICODE +#define UNICODE -/* - * @implemented - */ -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; -} +#import "tmpnam.c" diff --git a/reactos/lib/crt/stdlib/_exit.c b/reactos/lib/crt/stdlib/_exit.c index cb7b5e1a37b..a4ab2499172 100644 --- a/reactos/lib/crt/stdlib/_exit.c +++ b/reactos/lib/crt/stdlib/_exit.c @@ -1,8 +1,8 @@ #include "precomp.h" -#include -#include -#include -#include +#include +#include +#include +#include struct __atexit *__atexit_ptr = 0; diff --git a/reactos/lib/crt/stdlib/abort.c b/reactos/lib/crt/stdlib/abort.c index e0ae1955ebd..02338d6dd6e 100644 --- a/reactos/lib/crt/stdlib/abort.c +++ b/reactos/lib/crt/stdlib/abort.c @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include +#include +#include +#include char *msg ="Abort\n\r"; @@ -11,7 +11,7 @@ char *msg ="Abort\n\r"; void abort() { fflush(NULL); - fcloseall(); + _fcloseall(); raise(SIGABRT); _write(stderr->_file, msg, sizeof(msg)-1); exit(3); diff --git a/reactos/lib/crt/stdlib/abs.c b/reactos/lib/crt/stdlib/abs.c index 3efdce831fd..24f6351b574 100644 --- a/reactos/lib/crt/stdlib/abs.c +++ b/reactos/lib/crt/stdlib/abs.c @@ -1,6 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/atexit.c b/reactos/lib/crt/stdlib/atexit.c index 6d08dfd160f..7f6fa95f19e 100644 --- a/reactos/lib/crt/stdlib/atexit.c +++ b/reactos/lib/crt/stdlib/atexit.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include typedef int (* _onexit_t)(void); diff --git a/reactos/lib/crt/stdlib/atof.c b/reactos/lib/crt/stdlib/atof.c index e3021084b92..b2de698be50 100644 --- a/reactos/lib/crt/stdlib/atof.c +++ b/reactos/lib/crt/stdlib/atof.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/atoi.c b/reactos/lib/crt/stdlib/atoi.c index df6a0c47002..9e991dbe9a1 100644 --- a/reactos/lib/crt/stdlib/atoi.c +++ b/reactos/lib/crt/stdlib/atoi.c @@ -1,11 +1,12 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include +#include /* * @implemented */ int -atoi(const char *str) +_ttoi(const _TCHAR *str) { - return (int)strtol(str, 0, 10); + return (int)_tcstol(str, 0, 10); } diff --git a/reactos/lib/crt/stdlib/atoi64.c b/reactos/lib/crt/stdlib/atoi64.c index 6855b90fbcd..2011e0f297d 100644 --- a/reactos/lib/crt/stdlib/atoi64.c +++ b/reactos/lib/crt/stdlib/atoi64.c @@ -1,6 +1,6 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/atol.c b/reactos/lib/crt/stdlib/atol.c index 663301d95fc..58e0aa78028 100644 --- a/reactos/lib/crt/stdlib/atol.c +++ b/reactos/lib/crt/stdlib/atol.c @@ -1,11 +1,12 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include +#include /* * @implemented */ long -atol(const char *str) +_ttol(const _TCHAR *str) { - return strtol(str, 0, 10); + return _tcstol(str, 0, 10); } diff --git a/reactos/lib/crt/stdlib/atold.c b/reactos/lib/crt/stdlib/atold.c index c9b511684a4..ce3f33ac434 100644 --- a/reactos/lib/crt/stdlib/atold.c +++ b/reactos/lib/crt/stdlib/atold.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include long double _atold(const char *ascii) diff --git a/reactos/lib/crt/stdlib/bsearch.c b/reactos/lib/crt/stdlib/bsearch.c index 7efbdbd9897..e1e4f11e586 100644 --- a/reactos/lib/crt/stdlib/bsearch.c +++ b/reactos/lib/crt/stdlib/bsearch.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/div.c b/reactos/lib/crt/stdlib/div.c index 56b8b4422f8..06be1b070c2 100644 --- a/reactos/lib/crt/stdlib/div.c +++ b/reactos/lib/crt/stdlib/div.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/ecvt.c b/reactos/lib/crt/stdlib/ecvt.c index 940ffb2ed27..43ad5f2b2fc 100644 --- a/reactos/lib/crt/stdlib/ecvt.c +++ b/reactos/lib/crt/stdlib/ecvt.c @@ -1,6 +1,6 @@ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include char *ecvtbuf (double, int, int *, int *, char *); diff --git a/reactos/lib/crt/stdlib/ecvtbuf.c b/reactos/lib/crt/stdlib/ecvtbuf.c index 1d0f65fbba8..a218b92bea7 100644 --- a/reactos/lib/crt/stdlib/ecvtbuf.c +++ b/reactos/lib/crt/stdlib/ecvtbuf.c @@ -1,9 +1,9 @@ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include // #include void __ecvround (char *, char *, const char *, int *); @@ -41,7 +41,7 @@ ecvtbuf (double value, int ndigits, int *decpt, int *sign, char *buf) { static char INFINITY[] = "Infinity"; char decimal = '.' /* localeconv()->decimal_point[0] */; - char *cvtbuf = (char *)alloca (ndigits + 20); /* +3 for sign, dot, null; */ + char *cvtbuf = (char *)_alloca (ndigits + 20); /* +3 for sign, dot, null; */ /* two extra for rounding */ /* 15 extra for alignment */ char *s = cvtbuf, *d = buf; diff --git a/reactos/lib/crt/stdlib/errno.c b/reactos/lib/crt/stdlib/errno.c index cb3b00b4ecd..7b2ba8df874 100644 --- a/reactos/lib/crt/stdlib/errno.c +++ b/reactos/lib/crt/stdlib/errno.c @@ -5,9 +5,9 @@ #undef __USE_W32API #endif -#include -#include -#include +#include +#include +#include #include "doserrmap.h" diff --git a/reactos/lib/crt/stdlib/fcvt.c b/reactos/lib/crt/stdlib/fcvt.c index 423b7f2380d..d01a54eea8a 100644 --- a/reactos/lib/crt/stdlib/fcvt.c +++ b/reactos/lib/crt/stdlib/fcvt.c @@ -1,6 +1,6 @@ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include char *fcvtbuf (double, int, int *, int *, char *); diff --git a/reactos/lib/crt/stdlib/fcvtbuf.c b/reactos/lib/crt/stdlib/fcvtbuf.c index 2bf85aa6483..cbec72b604a 100644 --- a/reactos/lib/crt/stdlib/fcvtbuf.c +++ b/reactos/lib/crt/stdlib/fcvtbuf.c @@ -1,9 +1,9 @@ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include // #include void __ecvround (char *, char *, const char *, int *); @@ -15,7 +15,7 @@ fcvtbuf (double value, int ndigits, int *decpt, int *sign, char *buf) static char INFINITY[] = "Infinity"; char decimal = '.' /* localeconv()->decimal_point[0] */; int digits = ndigits >= 0 ? ndigits : 0; - char *cvtbuf = (char *)alloca (2*DBL_MAX_10_EXP + 16); + char *cvtbuf = (char *)_alloca (2*DBL_MAX_10_EXP + 16); char *s = cvtbuf; char *dot; diff --git a/reactos/lib/crt/stdlib/fullpath.c b/reactos/lib/crt/stdlib/fullpath.c index 8f61c94e76e..aea0833e62f 100644 --- a/reactos/lib/crt/stdlib/fullpath.c +++ b/reactos/lib/crt/stdlib/fullpath.c @@ -9,17 +9,18 @@ */ #include "precomp.h" -#include +#include +#include /* * @implemented */ -char* _fullpath(char* absPath, const char* relPath, size_t maxLength) +_TCHAR* _tfullpath(_TCHAR* absPath, const _TCHAR* relPath, size_t maxLength) { - char* lpFilePart; + _TCHAR* lpFilePart; - if (GetFullPathNameA(relPath,maxLength,absPath,&lpFilePart) == 0) + if (GetFullPathName(relPath,maxLength,absPath,&lpFilePart) == 0) return NULL; return absPath; diff --git a/reactos/lib/crt/stdlib/gcvt.c b/reactos/lib/crt/stdlib/gcvt.c index c077566c83a..dbc8168ddc3 100644 --- a/reactos/lib/crt/stdlib/gcvt.c +++ b/reactos/lib/crt/stdlib/gcvt.c @@ -1,7 +1,7 @@ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/getenv.c b/reactos/lib/crt/stdlib/getenv.c index 71d91b18afc..0a445b0dac2 100644 --- a/reactos/lib/crt/stdlib/getenv.c +++ b/reactos/lib/crt/stdlib/getenv.c @@ -1,8 +1,8 @@ #include "precomp.h" -#include +#include #define NDEBUG -#include +#include #undef environ diff --git a/reactos/lib/crt/stdlib/itoa.c b/reactos/lib/crt/stdlib/itoa.c index 004efc7ac6c..d6ce83ea36e 100644 --- a/reactos/lib/crt/stdlib/itoa.c +++ b/reactos/lib/crt/stdlib/itoa.c @@ -10,9 +10,9 @@ */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* diff --git a/reactos/lib/crt/stdlib/itow.c b/reactos/lib/crt/stdlib/itow.c index 1939d1a6ff0..5156bc46dc8 100644 --- a/reactos/lib/crt/stdlib/itow.c +++ b/reactos/lib/crt/stdlib/itow.c @@ -12,9 +12,9 @@ */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* diff --git a/reactos/lib/crt/stdlib/labs.c b/reactos/lib/crt/stdlib/labs.c index 8c1d3fff3f0..50ad63daf43 100644 --- a/reactos/lib/crt/stdlib/labs.c +++ b/reactos/lib/crt/stdlib/labs.c @@ -1,6 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/ldiv.c b/reactos/lib/crt/stdlib/ldiv.c index a40597d0e95..3f8a2ec3147 100644 --- a/reactos/lib/crt/stdlib/ldiv.c +++ b/reactos/lib/crt/stdlib/ldiv.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/makepath.c b/reactos/lib/crt/stdlib/makepath.c index 2ca367f1307..8db6a6794f9 100644 --- a/reactos/lib/crt/stdlib/makepath.c +++ b/reactos/lib/crt/stdlib/makepath.c @@ -1,7 +1,7 @@ /* $Id$ */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/malloc.c b/reactos/lib/crt/stdlib/malloc.c index 95e715ae76f..2ad1054dee2 100644 --- a/reactos/lib/crt/stdlib/malloc.c +++ b/reactos/lib/crt/stdlib/malloc.c @@ -22,8 +22,8 @@ */ #include "precomp.h" -#include -#include +#include +#include extern HANDLE hHeap; diff --git a/reactos/lib/crt/stdlib/mbstowcs.c b/reactos/lib/crt/stdlib/mbstowcs.c index 823d61a8231..54e2e33d26a 100644 --- a/reactos/lib/crt/stdlib/mbstowcs.c +++ b/reactos/lib/crt/stdlib/mbstowcs.c @@ -1,7 +1,7 @@ #include "precomp.h" -#include -#include -#include +#include +#include +#include #if 1 /* diff --git a/reactos/lib/crt/stdlib/mbtowc.c b/reactos/lib/crt/stdlib/mbtowc.c index 8530f55db0d..22b17c3fedc 100644 --- a/reactos/lib/crt/stdlib/mbtowc.c +++ b/reactos/lib/crt/stdlib/mbtowc.c @@ -1,6 +1,6 @@ #include "precomp.h" -#include -#include +#include +#include #if 1 diff --git a/reactos/lib/crt/stdlib/obsol.c b/reactos/lib/crt/stdlib/obsol.c index 48e465fc2d0..946c8ad3888 100644 --- a/reactos/lib/crt/stdlib/obsol.c +++ b/reactos/lib/crt/stdlib/obsol.c @@ -1,5 +1,5 @@ #include "precomp.h" -#include +#include #undef _cpumode unsigned char _cpumode = 0; diff --git a/reactos/lib/crt/stdlib/putenv.c b/reactos/lib/crt/stdlib/putenv.c index 8921ee78cac..7edf52d0591 100644 --- a/reactos/lib/crt/stdlib/putenv.c +++ b/reactos/lib/crt/stdlib/putenv.c @@ -1,9 +1,9 @@ #include "precomp.h" -#include -#include +#include +#include #define NDEBUG -#include +#include /* misc/environ.c */ int SetEnv(const wchar_t *option); diff --git a/reactos/lib/crt/stdlib/qsort.c b/reactos/lib/crt/stdlib/qsort.c index e5e662ad881..2be3badae77 100644 --- a/reactos/lib/crt/stdlib/qsort.c +++ b/reactos/lib/crt/stdlib/qsort.c @@ -3,8 +3,9 @@ #undef __USE_W32API #endif -#include -#include +#include +#include +#include /*- * Copyright (c) 1980, 1983 The Regents of the University of California. @@ -174,7 +175,7 @@ qst(PTHREADDATA pThreadData, char *base, char *max) * @implemented */ void -qsort(const void *base0, size_t n, size_t size, _pfunccmp_t compar) +qsort(void *base0, size_t n, size_t size, int (*compar)(const void*, const void*)) { PTHREADDATA pThreadData; char *base = (char *)base0; diff --git a/reactos/lib/crt/stdlib/rand.c b/reactos/lib/crt/stdlib/rand.c index fd4e9ead5ed..79a04b53448 100644 --- a/reactos/lib/crt/stdlib/rand.c +++ b/reactos/lib/crt/stdlib/rand.c @@ -3,8 +3,8 @@ #undef __USE_W32API #endif -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/rot.c b/reactos/lib/crt/stdlib/rot.c index c5f67aa200a..22ba5d0efc5 100644 --- a/reactos/lib/crt/stdlib/rot.c +++ b/reactos/lib/crt/stdlib/rot.c @@ -8,8 +8,7 @@ * 03/04/99: Created */ -#include -#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/senv.c b/reactos/lib/crt/stdlib/senv.c index be6e7e7e003..d63291c81dd 100644 --- a/reactos/lib/crt/stdlib/senv.c +++ b/reactos/lib/crt/stdlib/senv.c @@ -1,36 +1,37 @@ #include "precomp.h" -#include -#include +#include +#include +#include #define NDEBUG -#include +#include /* * @implemented */ -void _searchenv(const char* file,const char* var,char* path) +void _tsearchenv(const _TCHAR* file,const _TCHAR* var,_TCHAR* path) { - char* env = getenv(var); - char* x; - char* y; - char* FilePart; + _TCHAR* env = _tgetenv(var); + _TCHAR* x; + _TCHAR* y; + _TCHAR* FilePart; - DPRINT("_searchenv()\n"); + DPRINT(#_tsearchenv"()\n"); - x = strchr(env,'='); + x = _tcschr(env,'='); if ( x != NULL ) { *x = 0; x++; } - y = strchr(env,';'); + y = _tcschr(env,';'); while ( y != NULL ) { *y = 0; - if ( SearchPathA(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) { + if ( SearchPath(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) { return; } x = y+1; - y = strchr(env,';'); + y = _tcschr(env,';'); } return; } diff --git a/reactos/lib/crt/stdlib/splitp.c b/reactos/lib/crt/stdlib/splitp.c index b523c9514ab..066f9e5aabb 100644 --- a/reactos/lib/crt/stdlib/splitp.c +++ b/reactos/lib/crt/stdlib/splitp.c @@ -1,22 +1,23 @@ -#include -#include +#include +#include +#include /* * @implemented */ -void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext) +void _tsplitpath(const _TCHAR* path, _TCHAR* drive, _TCHAR* dir, _TCHAR* fname, _TCHAR* ext) { - char* tmp_drive; - char* tmp_dir; - char* tmp_ext; + _TCHAR* tmp_drive; + _TCHAR* tmp_dir; + _TCHAR* tmp_ext; - tmp_drive = (char*)strchr(path,':'); + tmp_drive = (_TCHAR*)_tcschr(path,':'); if (drive) { if (tmp_drive) { - strncpy(drive,tmp_drive-1,2); + _tcsncpy(drive,tmp_drive-1,2); *(drive+2) = 0; } else @@ -26,15 +27,15 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext } if (!tmp_drive) { - tmp_drive = (char*)path - 1; + tmp_drive = (_TCHAR*)path - 1; } - tmp_dir = (char*)strrchr(path,'\\'); + tmp_dir = (_TCHAR*)_tcsrchr(path,'\\'); if (dir) { if (tmp_dir) { - strncpy(dir,tmp_drive+1,tmp_dir-tmp_drive); + _tcsncpy(dir,tmp_drive+1,tmp_dir-tmp_drive); *(dir+(tmp_dir-tmp_drive)) = 0; } else @@ -43,26 +44,26 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext } } - tmp_ext = (char*)strrchr(path,'.'); + tmp_ext = (_TCHAR*)_tcsrchr(path,'.'); if (!tmp_ext) { - tmp_ext = (char*)path+strlen(path); + tmp_ext = (_TCHAR*)path+_tcslen(path); } if (ext) { - strcpy(ext,tmp_ext); + _tcscpy(ext,tmp_ext); } if (fname) { if (tmp_dir) { - strncpy(fname,tmp_dir+1,tmp_ext-tmp_dir-1); + _tcsncpy(fname,tmp_dir+1,tmp_ext-tmp_dir-1); *(fname+(tmp_ext-tmp_dir-1)) = 0; } else { - strncpy(fname,tmp_drive+1,tmp_ext-tmp_drive-1); + _tcsncpy(fname,tmp_drive+1,tmp_ext-tmp_drive-1); *(fname+(tmp_ext-path))=0; } } diff --git a/reactos/lib/crt/stdlib/strtod.c b/reactos/lib/crt/stdlib/strtod.c index 29d936ebdd0..9b9ec3ec279 100644 --- a/reactos/lib/crt/stdlib/strtod.c +++ b/reactos/lib/crt/stdlib/strtod.c @@ -1,7 +1,7 @@ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* diff --git a/reactos/lib/crt/stdlib/strtol.c b/reactos/lib/crt/stdlib/strtol.c index 40262d5e819..f43937e4c29 100644 --- a/reactos/lib/crt/stdlib/strtol.c +++ b/reactos/lib/crt/stdlib/strtol.c @@ -1,9 +1,9 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -#include -#include -#include -#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/stdlib/strtold.c b/reactos/lib/crt/stdlib/strtold.c index 5588206f937..0d38ac4ce64 100644 --- a/reactos/lib/crt/stdlib/strtold.c +++ b/reactos/lib/crt/stdlib/strtold.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include #include //#include diff --git a/reactos/lib/crt/stdlib/strtoll.c b/reactos/lib/crt/stdlib/strtoll.c deleted file mode 100644 index 6115580be3a..00000000000 --- a/reactos/lib/crt/stdlib/strtoll.c +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -//#include - -/* constants used in Solaris */ -#define LLONG_MIN -9223372036854775807L-1L -#define LLONG_MAX 9223372036854775807L -#define ULLONG_MAX 18446744073709551615UL - -long -strtoll(const char *nptr, char **endptr, int base) -{ - const char *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; - - /* - * See strtol for comments as to the logic used. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') - { - neg = 1; - c = *s++; - } - else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - -/* to prevent overflow, we take max-1 and add 1 after division */ - cutoff = neg ? -(LLONG_MIN+1) : LLONG_MAX-1; - cutlim = cutoff % base; - cutoff /= base; - if (++cutlim == base) - { - cutlim = 0; - cutoff++; - } - for (acc = 0, any = 0;; c = *s++) - { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else - { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) - { - acc = neg ? LLONG_MIN : LLONG_MAX; - __set_errno ( ERANGE ); - } - else if (neg) - acc *= -1; - if (endptr != 0) - *endptr = any ? (char *)s - 1 : (char *)nptr; - return acc; -} diff --git a/reactos/lib/crt/stdlib/strtoul.c b/reactos/lib/crt/stdlib/strtoul.c index 59fbe38b3f3..11baa3a85d6 100644 --- a/reactos/lib/crt/stdlib/strtoul.c +++ b/reactos/lib/crt/stdlib/strtoul.c @@ -1,9 +1,9 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -#include -#include -#include -#include +#include +#include +#include +#include /* * Convert a string to an unsigned long integer. diff --git a/reactos/lib/crt/stdlib/strtoull.c b/reactos/lib/crt/stdlib/strtoull.c index 031b9103a57..c61dd7f2aba 100644 --- a/reactos/lib/crt/stdlib/strtoull.c +++ b/reactos/lib/crt/stdlib/strtoull.c @@ -1,9 +1,9 @@ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -#include -#include -#include +#include +#include +#include //#include /* diff --git a/reactos/lib/crt/stdlib/swab.c b/reactos/lib/crt/stdlib/swab.c index c3c1c09017e..335859d9080 100644 --- a/reactos/lib/crt/stdlib/swab.c +++ b/reactos/lib/crt/stdlib/swab.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/stdlib/wcstod.c b/reactos/lib/crt/stdlib/wcstod.c index 14988abb220..89029c1a5c1 100644 --- a/reactos/lib/crt/stdlib/wcstod.c +++ b/reactos/lib/crt/stdlib/wcstod.c @@ -1,6 +1,6 @@ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* diff --git a/reactos/lib/crt/stdlib/wcstol.c b/reactos/lib/crt/stdlib/wcstol.c index 3f601e19131..103adbbf047 100644 --- a/reactos/lib/crt/stdlib/wcstol.c +++ b/reactos/lib/crt/stdlib/wcstol.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/stdlib/wcstom.c b/reactos/lib/crt/stdlib/wcstom.c index b9dd5d2cb02..0c74f97c15e 100644 --- a/reactos/lib/crt/stdlib/wcstom.c +++ b/reactos/lib/crt/stdlib/wcstom.c @@ -1,4 +1,4 @@ -#include +#include /* * @unimplemented diff --git a/reactos/lib/crt/stdlib/wcstomb.c b/reactos/lib/crt/stdlib/wcstomb.c index c0b5d997b18..0bed54a7edd 100644 --- a/reactos/lib/crt/stdlib/wcstomb.c +++ b/reactos/lib/crt/stdlib/wcstomb.c @@ -16,12 +16,10 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include - -#include -#include -#include +#include +#include +#include +#include #ifndef EILSEQ #define EILSEQ EINVAL diff --git a/reactos/lib/crt/stdlib/wcstombs.c b/reactos/lib/crt/stdlib/wcstombs.c index 06054eeada9..bfb3112db2b 100644 --- a/reactos/lib/crt/stdlib/wcstombs.c +++ b/reactos/lib/crt/stdlib/wcstombs.c @@ -16,11 +16,10 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include - -#include -#include +#include +#include +#include +#include #ifndef EILSEQ #define EILSEQ EINVAL diff --git a/reactos/lib/crt/stdlib/wcstoul.c b/reactos/lib/crt/stdlib/wcstoul.c index 54a309615d2..de1e0240a40 100644 --- a/reactos/lib/crt/stdlib/wcstoul.c +++ b/reactos/lib/crt/stdlib/wcstoul.c @@ -1,9 +1,9 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -#include -#include -#include -#include +#include +#include +#include +#include /* * Convert a unicode string to an unsigned long integer. diff --git a/reactos/lib/crt/stdlib/wctomb.c b/reactos/lib/crt/stdlib/wctomb.c index a38cffad4c0..6d375be963e 100644 --- a/reactos/lib/crt/stdlib/wctomb.c +++ b/reactos/lib/crt/stdlib/wctomb.c @@ -17,11 +17,11 @@ Boston, MA 02111-1307, USA. */ #include "precomp.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include int diff --git a/reactos/lib/crt/stdlib/wfulpath.c b/reactos/lib/crt/stdlib/wfulpath.c index 47d90bb12b7..43d6d788172 100644 --- a/reactos/lib/crt/stdlib/wfulpath.c +++ b/reactos/lib/crt/stdlib/wfulpath.c @@ -1,26 +1,5 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdlib/fullpath.c - * PURPOSE: Gets the fullpathname - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/98: Created - */ -#include "precomp.h" -#include +#define _UNICODE +#define UNICODE - -/* - * @implemented - */ -wchar_t* _wfullpath(wchar_t* absPath, const wchar_t* relPath, size_t maxLength) -{ - wchar_t* lpFilePart; - - if (GetFullPathNameW(relPath,maxLength,absPath,&lpFilePart) == 0) - return NULL; - - return absPath; -} +#include "fullpath.c" diff --git a/reactos/lib/crt/stdlib/witoa.c b/reactos/lib/crt/stdlib/witoa.c index 4e6d85aa488..cc14dcfb798 100644 --- a/reactos/lib/crt/stdlib/witoa.c +++ b/reactos/lib/crt/stdlib/witoa.c @@ -10,9 +10,9 @@ */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* diff --git a/reactos/lib/crt/stdlib/witow.c b/reactos/lib/crt/stdlib/witow.c index 245802a9e5a..a0b972ae9e3 100644 --- a/reactos/lib/crt/stdlib/witow.c +++ b/reactos/lib/crt/stdlib/witow.c @@ -12,9 +12,9 @@ */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include /* diff --git a/reactos/lib/crt/stdlib/wmakpath.c b/reactos/lib/crt/stdlib/wmakpath.c index 5026ca3416d..02f1fbb1396 100644 --- a/reactos/lib/crt/stdlib/wmakpath.c +++ b/reactos/lib/crt/stdlib/wmakpath.c @@ -1,7 +1,7 @@ /* $Id$ */ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/stdlib/wputenv.c b/reactos/lib/crt/stdlib/wputenv.c index 8b34b510a96..c06d966a257 100644 --- a/reactos/lib/crt/stdlib/wputenv.c +++ b/reactos/lib/crt/stdlib/wputenv.c @@ -1,9 +1,9 @@ #include "precomp.h" -#include -#include +#include +#include #define NDEBUG -#include +#include /* misc/environ.c */ int SetEnv(const wchar_t *option); diff --git a/reactos/lib/crt/stdlib/wsenv.c b/reactos/lib/crt/stdlib/wsenv.c index 0ebc7f1cde2..4e23231f854 100644 --- a/reactos/lib/crt/stdlib/wsenv.c +++ b/reactos/lib/crt/stdlib/wsenv.c @@ -1,35 +1,5 @@ -#include "precomp.h" -#include -#include -#define NDEBUG -#include +#define _UNICODE +#define UNICODE - -/* - * @implemented - */ -void _wsearchenv(const wchar_t* file,const wchar_t* var,wchar_t* path) -{ - wchar_t* env = _wgetenv(var); - wchar_t* x; - wchar_t* y; - wchar_t* FilePart; - - DPRINT("_wsearchenv()\n"); - x = wcschr(env,L'='); - if ( x != NULL ) { - *x = 0; - x++; - } - y = wcschr(env,L';'); - while ( y != NULL ) { - *y = 0; - if ( SearchPathW(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) { - return; - } - x = y+1; - y = wcschr(env,L';'); - } - return; -} +#include "senv.c" diff --git a/reactos/lib/crt/stdlib/wsplitp.c b/reactos/lib/crt/stdlib/wsplitp.c index 8a3520884b7..0b5a3cade62 100644 --- a/reactos/lib/crt/stdlib/wsplitp.c +++ b/reactos/lib/crt/stdlib/wsplitp.c @@ -1,69 +1,5 @@ -#include -#include +#define _UNICODE +#define UNICODE -/* - * @implemented - */ -void _wsplitpath(const wchar_t* path, wchar_t* drive, wchar_t* dir, wchar_t* fname, wchar_t* ext) -{ - wchar_t* tmp_drive; - wchar_t* tmp_dir; - wchar_t* tmp_ext; - - tmp_drive = (wchar_t*)wcschr(path,L':'); - if (drive) - { - if (tmp_drive) - { - wcsncpy(drive,tmp_drive-1,2); - *(drive+2) = 0; - } - else - { - *drive = 0; - } - } - if (!tmp_drive) - { - tmp_drive = (wchar_t*)path - 1; - } - - tmp_dir = (wchar_t*)wcsrchr(path,L'\\'); - if (dir) - { - if (tmp_dir) - { - wcsncpy(dir,tmp_drive+1,tmp_dir-tmp_drive); - *(dir+(tmp_dir-tmp_drive)) = 0; - } - else - { - *dir =0; - } - } - - tmp_ext = (wchar_t*)wcsrchr(path,L'.'); - if (! tmp_ext) - { - tmp_ext = (wchar_t*)path+wcslen(path); - } - if (ext) - { - wcscpy(ext,tmp_ext); - } - - if (fname) - { - if (tmp_dir) - { - wcsncpy(fname,tmp_dir+1,tmp_ext-tmp_dir-1); - *(fname+(tmp_ext-tmp_dir-1)) = 0; - } - else - { - wcsncpy(fname,tmp_drive+1,tmp_ext-tmp_drive-1); - *(fname+(tmp_ext-path))=0; - } - } -} +#include "splitp.c" diff --git a/reactos/lib/crt/stdlib/wtoi.c b/reactos/lib/crt/stdlib/wtoi.c index f8282056ef6..1a171024087 100644 --- a/reactos/lib/crt/stdlib/wtoi.c +++ b/reactos/lib/crt/stdlib/wtoi.c @@ -1,17 +1,6 @@ -#include -/* - * @implemented - */ -int _wtoi( const wchar_t *str ) -{ - return (int)wcstol(str, 0, 10); -} +#define _UNICODE +#define UNICODE + +#include "atoi.c" -/* - * @implemented - */ -long _wtol( const wchar_t *str ) -{ - return (int)wcstol(str, 0, 10); -} diff --git a/reactos/lib/crt/stdlib/wtoi64.c b/reactos/lib/crt/stdlib/wtoi64.c index a59513dadd2..6671f2be59f 100644 --- a/reactos/lib/crt/stdlib/wtoi64.c +++ b/reactos/lib/crt/stdlib/wtoi64.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/stdlib/wtol.c b/reactos/lib/crt/stdlib/wtol.c new file mode 100644 index 00000000000..e47cbbde33f --- /dev/null +++ b/reactos/lib/crt/stdlib/wtol.c @@ -0,0 +1,6 @@ + +#define _UNICODE +#define UNICODE + +#include "atol.c" + diff --git a/reactos/lib/crt/string/lasttok.c b/reactos/lib/crt/string/lasttok.c index 2713e4c954b..188b10d7085 100644 --- a/reactos/lib/crt/string/lasttok.c +++ b/reactos/lib/crt/string/lasttok.c @@ -2,8 +2,8 @@ #undef __USE_W32API #endif -#include -#include +#include +#include /* * This is an MSVCRT internal function to return the lasttoken diff --git a/reactos/lib/crt/string/memicmp.c b/reactos/lib/crt/string/memicmp.c index 3cbff006c09..039ccc5ae1c 100644 --- a/reactos/lib/crt/string/memicmp.c +++ b/reactos/lib/crt/string/memicmp.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/string/strcoll.c b/reactos/lib/crt/string/strcoll.c index 1571b4ae3c0..8ceb08f5df4 100644 --- a/reactos/lib/crt/string/strcoll.c +++ b/reactos/lib/crt/string/strcoll.c @@ -1,5 +1,5 @@ #include "precomp.h" -#include +#include /* Compare S1 and S2, returning less than, equal to or greater than zero if the collated form of S1 is lexicographically diff --git a/reactos/lib/crt/string/strdup.c b/reactos/lib/crt/string/strdup.c index c728585819b..5d4ebe6fb9b 100644 --- a/reactos/lib/crt/string/strdup.c +++ b/reactos/lib/crt/string/strdup.c @@ -1,6 +1,6 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/string/strerror.c b/reactos/lib/crt/string/strerror.c index fa8d9d0083b..df46dab88cd 100644 --- a/reactos/lib/crt/string/strerror.c +++ b/reactos/lib/crt/string/strerror.c @@ -1,7 +1,7 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include +#include +#include +#include char __syserr00[] = "No Error"; @@ -51,7 +51,7 @@ char __syserr42[] = "Illegal byte sequence (EILSEQ)"; -const char *_sys_errlist[] = { +char *_sys_errlist[] = { __syserr00, __syserr01, __syserr02, __syserr03, __syserr04, __syserr05, __syserr06, __syserr07, __syserr08, __syserr09, __syserr10, __syserr11, __syserr12, __syserr13, __syserr14, @@ -63,9 +63,9 @@ __syserr35, __syserr36, __syserr37, __syserr38, __syserr39, __syserr40, __syserr41, __syserr42 }; -int __sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]); +//int __sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]); -int* _sys_nerr = &__sys_nerr; +int/***/ _sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]);//&__sys_nerr; /* * @implemented @@ -76,7 +76,7 @@ char *strerror(int errnum) char *cp; int v=1000000, lz=0; - if (errnum >= 0 && errnum < __sys_nerr) + if (errnum >= 0 && errnum < _sys_nerr) return((char *)_sys_errlist[errnum]); strcpy(ebuf, "Unknown error: "); diff --git a/reactos/lib/crt/string/stricmp.c b/reactos/lib/crt/string/stricmp.c index cfecfb81931..ecd1afae22b 100644 --- a/reactos/lib/crt/string/stricmp.c +++ b/reactos/lib/crt/string/stricmp.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/string/strlwr.c b/reactos/lib/crt/string/strlwr.c index 6ddba9c7a2a..0f4a66b20c5 100644 --- a/reactos/lib/crt/string/strlwr.c +++ b/reactos/lib/crt/string/strlwr.c @@ -8,8 +8,8 @@ * Copyright 1997 Uwe Bonnes */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/string/strncoll.c b/reactos/lib/crt/string/strncoll.c index 304c52b1e5e..3f4d1088ea7 100644 --- a/reactos/lib/crt/string/strncoll.c +++ b/reactos/lib/crt/string/strncoll.c @@ -1,5 +1,5 @@ #include "precomp.h" -#include +#include /* Compare S1 and S2, returning less than, equal to or greater than zero if the collated form of S1 is lexicographically diff --git a/reactos/lib/crt/string/strnicmp.c b/reactos/lib/crt/string/strnicmp.c index d6ff2c0d2d1..a0d732e883b 100644 --- a/reactos/lib/crt/string/strnicmp.c +++ b/reactos/lib/crt/string/strnicmp.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/string/strpbrk.c b/reactos/lib/crt/string/strpbrk.c index 72079d0aa8a..c3ce6006734 100644 --- a/reactos/lib/crt/string/strpbrk.c +++ b/reactos/lib/crt/string/strpbrk.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* diff --git a/reactos/lib/crt/string/strrev.c b/reactos/lib/crt/string/strrev.c index 8827c3b5bb5..8f11abee723 100644 --- a/reactos/lib/crt/string/strrev.c +++ b/reactos/lib/crt/string/strrev.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/string/strset.c b/reactos/lib/crt/string/strset.c index 6de8d49b3bb..daf47aa296e 100644 --- a/reactos/lib/crt/string/strset.c +++ b/reactos/lib/crt/string/strset.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include + /* * @implemented diff --git a/reactos/lib/crt/string/strstr.c b/reactos/lib/crt/string/strstr.c index 430358fd196..bdc7eb7b8f8 100644 --- a/reactos/lib/crt/string/strstr.c +++ b/reactos/lib/crt/string/strstr.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* diff --git a/reactos/lib/crt/string/strtok.c b/reactos/lib/crt/string/strtok.c index 2423f4ae840..4bd36f39fdc 100644 --- a/reactos/lib/crt/string/strtok.c +++ b/reactos/lib/crt/string/strtok.c @@ -3,8 +3,8 @@ #undef __USE_W32API #endif -#include -#include +#include +#include char** _lasttoken(); /* lasttok.c */ diff --git a/reactos/lib/crt/string/strupr.c b/reactos/lib/crt/string/strupr.c index 413f585b21a..a878fa242b7 100644 --- a/reactos/lib/crt/string/strupr.c +++ b/reactos/lib/crt/string/strupr.c @@ -9,8 +9,8 @@ */ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/string/strxfrm.c b/reactos/lib/crt/string/strxfrm.c index dca7a645414..ae6fc98274a 100644 --- a/reactos/lib/crt/string/strxfrm.c +++ b/reactos/lib/crt/string/strxfrm.c @@ -1,5 +1,5 @@ #include "precomp.h" -#include +#include #if 1 /* diff --git a/reactos/lib/crt/sys_stat/fstat.c b/reactos/lib/crt/sys_stat/fstat.c index cc2addd351f..d84ca492d22 100644 --- a/reactos/lib/crt/sys_stat/fstat.c +++ b/reactos/lib/crt/sys_stat/fstat.c @@ -10,18 +10,18 @@ */ #include "precomp.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* * @implemented */ -int _fstat(int fd, struct stat* statbuf) +int _fstat(int fd, struct _stat* statbuf) { BY_HANDLE_FILE_INFORMATION FileInformation; DWORD dwFileType; @@ -32,7 +32,7 @@ int _fstat(int fd, struct stat* statbuf) return -1; } - if ((void*)-1 == (handle = _get_osfhandle(fd))) + if ((void*)-1 == (handle = (void*)_get_osfhandle(fd))) { __set_errno(EBADF); return -1; diff --git a/reactos/lib/crt/sys_stat/fstati64.c b/reactos/lib/crt/sys_stat/fstati64.c index ba7a053143f..0a05e278480 100644 --- a/reactos/lib/crt/sys_stat/fstati64.c +++ b/reactos/lib/crt/sys_stat/fstati64.c @@ -10,18 +10,18 @@ */ #include "precomp.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* * @implemented */ -__int64 _fstati64(int fd, struct _stati64* statbuf) +int _fstati64(int fd, struct _stati64* statbuf) { BY_HANDLE_FILE_INFORMATION FileInformation; DWORD dwFileType; @@ -33,7 +33,7 @@ __int64 _fstati64(int fd, struct _stati64* statbuf) return -1; } - if ((void*)-1 == (handle = _get_osfhandle(fd))) + if ((void*)-1 == (handle = (void*)_get_osfhandle(fd))) { __set_errno(EBADF); return -1; diff --git a/reactos/lib/crt/sys_stat/futime.c b/reactos/lib/crt/sys_stat/futime.c index ed3c37a9a66..e6d8306b1b7 100644 --- a/reactos/lib/crt/sys_stat/futime.c +++ b/reactos/lib/crt/sys_stat/futime.c @@ -1,10 +1,10 @@ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* @@ -22,7 +22,7 @@ int _futime (int nHandle, struct _utimbuf *pTimes) } if (pTimes == NULL) { - pTimes = alloca(sizeof(struct _utimbuf)); + pTimes = _alloca(sizeof(struct _utimbuf)); time(&pTimes->actime); time(&pTimes->modtime); } @@ -34,7 +34,7 @@ int _futime (int nHandle, struct _utimbuf *pTimes) UnixTimeToFileTime(pTimes->actime,&LastAccessTime,0); UnixTimeToFileTime(pTimes->modtime,&LastWriteTime,0); - if (!SetFileTime(_get_osfhandle(nHandle),NULL, &LastAccessTime, &LastWriteTime)) { + if (!SetFileTime((HANDLE)_get_osfhandle(nHandle),NULL, &LastAccessTime, &LastWriteTime)) { __set_errno(EBADF); return -1; } diff --git a/reactos/lib/crt/sys_stat/stat.c b/reactos/lib/crt/sys_stat/stat.c index a1f5af85835..87d4fd88781 100644 --- a/reactos/lib/crt/sys_stat/stat.c +++ b/reactos/lib/crt/sys_stat/stat.c @@ -1,17 +1,17 @@ #include "precomp.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* * @implemented */ -int _stat(const char* path, struct stat* buffer) +int _stat(const char* path, struct _stat* buffer) { WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; char* ext; @@ -64,7 +64,7 @@ int _stat(const char* path, struct stat* buffer) /* * @implemented */ -__int64 _stati64 (const char *path, struct _stati64 *buffer) +int _stati64 (const char *path, struct _stati64 *buffer) { WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; char* ext; diff --git a/reactos/lib/crt/sys_stat/systime.c b/reactos/lib/crt/sys_stat/systime.c index 59ecdc9d9ac..680270d31e3 100644 --- a/reactos/lib/crt/sys_stat/systime.c +++ b/reactos/lib/crt/sys_stat/systime.c @@ -1,5 +1,5 @@ #include "precomp.h" -#include +#include int month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31}; diff --git a/reactos/lib/crt/sys_stat/wstat.c b/reactos/lib/crt/sys_stat/wstat.c index 5cbdc4360df..cb9a1b3b3aa 100644 --- a/reactos/lib/crt/sys_stat/wstat.c +++ b/reactos/lib/crt/sys_stat/wstat.c @@ -1,17 +1,17 @@ #include "precomp.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* * @implemented */ -int _wstat (const wchar_t *path, struct stat *buffer) +int _wstat (const wchar_t *path, struct _stat *buffer) { WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; wchar_t *ext; @@ -64,7 +64,7 @@ int _wstat (const wchar_t *path, struct stat *buffer) /* * @implemented */ -__int64 _wstati64 (const wchar_t *path, struct _stati64 *buffer) +int _wstati64 (const wchar_t *path, struct _stati64 *buffer) { WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; wchar_t *ext; diff --git a/reactos/lib/crt/time/clock.c b/reactos/lib/crt/time/clock.c index cd9e77a41c8..e55b8e33d21 100644 --- a/reactos/lib/crt/time/clock.c +++ b/reactos/lib/crt/time/clock.c @@ -9,8 +9,8 @@ */ #include "precomp.h" -#include -#include +#include +#include VOID STDCALL GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime ); diff --git a/reactos/lib/crt/time/ctime.c b/reactos/lib/crt/time/ctime.c index fcadb68f1a3..ba7d3b47884 100644 --- a/reactos/lib/crt/time/ctime.c +++ b/reactos/lib/crt/time/ctime.c @@ -36,16 +36,16 @@ */ #include "precomp.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "tzfile.h" -#include +#include #include "posixrul.h" @@ -294,7 +294,7 @@ static int tzload(const char* name, struct state* CPP_CONST sp) name = fullname; } - if ((fid = open(name, OPEN_MODE)) == -1) + if ((fid = _open(name, OPEN_MODE)) == -1) { const char *base = strrchr(name, '/'); if (base) @@ -310,8 +310,8 @@ static int tzload(const char* name, struct state* CPP_CONST sp) } else { - i = read(fid, buf, sizeof buf); - if (close(fid) != 0 || i < sizeof *tzhp) + i = _read(fid, buf, sizeof buf); + if (_close(fid) != 0 || i < sizeof *tzhp) return -1; } @@ -1022,7 +1022,10 @@ localsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONS timesub(&t, ttisp->tt_gmtoff, sp, tmp); tmp->tm_isdst = ttisp->tt_isdst; _tzname[tmp->tm_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; +#if 0 +/* tm_zone doesnt exist in windows msvcrt -Gunnar */ tmp->tm_zone = (char *)&sp->chars[ttisp->tt_abbrind]; +#endif } /* @@ -1059,6 +1062,8 @@ gmtsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, ** but this is no time for a treasure hunt. */ +#if 0 +/* tm_zone doesnt exist in windows msvcrt -Gunnar */ if (offset != 0) tmp->tm_zone = TZ_NAME; else @@ -1073,6 +1078,7 @@ gmtsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp->tm_zone = gmtptr->chars; #endif /* State Farm */ } +#endif /* if 0 */ } /* @@ -1179,7 +1185,10 @@ timesub(const time_t * CPP_CONST timep, const long offset, const struct state * days = days - (long) ip[tmp->tm_mon]; tmp->tm_mday = (int) (days + 1); tmp->tm_isdst = 0; +#if 0 +/* tm_gmtoff doesnt exist in windows msvcrt -Gunnar */ tmp->tm_gmtoff = offset; +#endif } /* diff --git a/reactos/lib/crt/time/difftime.c b/reactos/lib/crt/time/difftime.c index 9e9d590a2cb..6b4de57c930 100644 --- a/reactos/lib/crt/time/difftime.c +++ b/reactos/lib/crt/time/difftime.c @@ -1,5 +1,5 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/time/ftime.c b/reactos/lib/crt/time/ftime.c index 8db083b3cff..867553f0c53 100644 --- a/reactos/lib/crt/time/ftime.c +++ b/reactos/lib/crt/time/ftime.c @@ -9,8 +9,8 @@ */ #include "precomp.h" -#include -#include +#include +#include /* ftime (3) -- Obsolete BSD library function included in the SUS for copat. * Also present in msvcrt.dll as _ftime @@ -18,7 +18,7 @@ /* * @implemented */ -void _ftime( struct timeb *tm ) +void _ftime( struct _timeb *tm ) { int ret = 0; SYSTEMTIME syst; @@ -28,7 +28,7 @@ void _ftime( struct timeb *tm ) if( ret == 0 ) { time( &tm->time ); tm->millitm = syst.wMilliseconds; - tm->_timezone = 0; /* According to the open group, timezone and dstflag */ +// tm->_timezone = 0; /* According to the open group, timezone and dstflag */ tm->dstflag = 0; /* exist for compatibility, but are unspecified. */ } } diff --git a/reactos/lib/crt/time/strdate.c b/reactos/lib/crt/time/strdate.c index 204e07d28d4..e421f52dfbf 100644 --- a/reactos/lib/crt/time/strdate.c +++ b/reactos/lib/crt/time/strdate.c @@ -7,16 +7,16 @@ * UPDATE HISTORY: * 28/12/98: Created */ -#include -#include -#include -#include +#include +#include +#include +#include /* * @implemented */ -char* _strdate(const char* datestr) +char* _strdate(char* datestr) { time_t t; struct tm* d; diff --git a/reactos/lib/crt/time/strftime.c b/reactos/lib/crt/time/strftime.c index bb7553e399c..e7ca78fb673 100644 --- a/reactos/lib/crt/time/strftime.c +++ b/reactos/lib/crt/time/strftime.c @@ -1,8 +1,8 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include +#include +#include +#include +#include #define TM_YEAR_BASE 1900 @@ -188,7 +188,10 @@ static size_t _fmt(const char* format, const struct tm* t) return 0; continue; case 'Z': +#if 0 + /* FIXME: tm_zone doesnt exist in windows */ if (!t->tm_zone || !_add(t->tm_zone)) +#endif return 0; continue; case '%': diff --git a/reactos/lib/crt/time/strtime.c b/reactos/lib/crt/time/strtime.c index a1aeeb13189..7473aea1b3e 100644 --- a/reactos/lib/crt/time/strtime.c +++ b/reactos/lib/crt/time/strtime.c @@ -7,10 +7,10 @@ * UPDATE HISTORY: * 28/12/98: Created */ -#include -#include -#include -#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/time/time.c b/reactos/lib/crt/time/time.c index bc459d54f7c..8dfc16c56cd 100644 --- a/reactos/lib/crt/time/time.c +++ b/reactos/lib/crt/time/time.c @@ -16,8 +16,8 @@ */ #include "precomp.h" -#include -#include +#include +#include VOID STDCALL GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime); diff --git a/reactos/lib/crt/time/tz_vars.c b/reactos/lib/crt/time/tz_vars.c index aad68dcb156..bb155d0fabc 100644 --- a/reactos/lib/crt/time/tz_vars.c +++ b/reactos/lib/crt/time/tz_vars.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include int _daylight; @@ -18,4 +18,18 @@ void _set_timezone_export(int value) } +/********************************************************************* + * __p_daylight (MSVCRT.@) + */ +void* __p__daylight(void) +{ + return &_daylight; +} +/********************************************************************* + * __p__timezone (MSVCRT.@) + */ +int* __p__timezone(void) +{ + return &_timezone; +} diff --git a/reactos/lib/crt/time/wctime.c b/reactos/lib/crt/time/wctime.c index 033595cfe1d..16cd12a2828 100644 --- a/reactos/lib/crt/time/wctime.c +++ b/reactos/lib/crt/time/wctime.c @@ -27,8 +27,9 @@ */ #include "precomp.h" -#include -#include +#include +#include +#include #include "tzfile.h" diff --git a/reactos/lib/crt/time/wstrdate.c b/reactos/lib/crt/time/wstrdate.c index a6a9d955985..faca97696a5 100644 --- a/reactos/lib/crt/time/wstrdate.c +++ b/reactos/lib/crt/time/wstrdate.c @@ -7,16 +7,16 @@ * UPDATE HISTORY: * 28/12/98: Created */ -#include -#include -#include -#include +#include +#include +#include +#include /* * @implemented */ -wchar_t* _wstrdate(const wchar_t* datestr) +wchar_t* _wstrdate(wchar_t* datestr) { time_t t; struct tm* d; diff --git a/reactos/lib/crt/time/wstrtime.c b/reactos/lib/crt/time/wstrtime.c index 8f5b2ace481..3fa0035f713 100644 --- a/reactos/lib/crt/time/wstrtime.c +++ b/reactos/lib/crt/time/wstrtime.c @@ -7,10 +7,10 @@ * UPDATE HISTORY: * 28/12/98: Created */ -#include -#include -#include -#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/wine/cpp.c b/reactos/lib/crt/wine/cpp.c index 1065cdc7c61..2176b257737 100644 --- a/reactos/lib/crt/wine/cpp.c +++ b/reactos/lib/crt/wine/cpp.c @@ -32,12 +32,12 @@ #include "winnt.h" #include "excpt.h" #include "wine/debug.h" -#include "msvcrt/malloc.h" -#include "msvcrt/stdlib.h" +#include +#include -#include -#include -#include +#include +#include +#include WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); diff --git a/reactos/lib/crt/wine/cppexcept.c b/reactos/lib/crt/wine/cppexcept.c index 98c4bcf7660..dea17149e31 100644 --- a/reactos/lib/crt/wine/cppexcept.c +++ b/reactos/lib/crt/wine/cppexcept.c @@ -32,12 +32,12 @@ #include "winbase.h" #include "winreg.h" #include "wine/winternl.h" -#include +#include #include "wine/exception.h" #include "excpt.h" #include "wine/debug.h" -#include +#include WINE_DEFAULT_DEBUG_CHANNEL(seh); diff --git a/reactos/lib/crt/wine/heap.c b/reactos/lib/crt/wine/heap.c index 54f7a762ae7..a9ccba4a003 100644 --- a/reactos/lib/crt/wine/heap.c +++ b/reactos/lib/crt/wine/heap.c @@ -23,10 +23,10 @@ #include "precomp.h" -#include "msvcrt/errno.h" -#include "msvcrt/malloc.h" -#include "msvcrt/stdlib.h" -#include +#include +#include +#include +#include #include "wine/debug.h" diff --git a/reactos/lib/crt/wine/scanf.c b/reactos/lib/crt/wine/scanf.c new file mode 100644 index 00000000000..33983384b65 --- /dev/null +++ b/reactos/lib/crt/wine/scanf.c @@ -0,0 +1,222 @@ +/* + * general implementation of scanf used by scanf, sscanf, fscanf, + * _cscanf, wscanf, swscanf and fwscanf + * + * Copyright 1996,1998 Marcus Meissner + * Copyright 1996 Jukka Iivonen + * Copyright 1997,2000 Uwe Bonnes + * Copyright 2000 Jon Griffiths + * Copyright 2002 Daniel Gudbjartsson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +/* +#include + +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "winternl.h" +#include "msvcrt.h" +*/ + +//#include +#include +//#include +//#include +#include +#include +#include +#include +#include + +//#include + +#define NDEBUG +#include + + +/* +This is so ugly. I tried including anything/everything, but no matter +what i did i got complaints about RtlGetProcessHeap etc. being undefined. +-Gunnar (i hate headers) +*/ +#define RtlFreeHeap HeapFree +#define RtlAllocateHeap HeapAlloc +#define RtlGetProcessHeap GetProcessHeap +//#include "wine/debug.h" + +#define WARN DPRINT1 + +//WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); + +extern FILE _iob[]; + +/* helper function for *scanf. Returns the value of character c in the + * given base, or -1 if the given character is not a digit of the base. + */ +static int char2digit(char c, int base) { + if ((c>='0') && (c<='9') && (c<='0'+base-1)) return (c-'0'); + if (base<=10) return -1; + if ((c>='A') && (c<='Z') && (c<='A'+base-11)) return (c-'A'+10); + if ((c>='a') && (c<='z') && (c<='a'+base-11)) return (c-'a'+10); + return -1; +} + +/* helper function for *wscanf. Returns the value of character c in the + * given base, or -1 if the given character is not a digit of the base. + */ +static int wchar2digit(wchar_t c, int base) { + if ((c>=L'0') && (c<=L'9') && (c<=L'0'+base-1)) return (c-L'0'); + if (base<=10) return -1; + if ((c>=L'A') && (c<=L'Z') && (c<=L'A'+base-11)) return (c-L'A'+10); + if ((c>=L'a') && (c<=L'z') && (c<=L'a'+base-11)) return (c-L'a'+10); + return -1; +} + +/* vfscanf */ +#undef WIDE_SCANF +#undef CONSOLE +#undef STRING +#include "scanf.h" + +/* vfwscanf */ +#define WIDE_SCANF 1 +#undef CONSOLE +#undef STRING +#include "scanf.h" + +/* vsscanf */ +#undef WIDE_SCANF +#undef CONSOLE +#define STRING 1 +#include "scanf.h" + +/* vswscanf */ +#define WIDE_SCANF 1 +#undef CONSOLE +#define STRING 1 +#include "scanf.h" + +/* vcscanf */ +#undef WIDE_SCANF +#define CONSOLE 1 +#undef STRING +#include "scanf.h" + + +/********************************************************************* + * fscanf (MSVCRT.@) + */ +int fscanf(FILE *file, const char *format, ...) +{ + va_list valist; + int res; + + va_start(valist, format); + res = vfscanf(file, format, valist); + va_end(valist); + return res; +} + +/********************************************************************* + * scanf (MSVCRT.@) + */ +int scanf(const char *format, ...) +{ + va_list valist; + int res; + + va_start(valist, format); + res = vfscanf(stdin, format, valist); + va_end(valist); + return res; +} + +/********************************************************************* + * fwscanf (MSVCRT.@) + */ +int fwscanf(FILE *file, const wchar_t *format, ...) +{ + va_list valist; + int res; + + va_start(valist, format); + res = vfwscanf(file, format, valist); + va_end(valist); + return res; +} + + +/********************************************************************* + * wscanf (MSVCRT.@) + */ +int wscanf(const wchar_t *format, ...) +{ + va_list valist; + int res; + + va_start(valist, format); + res = vfwscanf(stdin, format, valist); + va_end(valist); + return res; +} + + +/********************************************************************* + * sscanf (MSVCRT.@) + */ +int sscanf(const char *str, const char *format, ...) +{ + va_list valist; + int res; + + va_start(valist, format); + res = vsscanf(str, format, valist); + va_end(valist); + return res; +} + + +/********************************************************************* + * swscanf (MSVCRT.@) + */ +int swscanf(const wchar_t *str, const wchar_t *format, ...) +{ + va_list valist; + int res; + + va_start(valist, format); + res = vswscanf(str, format, valist); + va_end(valist); + return res; +} + + +/********************************************************************* + * _cscanf (MSVCRT.@) + */ +int _cscanf(/*const*/ char *format, ...) +{ + va_list valist; + int res; + + va_start(valist, format); + res = vcscanf(format, valist); + va_end(valist); + return res; +} diff --git a/reactos/lib/crt/wine/scanf.h b/reactos/lib/crt/wine/scanf.h new file mode 100644 index 00000000000..5fe005b9a88 --- /dev/null +++ b/reactos/lib/crt/wine/scanf.h @@ -0,0 +1,537 @@ +/* + * general implementation of scanf used by scanf, sscanf, fscanf, + * _cscanf, wscanf, swscanf and fwscanf + * + * Copyright 1996,1998 Marcus Meissner + * Copyright 1996 Jukka Iivonen + * Copyright 1997,2000, 2003 Uwe Bonnes + * Copyright 2000 Jon Griffiths + * Copyright 2002 Daniel Gudbjartsson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef WIDE_SCANF +#define _CHAR_ wchar_t +#define _EOF_ WEOF +#define _EOF_RET WEOF +#define _ISSPACE_(c) iswspace(c) +#define _ISDIGIT_(c) iswdigit(c) +#define _WIDE2SUPPORTED_(c) c /* No conversion needed (wide to wide) */ +#define _CHAR2SUPPORTED_(c) c /* FIXME: convert char to wide char */ +#define _CHAR2DIGIT_(c, base) wchar2digit((c), (base)) +#define _BITMAPSIZE_ 256*256 +#else /* WIDE_SCANF */ +#define _CHAR_ char +#define _EOF_ EOF +#define _EOF_RET EOF +#define _ISSPACE_(c) isspace(c) +#define _ISDIGIT_(c) isdigit(c) +#define _WIDE2SUPPORTED_(c) c /* FIXME: convert wide char to char */ +#define _CHAR2SUPPORTED_(c) c /* No conversion needed (char to char) */ +#define _CHAR2DIGIT_(c, base) char2digit((c), (base)) +#define _BITMAPSIZE_ 256 +#endif /* WIDE_SCANF */ + +#ifdef CONSOLE +#define _GETC_(file) (consumed++, _getch()) +#define _UNGETC_(nch, file) do { _ungetch(nch); consumed--; } while(0) +#define _FUNCTION_ int vcscanf(const char *format, va_list ap) +#else +#ifdef STRING +#undef _EOF_ +#define _EOF_ 0 +#define _GETC_(file) (consumed++, *file++) +#define _UNGETC_(nch, file) do { file--; consumed--; } while(0) +#ifdef WIDE_SCANF +#define _FUNCTION_ int vswscanf(const wchar_t *file, const wchar_t *format, va_list ap) +#else /* WIDE_SCANF */ +#define _FUNCTION_ int vsscanf(const char *file, const char *format, va_list ap) +#endif /* WIDE_SCANF */ +#else /* STRING */ +#ifdef WIDE_SCANF +#define _GETC_(file) (consumed++, fgetwc(file)) +#define _UNGETC_(nch, file) do { ungetwc(nch, file); consumed--; } while(0) +#define _FUNCTION_ int vfwscanf(FILE* file, const wchar_t *format, va_list ap) +#else /* WIDE_SCANF */ +#define _GETC_(file) (consumed++, fgetc(file)) +#define _UNGETC_(nch, file) do { ungetc(nch, file); consumed--; } while(0) +#define _FUNCTION_ int vfscanf(FILE* file, const char *format, va_list ap) +#endif /* WIDE_SCANF */ +#endif /* STRING */ +#endif /* CONSOLE */ + +/********************************************************************* + * Implemented based on + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt_format_specification_fields_.2d_.scanf_and_wscanf_functions.asp + * Extended by C. Scott Ananian to handle + * more types of format spec. + */ +_FUNCTION_ { + int rd = 0, consumed = 0; + int nch; + if (!*format) return 0; +#ifndef WIDE_SCANF +#ifdef CONSOLE + TRACE("(%s): \n", debugstr_a(format)); +#else /* CONSOLE */ +#ifdef STRING + TRACE("%s (%s)\n", file, debugstr_a(format)); +#else /* STRING */ + TRACE("%p (%s)\n", file, debugstr_a(format)); +#endif /* STRING */ +#endif /* CONSOLE */ +#endif /* WIDE_SCANF */ + nch = _GETC_(file); + if (nch == _EOF_) return _EOF_RET; + + while (*format) { + /* a whitespace character in the format string causes scanf to read, + * but not store, all consecutive white-space characters in the input + * up to the next non-white-space character. One white space character + * in the input matches any number (including zero) and combination of + * white-space characters in the input. */ + if (_ISSPACE_(*format)) { + /* skip whitespace */ + while ((nch!=_EOF_) && _ISSPACE_(nch)) + nch = _GETC_(file); + } + /* a format specification causes scanf to read and convert characters + * in the input into values of a specified type. The value is assigned + * to an argument in the argument list. Format specifications have + * the form %[*][width][{h | l | I64 | L}]type */ + else if (*format == '%') { + int st = 0; int suppress = 0; int width = 0; + int base, number_signed; + int h_prefix = 0; + int l_prefix = 0; + int L_prefix = 0; + int w_prefix = 0; + int prefix_finished = 0; + int I64_prefix = 0; + format++; + /* look for leading asterisk, which means 'suppress assignment of + * this field'. */ + if (*format=='*') { + format++; + suppress=1; + } + /* look for width specification */ + while (_ISDIGIT_(*format)) { + width*=10; + width+=*format++ - '0'; + } + if (width==0) width=-1; /* no width spec seen */ + /* read prefix (if any) */ + while (!prefix_finished) { + switch(*format) { + case 'h': h_prefix = 1; break; + case 'l': l_prefix = 1; break; + case 'w': w_prefix = 1; break; + case 'L': L_prefix = 1; break; + case 'I': + if (*(format + 1) == '6' && + *(format + 2) == '4') { + I64_prefix = 1; + format += 2; + } + break; + default: + prefix_finished = 1; + } + if (!prefix_finished) format++; + } + /* read type */ + switch(*format) { + case 'x': + case 'X': /* hexadecimal integer. */ + base = 16; number_signed = 0; + goto number; + case 'o': /* octal integer */ + base = 8; number_signed = 0; + goto number; + case 'u': /* unsigned decimal integer */ + base = 10; number_signed = 0; + goto number; + case 'd': /* signed decimal integer */ + base = 10; number_signed = 1; + goto number; + case 'i': /* generic integer */ + base = 10; number_signed = 1; + number: { + /* read an integer */ + ULONGLONG cur = 0; + int negative = 0; + int seendigit=0; + /* skip initial whitespace */ + while ((nch!=_EOF_) && _ISSPACE_(nch)) + nch = _GETC_(file); + /* get sign */ + if (number_signed && (nch == '-' || + nch == '+')) { + negative = (nch=='-'); + nch = _GETC_(file); + if (width>0) width--; + } + /* look for leading indication of base */ + if (width!=0 && nch == '0') { + nch = _GETC_(file); + if (width>0) width--; + seendigit=1; + if (width!=0 && (nch=='x' || nch=='X')) { + if (base==0) + base=16; + if (base==16) { + nch = _GETC_(file); + if (width>0) width--; + seendigit=0; + } + } else if (base==0) + base = 8; + } + /* throw away leading zeros */ + while (width!=0 && nch=='0') { + nch = _GETC_(file); + if (width>0) width--; + seendigit=1; + } + if (width!=0 && _CHAR2DIGIT_(nch, base)!=-1) { + cur = _CHAR2DIGIT_(nch, base); + nch = _GETC_(file); + if (width>0) width--; + seendigit=1; + } + /* read until no more digits */ + while (width!=0 && (nch!=_EOF_) && _CHAR2DIGIT_(nch, base)!=-1) { + cur = cur*base + _CHAR2DIGIT_(nch, base); + nch = _GETC_(file); + if (width>0) width--; + seendigit=1; + } + /* okay, done! */ + if (!seendigit) break; /* not a valid number */ + st = 1; + if (!suppress) { +#define _SET_NUMBER_(type) *va_arg(ap, type*) = negative ? -cur : cur + if (number_signed) { + if (I64_prefix) _SET_NUMBER_(LONGLONG); + else if (l_prefix) _SET_NUMBER_(long int); + else if (h_prefix) _SET_NUMBER_(short int); + else _SET_NUMBER_(int); + } else { + if (negative) { + WARN("Dropping sign in reading a negative number into an unsigned value"); + negative = 0; + } + if (I64_prefix) _SET_NUMBER_(ULONGLONG); + else if (l_prefix) _SET_NUMBER_(unsigned long int); + else if (h_prefix) + _SET_NUMBER_(unsigned short int); + else _SET_NUMBER_(unsigned int); + } + } + } + break; + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': { /* read a float */ + long double cur = 0; + int negative = 0; + /* skip initial whitespace */ + while ((nch!=_EOF_) && _ISSPACE_(nch)) + nch = _GETC_(file); + /* get sign. */ + if (nch == '-' || nch == '+') { + negative = (nch=='-'); + if (width>0) width--; + if (width==0) break; + nch = _GETC_(file); + } + /* get first digit. */ + if ('.' != nch) { + if (!_ISDIGIT_(nch)) break; + cur = (nch - '0'); + nch = _GETC_(file); + if (width>0) width--; + /* read until no more digits */ + while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) { + cur = cur*10 + (nch - '0'); + nch = _GETC_(file); + if (width>0) width--; + } + } else { + cur = 0; /* MaxPayneDemo Fix: .8 -> 0.8 */ + } + /* handle decimals */ + if (width!=0 && nch == '.') { + float dec = 1; + nch = _GETC_(file); + if (width>0) width--; + while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) { + dec /= 10; + cur += dec * (nch - '0'); + nch = _GETC_(file); + if (width>0) width--; + } + } + /* handle exponent */ + if (width!=0 && (nch == 'e' || nch == 'E')) { + int exponent = 0, negexp = 0; + float expcnt; + nch = _GETC_(file); + if (width>0) width--; + /* possible sign on the exponent */ + if (width!=0 && (nch=='+' || nch=='-')) { + negexp = (nch=='-'); + nch = _GETC_(file); + if (width>0) width--; + } + /* exponent digits */ + while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) { + exponent *= 10; + exponent += (nch - '0'); + nch = _GETC_(file); + if (width>0) width--; + } + /* update 'cur' with this exponent. */ + expcnt = negexp ? .1 : 10; + while (exponent!=0) { + if (exponent&1) + cur*=expcnt; + exponent/=2; + expcnt=expcnt*expcnt; + } + } + st = 1; + if (!suppress) { + if (L_prefix) _SET_NUMBER_(long double); + else if (l_prefix) _SET_NUMBER_(double); + else _SET_NUMBER_(float); + } + } + break; + /* According to + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_scanf_type_field_characters.asp + * 's' reads a character string in a call to fscanf + * and 'S' a wide character string and vice versa in a + * call to fwscanf. The 'h', 'w' and 'l' prefixes override + * this behaviour. 'h' forces reading char * but 'l' and 'w' + * force reading WCHAR. */ + case 's': + if (w_prefix || l_prefix) goto widecharstring; + else if (h_prefix) goto charstring; +#ifdef WIDE_SCANF + else goto widecharstring; +#else /* WIDE_SCANF */ + else goto charstring; +#endif /* WIDE_SCANF */ + case 'S': + if (w_prefix || l_prefix) goto widecharstring; + else if (h_prefix) goto charstring; +#ifdef WIDE_SCANF + else goto charstring; +#else /* WIDE_SCANF */ + else goto widecharstring; +#endif /* WIDE_SCANF */ + charstring: { /* read a word into a char */ + char*str = suppress ? NULL : va_arg(ap, char*); + char*sptr = str; + /* skip initial whitespace */ + while ((nch!=_EOF_) && _ISSPACE_(nch)) + nch = _GETC_(file); + /* read until whitespace */ + while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) { + if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch); + st++; + nch = _GETC_(file); + if (width>0) width--; + } + /* terminate */ + if (!suppress) *sptr = 0; + } + break; + widecharstring: { /* read a word into a wchar_t* */ + wchar_t*str = + suppress ? NULL : va_arg(ap, wchar_t*); + wchar_t*sptr = str; + /* skip initial whitespace */ + while ((nch!=_EOF_) && _ISSPACE_(nch)) + nch = _GETC_(file); + /* read until whitespace */ + while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) { + if (!suppress) *sptr++ = _WIDE2SUPPORTED_(nch); + st++; + nch = _GETC_(file); + if (width>0) width--; + } + /* terminate */ + if (!suppress) *sptr = 0; + } + break; + /* 'c' and 'C work analogously to 's' and 'S' as described + * above */ + case 'c': + if (w_prefix || l_prefix) goto widecharacter; + else if (h_prefix) goto character; +#ifdef WIDE_SCANF + else goto widecharacter; +#else /* WIDE_SCANF */ + else goto character; +#endif /* WIDE_SCANF */ + case 'C': + if (w_prefix || l_prefix) goto widecharacter; + else if (h_prefix) goto character; +#ifdef WIDE_SCANF + else goto character; +#else /* WIDE_SCANF */ + else goto widecharacter; +#endif /* WIDE_SCANF */ + character: { /* read single character into char */ + if (nch!=_EOF_) { + if (!suppress) { + char*c = va_arg(ap, char*); + *c = _CHAR2SUPPORTED_(nch); + } + st = 1; + nch = _GETC_(file); + } + } + break; + widecharacter: { /* read single character into a wchar_t */ + if (nch!=_EOF_) { + if (!suppress) { + wchar_t*c = va_arg(ap, wchar_t*); + *c = _WIDE2SUPPORTED_(nch); + } + nch = _GETC_(file); + st = 1; + } + } + break; + case 'n': { + if (!suppress) { + int*n = va_arg(ap, int*); + *n = consumed - (nch!=_EOF_); + } + } + break; + case '[': { + _CHAR_ *str = suppress ? NULL : va_arg(ap, _CHAR_*); + _CHAR_ *sptr = str; + RTL_BITMAP bitMask; + ULONG *Mask; + int invert = 0; /* Set if we are NOT to find the chars */ + + /* Init our bitmap */ + Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, _BITMAPSIZE_/8); + RtlInitializeBitMap(&bitMask, Mask, _BITMAPSIZE_); + + /* Read the format */ + format++; + if(*format == '^') { + invert = 1; + format++; + } + if(*format == ']') { + RtlSetBits(&bitMask, ']', 1); + format++; + } + while(*format && (*format != ']')) { + /* According to: + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt_scanf_width_specification.asp + * "Note that %[a-z] and %[z-a] are interpreted as equivalent to %[abcde...z]." */ + if((*format == '-') && (*(format + 1) != ']')) { + if ((*(format - 1)) < *(format + 1)) + RtlSetBits(&bitMask, *(format - 1) +1 , *(format + 1) - *(format - 1)); + else + RtlSetBits(&bitMask, *(format + 1) , *(format - 1) - *(format + 1)); + format++; + } else + RtlSetBits(&bitMask, *format, 1); + format++; + } + /* read until char is not suitable */ + while ((width != 0) && (nch != _EOF_)) { + if(!invert) { + if(RtlAreBitsSet(&bitMask, nch, 1)) { + if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch); + } else + break; + } else { + if(RtlAreBitsClear(&bitMask, nch, 1)) { + if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch); + } else + break; + } + st++; + nch = _GETC_(file); + if (width>0) width--; + } + /* terminate */ + if (!suppress) *sptr = 0; + HeapFree(GetProcessHeap(), 0, Mask); + } + break; + default: + /* From spec: "if a percent sign is followed by a character + * that has no meaning as a format-control character, that + * character and the following characters are treated as + * an ordinary sequence of characters, that is, a sequence + * of characters that must match the input. For example, + * to specify that a percent-sign character is to be input, + * use %%." */ + while ((nch!=_EOF_) && _ISSPACE_(nch)) + nch = _GETC_(file); + if (nch==*format) { + suppress = 1; /* whoops no field to be read */ + st = 1; /* but we got what we expected */ + nch = _GETC_(file); + } + break; + } + if (st && !suppress) rd++; + else if (!st) break; + } + /* a non-white-space character causes scanf to read, but not store, + * a matching non-white-space character. */ + else { + /* check for character match */ + if (nch == *format) { + nch = _GETC_(file); + } else break; + } + format++; + } + if (nch!=_EOF_) { + _UNGETC_(nch, file); + } + TRACE("returning %d\n", rd); + return rd; +} + +#undef _CHAR_ +#undef _EOF_ +#undef _EOF_RET +#undef _ISSPACE_ +#undef _ISDIGIT_ +#undef _CHAR2SUPPORTED_ +#undef _WIDE2SUPPORTED_ +#undef _CHAR2DIGIT_ +#undef _GETC_ +#undef _UNGETC_ +#undef _FUNCTION_ +#undef _BITMAPSIZE_ diff --git a/reactos/lib/crt/wine/thread.c b/reactos/lib/crt/wine/thread.c index f8b9a579574..15434fc384d 100644 --- a/reactos/lib/crt/wine/thread.c +++ b/reactos/lib/crt/wine/thread.c @@ -19,10 +19,10 @@ */ #include "precomp.h" -#include +#include -#include "msvcrt/malloc.h" -#include "msvcrt/process.h" +#include +#include #include "wine/debug.h" diff --git a/reactos/lib/crt/wstring/wcscoll.c b/reactos/lib/crt/wstring/wcscoll.c index e1c27270ed2..abfbb011c26 100644 --- a/reactos/lib/crt/wstring/wcscoll.c +++ b/reactos/lib/crt/wstring/wcscoll.c @@ -1,5 +1,5 @@ -#include +#include /* * @unimplemented diff --git a/reactos/lib/crt/wstring/wcscspn.c b/reactos/lib/crt/wstring/wcscspn.c index 44f66b70b61..64ad89d4c52 100644 --- a/reactos/lib/crt/wstring/wcscspn.c +++ b/reactos/lib/crt/wstring/wcscspn.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcsdup.c b/reactos/lib/crt/wstring/wcsdup.c index 9c150a44acb..62a65c28c89 100644 --- a/reactos/lib/crt/wstring/wcsdup.c +++ b/reactos/lib/crt/wstring/wcsdup.c @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include +#include +#include +#include /* diff --git a/reactos/lib/crt/wstring/wcsicmp.c b/reactos/lib/crt/wstring/wcsicmp.c index 82feea78558..fd2de512775 100644 --- a/reactos/lib/crt/wstring/wcsicmp.c +++ b/reactos/lib/crt/wstring/wcsicmp.c @@ -1,7 +1,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include +#include +#include /* diff --git a/reactos/lib/crt/wstring/wcslwr.c b/reactos/lib/crt/wstring/wcslwr.c index 176af2fceeb..bc35b6e7172 100644 --- a/reactos/lib/crt/wstring/wcslwr.c +++ b/reactos/lib/crt/wstring/wcslwr.c @@ -8,7 +8,7 @@ * Copyright 1997 Uwe Bonnes */ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcsnicmp.c b/reactos/lib/crt/wstring/wcsnicmp.c index 4a99c8c492a..cc9eeee060f 100644 --- a/reactos/lib/crt/wstring/wcsnicmp.c +++ b/reactos/lib/crt/wstring/wcsnicmp.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcspbrk.c b/reactos/lib/crt/wstring/wcspbrk.c index e65ec33c2e0..abfe91e78f7 100644 --- a/reactos/lib/crt/wstring/wcspbrk.c +++ b/reactos/lib/crt/wstring/wcspbrk.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcsrev.c b/reactos/lib/crt/wstring/wcsrev.c index 4c213c5bf62..89c8ca7f04b 100644 --- a/reactos/lib/crt/wstring/wcsrev.c +++ b/reactos/lib/crt/wstring/wcsrev.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcsset.c b/reactos/lib/crt/wstring/wcsset.c index 3e797b04348..56ac5d98c99 100644 --- a/reactos/lib/crt/wstring/wcsset.c +++ b/reactos/lib/crt/wstring/wcsset.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcsspn.c b/reactos/lib/crt/wstring/wcsspn.c index 1025c8c1c2a..b50e104cce4 100644 --- a/reactos/lib/crt/wstring/wcsspn.c +++ b/reactos/lib/crt/wstring/wcsspn.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcsstr.c b/reactos/lib/crt/wstring/wcsstr.c index 7167f946c56..f8827b33942 100644 --- a/reactos/lib/crt/wstring/wcsstr.c +++ b/reactos/lib/crt/wstring/wcsstr.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcstok.c b/reactos/lib/crt/wstring/wcstok.c index 72cc6000a7c..e79fe27f861 100644 --- a/reactos/lib/crt/wstring/wcstok.c +++ b/reactos/lib/crt/wstring/wcstok.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include wchar_t** _wlasttoken(); /* wlasttok.c */ diff --git a/reactos/lib/crt/wstring/wcsupr.c b/reactos/lib/crt/wstring/wcsupr.c index 4a5dd8ad198..c62113c985b 100644 --- a/reactos/lib/crt/wstring/wcsupr.c +++ b/reactos/lib/crt/wstring/wcsupr.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wcsxfrm.c b/reactos/lib/crt/wstring/wcsxfrm.c index 9e5cb52ac99..3ee861f668a 100644 --- a/reactos/lib/crt/wstring/wcsxfrm.c +++ b/reactos/lib/crt/wstring/wcsxfrm.c @@ -1,4 +1,4 @@ -#include +#include /* * @implemented diff --git a/reactos/lib/crt/wstring/wlasttok.c b/reactos/lib/crt/wstring/wlasttok.c index fcc80c06d0e..14c333f4e1d 100644 --- a/reactos/lib/crt/wstring/wlasttok.c +++ b/reactos/lib/crt/wstring/wlasttok.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include /* * This is an MSVCRT internal function to return the lasttoken * bit of data used by wcstok. The reason for it's existence is