From f96362240e5512597ad42768014d4d153f87c3f9 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Wed, 14 Mar 2007 20:28:28 +0000 Subject: [PATCH] - Remove leftovers. svn path=/trunk/; revision=26096 --- reactos/lib/crt/README.txt | 13 - reactos/lib/crt/conio/cgets.c | 73 - reactos/lib/crt/conio/cprintf.c | 36 - reactos/lib/crt/conio/cputs.c | 23 - reactos/lib/crt/conio/getch.c | 55 - reactos/lib/crt/conio/getche.c | 29 - reactos/lib/crt/conio/kbhit.c | 30 - reactos/lib/crt/conio/putch.c | 24 - reactos/lib/crt/conio/ungetch.c | 29 - reactos/lib/crt/crt.rbuild | 415 ----- reactos/lib/crt/direct/chdir.c | 16 - reactos/lib/crt/direct/chdrive.c | 45 - reactos/lib/crt/direct/getcwd.c | 33 - reactos/lib/crt/direct/getdcwd.c | 62 - reactos/lib/crt/direct/getdfree.c | 23 - reactos/lib/crt/direct/getdrive.c | 35 - reactos/lib/crt/direct/mkdir.c | 15 - reactos/lib/crt/direct/rmdir.c | 15 - reactos/lib/crt/direct/wchdir.c | 5 - reactos/lib/crt/direct/wgetcwd.c | 5 - reactos/lib/crt/direct/wgetdcwd.c | 5 - reactos/lib/crt/direct/wmkdir.c | 4 - reactos/lib/crt/direct/wrmdir.c | 4 - reactos/lib/crt/except/abnorter.c | 16 - reactos/lib/crt/except/exhand2.c | 33 - reactos/lib/crt/except/i386/seh.s | 380 ----- reactos/lib/crt/except/i386/unwind.c | 72 - reactos/lib/crt/except/matherr.c | 33 - reactos/lib/crt/except/xcptfil.c | 15 - reactos/lib/crt/float/chgsign.c | 33 - reactos/lib/crt/float/copysign.c | 36 - reactos/lib/crt/float/fpclass.c | 86 - reactos/lib/crt/float/fpecode.c | 20 - reactos/lib/crt/float/fpreset.c | 21 - reactos/lib/crt/float/i386/clearfp.c | 29 - reactos/lib/crt/float/i386/cntrlfp.c | 174 -- reactos/lib/crt/float/i386/logb.c | 34 - reactos/lib/crt/float/i386/statfp.c | 29 - reactos/lib/crt/float/isnan.c | 96 -- reactos/lib/crt/float/nafter.c | 25 - reactos/lib/crt/float/scalb.c | 30 - reactos/lib/crt/include/float.h | 171 -- reactos/lib/crt/include/internal/atexit.h | 17 - reactos/lib/crt/include/internal/console.h | 16 - reactos/lib/crt/include/internal/debug.h | 97 -- reactos/lib/crt/include/internal/file.h | 190 --- reactos/lib/crt/include/internal/ieee.h | 25 - reactos/lib/crt/include/internal/math.h | 12 - reactos/lib/crt/include/internal/mbstring.h | 37 - reactos/lib/crt/include/internal/mtdll.h | 72 - reactos/lib/crt/include/internal/rterror.h | 31 - reactos/lib/crt/include/internal/tls.h | 50 - .../lib/crt/include/internal/wine/cppexcept.h | 124 -- reactos/lib/crt/include/internal/wine/eh.h | 53 - .../lib/crt/include/internal/wine/msvcrt.h | 135 -- reactos/lib/crt/io/access.c | 59 - reactos/lib/crt/io/chmod.c | 57 - reactos/lib/crt/io/chsize.c | 21 - reactos/lib/crt/io/close.c | 20 - reactos/lib/crt/io/commit.c | 14 - reactos/lib/crt/io/create.c | 24 - reactos/lib/crt/io/dup.c | 38 - reactos/lib/crt/io/dup2.c | 9 - reactos/lib/crt/io/eof.c | 27 - reactos/lib/crt/io/filelen.c | 17 - reactos/lib/crt/io/fileleni.c | 19 - reactos/lib/crt/io/find.c | 189 --- reactos/lib/crt/io/fmode.c | 12 - reactos/lib/crt/io/isatty.c | 15 - reactos/lib/crt/io/locking.c | 17 - reactos/lib/crt/io/lseek.c | 17 - reactos/lib/crt/io/lseeki64.c | 39 - reactos/lib/crt/io/mktemp.c | 75 - reactos/lib/crt/io/open.c | 729 --------- reactos/lib/crt/io/pipe.c | 53 - reactos/lib/crt/io/read.c | 100 -- reactos/lib/crt/io/setmode.c | 16 - reactos/lib/crt/io/sopen.c | 20 - reactos/lib/crt/io/stubs.c | 1 - reactos/lib/crt/io/tell.c | 10 - reactos/lib/crt/io/telli64.c | 19 - reactos/lib/crt/io/umask.c | 14 - reactos/lib/crt/io/unlink.c | 28 - reactos/lib/crt/io/utime.c | 31 - reactos/lib/crt/io/waccess.c | 4 - reactos/lib/crt/io/wchmod.c | 4 - reactos/lib/crt/io/wcreate.c | 24 - reactos/lib/crt/io/wfind.c | 5 - reactos/lib/crt/io/wmktemp.c | 76 - reactos/lib/crt/io/wopen.c | 143 -- reactos/lib/crt/io/write.c | 98 -- reactos/lib/crt/io/wunlink.c | 27 - reactos/lib/crt/io/wutime.c | 32 - reactos/lib/crt/locale/locale.c | 276 ---- reactos/lib/crt/math/acos.c | 27 - reactos/lib/crt/math/adjust.c | 7 - reactos/lib/crt/math/asin.c | 27 - reactos/lib/crt/math/cabs.c | 14 - reactos/lib/crt/math/cosh.c | 12 - reactos/lib/crt/math/frexp.c | 29 - reactos/lib/crt/math/huge_val.c | 6 - reactos/lib/crt/math/hypot.c | 98 -- reactos/lib/crt/math/i386/.gitignore | 0 reactos/lib/crt/math/i386/atan2.c | 21 - reactos/lib/crt/math/i386/atan_asm.s | 22 - reactos/lib/crt/math/i386/exp.c | 47 - reactos/lib/crt/math/i386/fmod.c | 39 - reactos/lib/crt/math/i386/ldexp.c | 36 - reactos/lib/crt/math/i386/log10_asm.s | 25 - reactos/lib/crt/math/i386/pow_asm.s | 140 -- reactos/lib/crt/math/j0_y0.c | 18 - reactos/lib/crt/math/j1_y1.c | 18 - reactos/lib/crt/math/jn_yn.c | 18 - reactos/lib/crt/math/modf.c | 86 - reactos/lib/crt/math/pow_asm.c | 30 - reactos/lib/crt/math/s_modf.c | 194 --- reactos/lib/crt/math/sinh.c | 19 - reactos/lib/crt/math/stubs.c | 133 -- reactos/lib/crt/math/tanh.c | 20 - reactos/lib/crt/mbstring/hanzen.c | 107 -- reactos/lib/crt/mbstring/ischira.c | 46 - reactos/lib/crt/mbstring/iskana.c | 21 - reactos/lib/crt/mbstring/iskmoji.c | 6 - reactos/lib/crt/mbstring/iskpun.c | 18 - reactos/lib/crt/mbstring/islead.c | 11 - reactos/lib/crt/mbstring/islwr.c | 26 - reactos/lib/crt/mbstring/ismbal.c | 20 - reactos/lib/crt/mbstring/ismbaln.c | 12 - reactos/lib/crt/mbstring/ismbc.c | 135 -- reactos/lib/crt/mbstring/ismbgra.c | 11 - reactos/lib/crt/mbstring/ismbkaln.c | 19 - reactos/lib/crt/mbstring/ismblead.c | 66 - reactos/lib/crt/mbstring/ismbpri.c | 11 - reactos/lib/crt/mbstring/ismbpun.c | 29 - reactos/lib/crt/mbstring/ismbtrl.c | 46 - reactos/lib/crt/mbstring/isuppr.c | 26 - reactos/lib/crt/mbstring/jistojms.c | 27 - reactos/lib/crt/mbstring/jmstojis.c | 28 - reactos/lib/crt/mbstring/mbbtype.c | 54 - reactos/lib/crt/mbstring/mbccpy.c | 15 - reactos/lib/crt/mbstring/mbclen.c | 33 - reactos/lib/crt/mbstring/mbscat.c | 10 - reactos/lib/crt/mbstring/mbschr.c | 9 - reactos/lib/crt/mbstring/mbscmp.c | 10 - reactos/lib/crt/mbstring/mbscoll.c | 100 -- reactos/lib/crt/mbstring/mbscpy.c | 11 - reactos/lib/crt/mbstring/mbscspn.c | 23 - reactos/lib/crt/mbstring/mbsdec.c | 18 - reactos/lib/crt/mbstring/mbsdup.c | 29 - reactos/lib/crt/mbstring/mbsicmp.c | 65 - reactos/lib/crt/mbstring/mbsicoll.c | 58 - reactos/lib/crt/mbstring/mbsinc.c | 13 - reactos/lib/crt/mbstring/mbslen.c | 18 - reactos/lib/crt/mbstring/mbslwr.c | 45 - reactos/lib/crt/mbstring/mbsncat.c | 64 - reactos/lib/crt/mbstring/mbsnccnt.c | 35 - reactos/lib/crt/mbstring/mbsncmp.c | 109 -- reactos/lib/crt/mbstring/mbsncoll.c | 115 -- reactos/lib/crt/mbstring/mbsncpy.c | 91 -- reactos/lib/crt/mbstring/mbsnextc.c | 20 - reactos/lib/crt/mbstring/mbsnicmp.c | 47 - reactos/lib/crt/mbstring/mbsnicoll.c | 17 - reactos/lib/crt/mbstring/mbsninc.c | 16 - reactos/lib/crt/mbstring/mbsnset.c | 70 - reactos/lib/crt/mbstring/mbspbrk.c | 26 - reactos/lib/crt/mbstring/mbsrchr.c | 33 - reactos/lib/crt/mbstring/mbsrev.c | 33 - reactos/lib/crt/mbstring/mbsset.c | 40 - reactos/lib/crt/mbstring/mbsspn.c | 20 - reactos/lib/crt/mbstring/mbsspnp.c | 19 - reactos/lib/crt/mbstring/mbsstr.c | 23 - reactos/lib/crt/mbstring/mbstok.c | 57 - reactos/lib/crt/mbstring/mbstrlen.c | 19 - reactos/lib/crt/mbstring/mbsupr.c | 56 - reactos/lib/crt/misc/amsg.c | 52 - reactos/lib/crt/misc/assert.c | 17 - reactos/lib/crt/misc/crtmain.c | 92 -- reactos/lib/crt/misc/environ.c | 471 ------ reactos/lib/crt/misc/getargs.c | 350 ---- reactos/lib/crt/misc/initterm.c | 20 - reactos/lib/crt/misc/lock.c | 135 -- reactos/lib/crt/misc/purecall.c | 10 - reactos/lib/crt/misc/stubs.c | 144 -- reactos/lib/crt/misc/tls.c | 102 -- reactos/lib/crt/precomp.h | 42 - reactos/lib/crt/process/_cwait.c | 32 - reactos/lib/crt/process/_system.c | 114 -- reactos/lib/crt/process/dll.c | 39 - reactos/lib/crt/process/process.c | 648 -------- reactos/lib/crt/process/procid.c | 11 - reactos/lib/crt/process/thread.c | 23 - reactos/lib/crt/process/threadid.c | 19 - reactos/lib/crt/process/threadx.c | 44 - reactos/lib/crt/process/wprocess.c | 4 - reactos/lib/crt/search/lfind.c | 21 - reactos/lib/crt/search/lsearch.c | 21 - reactos/lib/crt/setjmp/i386/setjmp.s | 111 -- reactos/lib/crt/signal/signal.c | 144 -- reactos/lib/crt/signal/xcptinfo.c | 9 - reactos/lib/crt/stdio/allocfil.c | 95 -- reactos/lib/crt/stdio/clearerr.c | 20 - reactos/lib/crt/stdio/fclose.c | 49 - reactos/lib/crt/stdio/fdopen.c | 55 - reactos/lib/crt/stdio/feof.c | 20 - reactos/lib/crt/stdio/ferror.c | 17 - reactos/lib/crt/stdio/fflush.c | 112 -- reactos/lib/crt/stdio/fgetc.c | 28 - reactos/lib/crt/stdio/fgetchar.c | 37 - reactos/lib/crt/stdio/fgetpos.c | 16 - reactos/lib/crt/stdio/fgets.c | 44 - reactos/lib/crt/stdio/fgetws.c | 50 - reactos/lib/crt/stdio/filbuf.c | 117 -- reactos/lib/crt/stdio/fileno.c | 21 - reactos/lib/crt/stdio/flsbuf.c | 153 -- reactos/lib/crt/stdio/fopen.c | 91 -- reactos/lib/crt/stdio/fprintf.c | 34 - reactos/lib/crt/stdio/fputc.c | 24 - reactos/lib/crt/stdio/fputchar.c | 38 - reactos/lib/crt/stdio/fputs.c | 61 - reactos/lib/crt/stdio/fputws.c | 5 - reactos/lib/crt/stdio/fread.c | 88 - reactos/lib/crt/stdio/freopen.c | 66 - reactos/lib/crt/stdio/fseek.c | 52 - reactos/lib/crt/stdio/fsetpos.c | 16 - reactos/lib/crt/stdio/fsopen.c | 99 -- reactos/lib/crt/stdio/ftell.c | 43 - reactos/lib/crt/stdio/fwalk.c | 16 - reactos/lib/crt/stdio/fwprintf.c | 4 - reactos/lib/crt/stdio/fwrite.c | 111 -- reactos/lib/crt/stdio/getc.c | 130 -- reactos/lib/crt/stdio/getchar.c | 44 - reactos/lib/crt/stdio/gets.c | 144 -- reactos/lib/crt/stdio/getw.c | 38 - reactos/lib/crt/stdio/perror.c | 23 - reactos/lib/crt/stdio/popen.c | 134 -- reactos/lib/crt/stdio/printf.c | 36 - reactos/lib/crt/stdio/putc.c | 142 -- reactos/lib/crt/stdio/putchar.c | 30 - reactos/lib/crt/stdio/puts.c | 32 - reactos/lib/crt/stdio/putw.c | 32 - reactos/lib/crt/stdio/putwchar.c | 4 - reactos/lib/crt/stdio/remove.c | 19 - reactos/lib/crt/stdio/rename.c | 26 - reactos/lib/crt/stdio/rewind.c | 14 - reactos/lib/crt/stdio/rmtmp.c | 53 - reactos/lib/crt/stdio/setbuf.c | 13 - reactos/lib/crt/stdio/setvbuf.c | 64 - reactos/lib/crt/stdio/sprintf.c | 61 - reactos/lib/crt/stdio/stdhnd.c | 32 - reactos/lib/crt/stdio/swprintf.c | 57 - reactos/lib/crt/stdio/tempnam.c | 28 - reactos/lib/crt/stdio/tmpfile.c | 62 - reactos/lib/crt/stdio/tmpnam.c | 17 - reactos/lib/crt/stdio/ungetc.c | 35 - reactos/lib/crt/stdio/ungetwc.c | 4 - reactos/lib/crt/stdio/vfprintf.c | 874 ---------- reactos/lib/crt/stdio/vfwprint.c | 846 ---------- reactos/lib/crt/stdio/vprintf.c | 58 - reactos/lib/crt/stdio/vsprintf.c | 42 - reactos/lib/crt/stdio/vswprintf.c | 4 - reactos/lib/crt/stdio/vwprintf.c | 5 - reactos/lib/crt/stdio/wfdopen.c | 7 - reactos/lib/crt/stdio/wfopen.c | 4 - 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 | 6 - reactos/lib/crt/stdio/wtempnam.c | 6 - reactos/lib/crt/stdio/wtmpnam.c | 5 - reactos/lib/crt/stdlib/_exit.c | 49 - reactos/lib/crt/stdlib/abort.c | 27 - reactos/lib/crt/stdlib/abs.c | 11 - reactos/lib/crt/stdlib/atexit.c | 69 - reactos/lib/crt/stdlib/atof.c | 11 - reactos/lib/crt/stdlib/atoi.c | 11 - reactos/lib/crt/stdlib/atoi64.c | 42 - reactos/lib/crt/stdlib/atol.c | 12 - reactos/lib/crt/stdlib/atold.c | 8 - reactos/lib/crt/stdlib/bsearch.c | 28 - reactos/lib/crt/stdlib/div.c | 27 - reactos/lib/crt/stdlib/doserrmap.h | 82 - reactos/lib/crt/stdlib/ecvt.c | 14 - reactos/lib/crt/stdlib/ecvtbuf.c | 108 -- reactos/lib/crt/stdlib/errno.c | 74 - reactos/lib/crt/stdlib/fcvt.c | 14 - reactos/lib/crt/stdlib/fcvtbuf.c | 127 -- reactos/lib/crt/stdlib/fullpath.c | 33 - reactos/lib/crt/stdlib/gcvt.c | 32 - reactos/lib/crt/stdlib/getenv.c | 52 - reactos/lib/crt/stdlib/itoa.c | 135 -- reactos/lib/crt/stdlib/itow.c | 96 -- reactos/lib/crt/stdlib/labs.c | 11 - reactos/lib/crt/stdlib/ldiv.c | 28 - reactos/lib/crt/stdlib/makepath.c | 37 - reactos/lib/crt/stdlib/malloc.c | 151 -- reactos/lib/crt/stdlib/mbstowcs.c | 120 -- reactos/lib/crt/stdlib/mbtowc.c | 62 - reactos/lib/crt/stdlib/obsol.c | 33 - reactos/lib/crt/stdlib/putenv.c | 34 - reactos/lib/crt/stdlib/qsort.c | 241 --- reactos/lib/crt/stdlib/rand.c | 27 - reactos/lib/crt/stdlib/rot.c | 68 - reactos/lib/crt/stdlib/senv.c | 47 - reactos/lib/crt/stdlib/splitp.c | 68 - reactos/lib/crt/stdlib/strtod.c | 103 -- reactos/lib/crt/stdlib/strtol.c | 90 -- reactos/lib/crt/stdlib/strtold.c | 125 -- reactos/lib/crt/stdlib/strtoul.c | 74 - reactos/lib/crt/stdlib/strtoull.c | 76 - reactos/lib/crt/stdlib/swab.c | 34 - reactos/lib/crt/stdlib/wcstod.c | 98 -- reactos/lib/crt/stdlib/wcstol.c | 45 - reactos/lib/crt/stdlib/wcstom.c | 20 - reactos/lib/crt/stdlib/wcstomb.c | 114 -- reactos/lib/crt/stdlib/wcstombs.c | 157 -- reactos/lib/crt/stdlib/wcstoul.c | 100 -- reactos/lib/crt/stdlib/wctomb.c | 145 -- reactos/lib/crt/stdlib/wfulpath.c | 5 - reactos/lib/crt/stdlib/witoa.c | 81 - reactos/lib/crt/stdlib/witow.c | 93 -- reactos/lib/crt/stdlib/wmakpath.c | 45 - reactos/lib/crt/stdlib/wputenv.c | 15 - reactos/lib/crt/stdlib/wsenv.c | 5 - reactos/lib/crt/stdlib/wsplitp.c | 7 - reactos/lib/crt/stdlib/wtoi.c | 6 - reactos/lib/crt/stdlib/wtoi64.c | 39 - reactos/lib/crt/stdlib/wtol.c | 6 - reactos/lib/crt/string/lasttok.c | 26 - reactos/lib/crt/string/memicmp.c | 22 - reactos/lib/crt/string/strcoll.c | 45 - reactos/lib/crt/string/strdup.c | 17 - reactos/lib/crt/string/strerror.c | 111 -- reactos/lib/crt/string/stricmp.c | 27 - reactos/lib/crt/string/strlwr.c | 25 - reactos/lib/crt/string/strncoll.c | 23 - reactos/lib/crt/string/strnicmp.c | 19 - reactos/lib/crt/string/strrev.c | 32 - reactos/lib/crt/string/strset.c | 43 - reactos/lib/crt/string/strstr.c | 35 - reactos/lib/crt/string/strtok.c | 62 - reactos/lib/crt/string/strupr.c | 25 - reactos/lib/crt/string/strxfrm.c | 33 - reactos/lib/crt/sys_stat/fstat.c | 79 - reactos/lib/crt/sys_stat/fstati64.c | 80 - reactos/lib/crt/sys_stat/futime.c | 47 - reactos/lib/crt/sys_stat/stat.c | 120 -- reactos/lib/crt/sys_stat/systime.c | 78 - reactos/lib/crt/sys_stat/wstat.c | 119 -- reactos/lib/crt/time/clock.c | 28 - reactos/lib/crt/time/ctime.c | 1438 ----------------- reactos/lib/crt/time/difftime.c | 11 - reactos/lib/crt/time/ftime.c | 33 - reactos/lib/crt/time/posixrul.h | 49 - reactos/lib/crt/time/strdate.c | 29 - reactos/lib/crt/time/strftime.c | 260 --- reactos/lib/crt/time/strtime.c | 29 - reactos/lib/crt/time/time.c | 222 --- reactos/lib/crt/time/tz_vars.c | 35 - reactos/lib/crt/time/tzfile.h | 160 -- reactos/lib/crt/time/wctime.c | 72 - reactos/lib/crt/time/wstrdate.c | 29 - reactos/lib/crt/time/wstrtime.c | 29 - reactos/lib/crt/wine/cpp.c | 1250 -------------- reactos/lib/crt/wine/cppexcept.c | 442 ----- reactos/lib/crt/wine/heap.c | 130 -- reactos/lib/crt/wine/scanf.c | 191 --- reactos/lib/crt/wine/scanf.h | 560 ------- reactos/lib/crt/wine/thread.c | 108 -- reactos/lib/crt/wine/undname.c | 1219 -------------- reactos/lib/crt/wstring/wcscoll.c | 47 - reactos/lib/crt/wstring/wcscspn.c | 33 - reactos/lib/crt/wstring/wcsdup.c | 27 - reactos/lib/crt/wstring/wcsicmp.c | 18 - reactos/lib/crt/wstring/wcslwr.c | 25 - reactos/lib/crt/wstring/wcsnicmp.c | 27 - reactos/lib/crt/wstring/wcspbrk.c | 29 - reactos/lib/crt/wstring/wcsrev.c | 31 - reactos/lib/crt/wstring/wcsset.c | 43 - reactos/lib/crt/wstring/wcsspn.c | 33 - reactos/lib/crt/wstring/wcsstr.c | 36 - reactos/lib/crt/wstring/wcstok.c | 71 - reactos/lib/crt/wstring/wcsupr.c | 25 - reactos/lib/crt/wstring/wcsxfrm.c | 36 - reactos/lib/crt/wstring/wlasttok.c | 26 - 386 files changed, 27521 deletions(-) delete mode 100644 reactos/lib/crt/README.txt delete mode 100644 reactos/lib/crt/conio/cgets.c delete mode 100644 reactos/lib/crt/conio/cprintf.c delete mode 100644 reactos/lib/crt/conio/cputs.c delete mode 100644 reactos/lib/crt/conio/getch.c delete mode 100644 reactos/lib/crt/conio/getche.c delete mode 100644 reactos/lib/crt/conio/kbhit.c delete mode 100644 reactos/lib/crt/conio/putch.c delete mode 100644 reactos/lib/crt/conio/ungetch.c delete mode 100644 reactos/lib/crt/crt.rbuild delete mode 100644 reactos/lib/crt/direct/chdir.c delete mode 100644 reactos/lib/crt/direct/chdrive.c delete mode 100644 reactos/lib/crt/direct/getcwd.c delete mode 100644 reactos/lib/crt/direct/getdcwd.c delete mode 100644 reactos/lib/crt/direct/getdfree.c delete mode 100644 reactos/lib/crt/direct/getdrive.c delete mode 100644 reactos/lib/crt/direct/mkdir.c delete mode 100644 reactos/lib/crt/direct/rmdir.c delete mode 100644 reactos/lib/crt/direct/wchdir.c delete mode 100644 reactos/lib/crt/direct/wgetcwd.c delete mode 100644 reactos/lib/crt/direct/wgetdcwd.c delete mode 100644 reactos/lib/crt/direct/wmkdir.c delete mode 100644 reactos/lib/crt/direct/wrmdir.c delete mode 100644 reactos/lib/crt/except/abnorter.c delete mode 100644 reactos/lib/crt/except/exhand2.c delete mode 100755 reactos/lib/crt/except/i386/seh.s delete mode 100644 reactos/lib/crt/except/i386/unwind.c delete mode 100644 reactos/lib/crt/except/matherr.c delete mode 100644 reactos/lib/crt/except/xcptfil.c delete mode 100644 reactos/lib/crt/float/chgsign.c delete mode 100644 reactos/lib/crt/float/copysign.c delete mode 100644 reactos/lib/crt/float/fpclass.c delete mode 100644 reactos/lib/crt/float/fpecode.c delete mode 100644 reactos/lib/crt/float/fpreset.c delete mode 100644 reactos/lib/crt/float/i386/clearfp.c delete mode 100644 reactos/lib/crt/float/i386/cntrlfp.c delete mode 100644 reactos/lib/crt/float/i386/logb.c delete mode 100644 reactos/lib/crt/float/i386/statfp.c delete mode 100644 reactos/lib/crt/float/isnan.c delete mode 100644 reactos/lib/crt/float/nafter.c delete mode 100644 reactos/lib/crt/float/scalb.c delete mode 100644 reactos/lib/crt/include/float.h delete mode 100644 reactos/lib/crt/include/internal/atexit.h delete mode 100644 reactos/lib/crt/include/internal/console.h delete mode 100644 reactos/lib/crt/include/internal/debug.h delete mode 100644 reactos/lib/crt/include/internal/file.h delete mode 100644 reactos/lib/crt/include/internal/ieee.h delete mode 100644 reactos/lib/crt/include/internal/math.h delete mode 100644 reactos/lib/crt/include/internal/mbstring.h delete mode 100644 reactos/lib/crt/include/internal/mtdll.h delete mode 100644 reactos/lib/crt/include/internal/rterror.h delete mode 100644 reactos/lib/crt/include/internal/tls.h delete mode 100644 reactos/lib/crt/include/internal/wine/cppexcept.h delete mode 100644 reactos/lib/crt/include/internal/wine/eh.h delete mode 100644 reactos/lib/crt/include/internal/wine/msvcrt.h delete mode 100644 reactos/lib/crt/io/access.c delete mode 100644 reactos/lib/crt/io/chmod.c delete mode 100644 reactos/lib/crt/io/chsize.c delete mode 100644 reactos/lib/crt/io/close.c delete mode 100644 reactos/lib/crt/io/commit.c delete mode 100644 reactos/lib/crt/io/create.c delete mode 100644 reactos/lib/crt/io/dup.c delete mode 100644 reactos/lib/crt/io/dup2.c delete mode 100644 reactos/lib/crt/io/eof.c delete mode 100644 reactos/lib/crt/io/filelen.c delete mode 100644 reactos/lib/crt/io/fileleni.c delete mode 100644 reactos/lib/crt/io/find.c delete mode 100644 reactos/lib/crt/io/fmode.c delete mode 100644 reactos/lib/crt/io/isatty.c delete mode 100644 reactos/lib/crt/io/locking.c delete mode 100644 reactos/lib/crt/io/lseek.c delete mode 100644 reactos/lib/crt/io/lseeki64.c delete mode 100644 reactos/lib/crt/io/mktemp.c delete mode 100644 reactos/lib/crt/io/open.c delete mode 100644 reactos/lib/crt/io/pipe.c delete mode 100644 reactos/lib/crt/io/read.c delete mode 100644 reactos/lib/crt/io/setmode.c delete mode 100644 reactos/lib/crt/io/sopen.c delete mode 100644 reactos/lib/crt/io/stubs.c delete mode 100644 reactos/lib/crt/io/tell.c delete mode 100644 reactos/lib/crt/io/telli64.c delete mode 100644 reactos/lib/crt/io/umask.c delete mode 100644 reactos/lib/crt/io/unlink.c delete mode 100644 reactos/lib/crt/io/utime.c delete mode 100644 reactos/lib/crt/io/waccess.c delete mode 100644 reactos/lib/crt/io/wchmod.c delete mode 100644 reactos/lib/crt/io/wcreate.c delete mode 100644 reactos/lib/crt/io/wfind.c delete mode 100644 reactos/lib/crt/io/wmktemp.c delete mode 100644 reactos/lib/crt/io/wopen.c delete mode 100644 reactos/lib/crt/io/write.c delete mode 100644 reactos/lib/crt/io/wunlink.c delete mode 100644 reactos/lib/crt/io/wutime.c delete mode 100644 reactos/lib/crt/locale/locale.c delete mode 100644 reactos/lib/crt/math/acos.c delete mode 100644 reactos/lib/crt/math/adjust.c delete mode 100644 reactos/lib/crt/math/asin.c delete mode 100644 reactos/lib/crt/math/cabs.c delete mode 100644 reactos/lib/crt/math/cosh.c delete mode 100644 reactos/lib/crt/math/frexp.c delete mode 100644 reactos/lib/crt/math/huge_val.c delete mode 100644 reactos/lib/crt/math/hypot.c delete mode 100644 reactos/lib/crt/math/i386/.gitignore delete mode 100644 reactos/lib/crt/math/i386/atan2.c delete mode 100644 reactos/lib/crt/math/i386/atan_asm.s delete mode 100644 reactos/lib/crt/math/i386/exp.c delete mode 100644 reactos/lib/crt/math/i386/fmod.c delete mode 100644 reactos/lib/crt/math/i386/ldexp.c delete mode 100644 reactos/lib/crt/math/i386/log10_asm.s delete mode 100644 reactos/lib/crt/math/i386/pow_asm.s delete mode 100644 reactos/lib/crt/math/j0_y0.c delete mode 100644 reactos/lib/crt/math/j1_y1.c delete mode 100644 reactos/lib/crt/math/jn_yn.c delete mode 100644 reactos/lib/crt/math/modf.c delete mode 100644 reactos/lib/crt/math/pow_asm.c delete mode 100644 reactos/lib/crt/math/s_modf.c delete mode 100644 reactos/lib/crt/math/sinh.c delete mode 100644 reactos/lib/crt/math/stubs.c delete mode 100644 reactos/lib/crt/math/tanh.c delete mode 100644 reactos/lib/crt/mbstring/hanzen.c delete mode 100644 reactos/lib/crt/mbstring/ischira.c delete mode 100644 reactos/lib/crt/mbstring/iskana.c delete mode 100644 reactos/lib/crt/mbstring/iskmoji.c delete mode 100644 reactos/lib/crt/mbstring/iskpun.c delete mode 100644 reactos/lib/crt/mbstring/islead.c delete mode 100644 reactos/lib/crt/mbstring/islwr.c delete mode 100644 reactos/lib/crt/mbstring/ismbal.c delete mode 100644 reactos/lib/crt/mbstring/ismbaln.c delete mode 100644 reactos/lib/crt/mbstring/ismbc.c delete mode 100644 reactos/lib/crt/mbstring/ismbgra.c delete mode 100644 reactos/lib/crt/mbstring/ismbkaln.c delete mode 100644 reactos/lib/crt/mbstring/ismblead.c delete mode 100644 reactos/lib/crt/mbstring/ismbpri.c delete mode 100644 reactos/lib/crt/mbstring/ismbpun.c delete mode 100644 reactos/lib/crt/mbstring/ismbtrl.c delete mode 100644 reactos/lib/crt/mbstring/isuppr.c delete mode 100644 reactos/lib/crt/mbstring/jistojms.c delete mode 100644 reactos/lib/crt/mbstring/jmstojis.c delete mode 100644 reactos/lib/crt/mbstring/mbbtype.c delete mode 100644 reactos/lib/crt/mbstring/mbccpy.c delete mode 100644 reactos/lib/crt/mbstring/mbclen.c delete mode 100644 reactos/lib/crt/mbstring/mbscat.c delete mode 100644 reactos/lib/crt/mbstring/mbschr.c delete mode 100644 reactos/lib/crt/mbstring/mbscmp.c delete mode 100644 reactos/lib/crt/mbstring/mbscoll.c delete mode 100644 reactos/lib/crt/mbstring/mbscpy.c delete mode 100644 reactos/lib/crt/mbstring/mbscspn.c delete mode 100644 reactos/lib/crt/mbstring/mbsdec.c delete mode 100644 reactos/lib/crt/mbstring/mbsdup.c delete mode 100644 reactos/lib/crt/mbstring/mbsicmp.c delete mode 100644 reactos/lib/crt/mbstring/mbsicoll.c delete mode 100644 reactos/lib/crt/mbstring/mbsinc.c delete mode 100644 reactos/lib/crt/mbstring/mbslen.c delete mode 100644 reactos/lib/crt/mbstring/mbslwr.c delete mode 100644 reactos/lib/crt/mbstring/mbsncat.c delete mode 100644 reactos/lib/crt/mbstring/mbsnccnt.c delete mode 100644 reactos/lib/crt/mbstring/mbsncmp.c delete mode 100644 reactos/lib/crt/mbstring/mbsncoll.c delete mode 100644 reactos/lib/crt/mbstring/mbsncpy.c delete mode 100644 reactos/lib/crt/mbstring/mbsnextc.c delete mode 100644 reactos/lib/crt/mbstring/mbsnicmp.c delete mode 100644 reactos/lib/crt/mbstring/mbsnicoll.c delete mode 100644 reactos/lib/crt/mbstring/mbsninc.c delete mode 100644 reactos/lib/crt/mbstring/mbsnset.c delete mode 100644 reactos/lib/crt/mbstring/mbspbrk.c delete mode 100644 reactos/lib/crt/mbstring/mbsrchr.c delete mode 100644 reactos/lib/crt/mbstring/mbsrev.c delete mode 100644 reactos/lib/crt/mbstring/mbsset.c delete mode 100644 reactos/lib/crt/mbstring/mbsspn.c delete mode 100644 reactos/lib/crt/mbstring/mbsspnp.c delete mode 100644 reactos/lib/crt/mbstring/mbsstr.c delete mode 100644 reactos/lib/crt/mbstring/mbstok.c delete mode 100644 reactos/lib/crt/mbstring/mbstrlen.c delete mode 100644 reactos/lib/crt/mbstring/mbsupr.c delete mode 100644 reactos/lib/crt/misc/amsg.c delete mode 100644 reactos/lib/crt/misc/assert.c delete mode 100644 reactos/lib/crt/misc/crtmain.c delete mode 100644 reactos/lib/crt/misc/environ.c delete mode 100644 reactos/lib/crt/misc/getargs.c delete mode 100644 reactos/lib/crt/misc/initterm.c delete mode 100644 reactos/lib/crt/misc/lock.c delete mode 100644 reactos/lib/crt/misc/purecall.c delete mode 100644 reactos/lib/crt/misc/stubs.c delete mode 100644 reactos/lib/crt/misc/tls.c delete mode 100644 reactos/lib/crt/precomp.h delete mode 100644 reactos/lib/crt/process/_cwait.c delete mode 100644 reactos/lib/crt/process/_system.c delete mode 100644 reactos/lib/crt/process/dll.c delete mode 100644 reactos/lib/crt/process/process.c delete mode 100644 reactos/lib/crt/process/procid.c delete mode 100644 reactos/lib/crt/process/thread.c delete mode 100644 reactos/lib/crt/process/threadid.c delete mode 100644 reactos/lib/crt/process/threadx.c delete mode 100644 reactos/lib/crt/process/wprocess.c delete mode 100644 reactos/lib/crt/search/lfind.c delete mode 100644 reactos/lib/crt/search/lsearch.c delete mode 100644 reactos/lib/crt/setjmp/i386/setjmp.s delete mode 100644 reactos/lib/crt/signal/signal.c delete mode 100644 reactos/lib/crt/signal/xcptinfo.c delete mode 100644 reactos/lib/crt/stdio/allocfil.c delete mode 100644 reactos/lib/crt/stdio/clearerr.c delete mode 100644 reactos/lib/crt/stdio/fclose.c delete mode 100644 reactos/lib/crt/stdio/fdopen.c delete mode 100644 reactos/lib/crt/stdio/feof.c delete mode 100644 reactos/lib/crt/stdio/ferror.c delete mode 100644 reactos/lib/crt/stdio/fflush.c delete mode 100644 reactos/lib/crt/stdio/fgetc.c delete mode 100644 reactos/lib/crt/stdio/fgetchar.c delete mode 100644 reactos/lib/crt/stdio/fgetpos.c delete mode 100644 reactos/lib/crt/stdio/fgets.c delete mode 100644 reactos/lib/crt/stdio/fgetws.c delete mode 100644 reactos/lib/crt/stdio/filbuf.c delete mode 100644 reactos/lib/crt/stdio/fileno.c delete mode 100644 reactos/lib/crt/stdio/flsbuf.c delete mode 100644 reactos/lib/crt/stdio/fopen.c delete mode 100644 reactos/lib/crt/stdio/fprintf.c delete mode 100644 reactos/lib/crt/stdio/fputc.c delete mode 100644 reactos/lib/crt/stdio/fputchar.c delete mode 100644 reactos/lib/crt/stdio/fputs.c delete mode 100644 reactos/lib/crt/stdio/fputws.c delete mode 100644 reactos/lib/crt/stdio/fread.c delete mode 100644 reactos/lib/crt/stdio/freopen.c delete mode 100644 reactos/lib/crt/stdio/fseek.c delete mode 100644 reactos/lib/crt/stdio/fsetpos.c delete mode 100644 reactos/lib/crt/stdio/fsopen.c delete mode 100644 reactos/lib/crt/stdio/ftell.c delete mode 100644 reactos/lib/crt/stdio/fwalk.c delete mode 100644 reactos/lib/crt/stdio/fwprintf.c delete mode 100644 reactos/lib/crt/stdio/fwrite.c delete mode 100644 reactos/lib/crt/stdio/getc.c delete mode 100644 reactos/lib/crt/stdio/getchar.c delete mode 100644 reactos/lib/crt/stdio/gets.c delete mode 100644 reactos/lib/crt/stdio/getw.c delete mode 100644 reactos/lib/crt/stdio/perror.c delete mode 100644 reactos/lib/crt/stdio/popen.c delete mode 100644 reactos/lib/crt/stdio/printf.c delete mode 100644 reactos/lib/crt/stdio/putc.c delete mode 100644 reactos/lib/crt/stdio/putchar.c delete mode 100644 reactos/lib/crt/stdio/puts.c delete mode 100644 reactos/lib/crt/stdio/putw.c delete mode 100644 reactos/lib/crt/stdio/putwchar.c delete mode 100644 reactos/lib/crt/stdio/remove.c delete mode 100644 reactos/lib/crt/stdio/rename.c delete mode 100644 reactos/lib/crt/stdio/rewind.c delete mode 100644 reactos/lib/crt/stdio/rmtmp.c delete mode 100644 reactos/lib/crt/stdio/setbuf.c delete mode 100644 reactos/lib/crt/stdio/setvbuf.c delete mode 100644 reactos/lib/crt/stdio/sprintf.c delete mode 100644 reactos/lib/crt/stdio/stdhnd.c delete mode 100644 reactos/lib/crt/stdio/swprintf.c delete mode 100644 reactos/lib/crt/stdio/tempnam.c delete mode 100644 reactos/lib/crt/stdio/tmpfile.c delete mode 100644 reactos/lib/crt/stdio/tmpnam.c delete mode 100644 reactos/lib/crt/stdio/ungetc.c delete mode 100644 reactos/lib/crt/stdio/ungetwc.c delete mode 100644 reactos/lib/crt/stdio/vfprintf.c delete mode 100644 reactos/lib/crt/stdio/vfwprint.c delete mode 100644 reactos/lib/crt/stdio/vprintf.c delete mode 100644 reactos/lib/crt/stdio/vsprintf.c delete mode 100644 reactos/lib/crt/stdio/vswprintf.c delete mode 100644 reactos/lib/crt/stdio/vwprintf.c delete mode 100644 reactos/lib/crt/stdio/wfdopen.c delete mode 100644 reactos/lib/crt/stdio/wfopen.c delete mode 100644 reactos/lib/crt/stdio/wfreopen.c delete mode 100644 reactos/lib/crt/stdio/wfsopen.c delete mode 100644 reactos/lib/crt/stdio/wpopen.c delete mode 100644 reactos/lib/crt/stdio/wprintf.c delete mode 100644 reactos/lib/crt/stdio/wremove.c delete mode 100644 reactos/lib/crt/stdio/wrename.c delete mode 100644 reactos/lib/crt/stdio/wtempnam.c delete mode 100644 reactos/lib/crt/stdio/wtmpnam.c delete mode 100644 reactos/lib/crt/stdlib/_exit.c delete mode 100644 reactos/lib/crt/stdlib/abort.c delete mode 100644 reactos/lib/crt/stdlib/abs.c delete mode 100644 reactos/lib/crt/stdlib/atexit.c delete mode 100644 reactos/lib/crt/stdlib/atof.c delete mode 100644 reactos/lib/crt/stdlib/atoi.c delete mode 100644 reactos/lib/crt/stdlib/atoi64.c delete mode 100644 reactos/lib/crt/stdlib/atol.c delete mode 100644 reactos/lib/crt/stdlib/atold.c delete mode 100644 reactos/lib/crt/stdlib/bsearch.c delete mode 100644 reactos/lib/crt/stdlib/div.c delete mode 100644 reactos/lib/crt/stdlib/doserrmap.h delete mode 100644 reactos/lib/crt/stdlib/ecvt.c delete mode 100644 reactos/lib/crt/stdlib/ecvtbuf.c delete mode 100644 reactos/lib/crt/stdlib/errno.c delete mode 100644 reactos/lib/crt/stdlib/fcvt.c delete mode 100644 reactos/lib/crt/stdlib/fcvtbuf.c delete mode 100644 reactos/lib/crt/stdlib/fullpath.c delete mode 100644 reactos/lib/crt/stdlib/gcvt.c delete mode 100644 reactos/lib/crt/stdlib/getenv.c delete mode 100644 reactos/lib/crt/stdlib/itoa.c delete mode 100644 reactos/lib/crt/stdlib/itow.c delete mode 100644 reactos/lib/crt/stdlib/labs.c delete mode 100644 reactos/lib/crt/stdlib/ldiv.c delete mode 100644 reactos/lib/crt/stdlib/makepath.c delete mode 100644 reactos/lib/crt/stdlib/malloc.c delete mode 100644 reactos/lib/crt/stdlib/mbstowcs.c delete mode 100644 reactos/lib/crt/stdlib/mbtowc.c delete mode 100644 reactos/lib/crt/stdlib/obsol.c delete mode 100644 reactos/lib/crt/stdlib/putenv.c delete mode 100644 reactos/lib/crt/stdlib/qsort.c delete mode 100644 reactos/lib/crt/stdlib/rand.c delete mode 100644 reactos/lib/crt/stdlib/rot.c delete mode 100644 reactos/lib/crt/stdlib/senv.c delete mode 100644 reactos/lib/crt/stdlib/splitp.c delete mode 100644 reactos/lib/crt/stdlib/strtod.c delete mode 100644 reactos/lib/crt/stdlib/strtol.c delete mode 100644 reactos/lib/crt/stdlib/strtold.c delete mode 100644 reactos/lib/crt/stdlib/strtoul.c delete mode 100644 reactos/lib/crt/stdlib/strtoull.c delete mode 100644 reactos/lib/crt/stdlib/swab.c delete mode 100644 reactos/lib/crt/stdlib/wcstod.c delete mode 100644 reactos/lib/crt/stdlib/wcstol.c delete mode 100644 reactos/lib/crt/stdlib/wcstom.c delete mode 100644 reactos/lib/crt/stdlib/wcstomb.c delete mode 100644 reactos/lib/crt/stdlib/wcstombs.c delete mode 100644 reactos/lib/crt/stdlib/wcstoul.c delete mode 100644 reactos/lib/crt/stdlib/wctomb.c delete mode 100644 reactos/lib/crt/stdlib/wfulpath.c delete mode 100644 reactos/lib/crt/stdlib/witoa.c delete mode 100644 reactos/lib/crt/stdlib/witow.c delete mode 100644 reactos/lib/crt/stdlib/wmakpath.c delete mode 100644 reactos/lib/crt/stdlib/wputenv.c delete mode 100644 reactos/lib/crt/stdlib/wsenv.c delete mode 100644 reactos/lib/crt/stdlib/wsplitp.c delete mode 100644 reactos/lib/crt/stdlib/wtoi.c delete mode 100644 reactos/lib/crt/stdlib/wtoi64.c delete mode 100644 reactos/lib/crt/stdlib/wtol.c delete mode 100644 reactos/lib/crt/string/lasttok.c delete mode 100644 reactos/lib/crt/string/memicmp.c delete mode 100644 reactos/lib/crt/string/strcoll.c delete mode 100644 reactos/lib/crt/string/strdup.c delete mode 100644 reactos/lib/crt/string/strerror.c delete mode 100644 reactos/lib/crt/string/stricmp.c delete mode 100644 reactos/lib/crt/string/strlwr.c delete mode 100644 reactos/lib/crt/string/strncoll.c delete mode 100644 reactos/lib/crt/string/strnicmp.c delete mode 100644 reactos/lib/crt/string/strrev.c delete mode 100644 reactos/lib/crt/string/strset.c delete mode 100644 reactos/lib/crt/string/strstr.c delete mode 100644 reactos/lib/crt/string/strtok.c delete mode 100644 reactos/lib/crt/string/strupr.c delete mode 100644 reactos/lib/crt/string/strxfrm.c delete mode 100644 reactos/lib/crt/sys_stat/fstat.c delete mode 100644 reactos/lib/crt/sys_stat/fstati64.c delete mode 100644 reactos/lib/crt/sys_stat/futime.c delete mode 100644 reactos/lib/crt/sys_stat/stat.c delete mode 100644 reactos/lib/crt/sys_stat/systime.c delete mode 100644 reactos/lib/crt/sys_stat/wstat.c delete mode 100644 reactos/lib/crt/time/clock.c delete mode 100644 reactos/lib/crt/time/ctime.c delete mode 100644 reactos/lib/crt/time/difftime.c delete mode 100644 reactos/lib/crt/time/ftime.c delete mode 100644 reactos/lib/crt/time/posixrul.h delete mode 100644 reactos/lib/crt/time/strdate.c delete mode 100644 reactos/lib/crt/time/strftime.c delete mode 100644 reactos/lib/crt/time/strtime.c delete mode 100644 reactos/lib/crt/time/time.c delete mode 100644 reactos/lib/crt/time/tz_vars.c delete mode 100644 reactos/lib/crt/time/tzfile.h delete mode 100644 reactos/lib/crt/time/wctime.c delete mode 100644 reactos/lib/crt/time/wstrdate.c delete mode 100644 reactos/lib/crt/time/wstrtime.c delete mode 100644 reactos/lib/crt/wine/cpp.c delete mode 100644 reactos/lib/crt/wine/cppexcept.c delete mode 100644 reactos/lib/crt/wine/heap.c delete mode 100644 reactos/lib/crt/wine/scanf.c delete mode 100644 reactos/lib/crt/wine/scanf.h delete mode 100644 reactos/lib/crt/wine/thread.c delete mode 100755 reactos/lib/crt/wine/undname.c delete mode 100644 reactos/lib/crt/wstring/wcscoll.c delete mode 100644 reactos/lib/crt/wstring/wcscspn.c delete mode 100644 reactos/lib/crt/wstring/wcsdup.c delete mode 100644 reactos/lib/crt/wstring/wcsicmp.c delete mode 100644 reactos/lib/crt/wstring/wcslwr.c delete mode 100644 reactos/lib/crt/wstring/wcsnicmp.c delete mode 100644 reactos/lib/crt/wstring/wcspbrk.c delete mode 100644 reactos/lib/crt/wstring/wcsrev.c delete mode 100644 reactos/lib/crt/wstring/wcsset.c delete mode 100644 reactos/lib/crt/wstring/wcsspn.c delete mode 100644 reactos/lib/crt/wstring/wcsstr.c delete mode 100644 reactos/lib/crt/wstring/wcstok.c delete mode 100644 reactos/lib/crt/wstring/wcsupr.c delete mode 100644 reactos/lib/crt/wstring/wcsxfrm.c delete mode 100644 reactos/lib/crt/wstring/wlasttok.c diff --git a/reactos/lib/crt/README.txt b/reactos/lib/crt/README.txt deleted file mode 100644 index 8853dceee74..00000000000 --- a/reactos/lib/crt/README.txt +++ /dev/null @@ -1,13 +0,0 @@ -This file contains information about the status the MSVCRT runtime in ReactOS. - -Please note that all of the MSVCRT.DLL runtime sources are license GPL unless -otherwise noted. The sources from WINE are dual licensed GPL/LGPL. -If you update a function in the ~/wine directory please send a patch to wine-patches@winehq.com - -TODO List: -Implement the remaining functions that are commented out in the .def file -Update source code headers for the license information. -Compleate the W32API conversion for all source files. -Write a decent regression test suite. -Convert all C++ style comments to C style comments. -???? diff --git a/reactos/lib/crt/conio/cgets.c b/reactos/lib/crt/conio/cgets.c deleted file mode 100644 index a83d0357d46..00000000000 --- a/reactos/lib/crt/conio/cgets.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: msvcrt/conio/cgets.c - * PURPOSE: C Runtime - * PROGRAMMER: Eric Kohl (Imported from DJGPP) - */ - -#include - -/* - * @implemented - */ -char *_cgets(char *string) -{ - unsigned len = 0; - unsigned int maxlen_wanted; - char *sp; - int c; - /* - * Be smart and check for NULL pointer. - * Don't know wether TURBOC does this. - */ - if (!string) - return(NULL); - maxlen_wanted = (unsigned int)((unsigned char)string[0]); - sp = &(string[2]); - /* - * Should the string be shorter maxlen_wanted including or excluding - * the trailing '\0' ? We don't take any risk. - */ - while(len < maxlen_wanted-1) - { - c=_getch(); - /* - * shold we check for backspace here? - * TURBOC does (just checked) but doesn't in cscanf (thats harder - * or even impossible). We do the same. - */ - if (c == '\b') - { - if (len > 0) - { - _cputs("\b \b"); /* go back, clear char on screen with space - and go back again */ - len--; - sp[len] = '\0'; /* clear the character in the string */ - } - } - else if (c == '\r') - { - sp[len] = '\0'; - break; - } - else if (c == 0) - { - /* special character ends input */ - sp[len] = '\0'; - _ungetch(c); /* keep the char for later processing */ - break; - } - else - { - sp[len] = _putch(c); - len++; - } - } - sp[maxlen_wanted-1] = '\0'; - string[1] = (char)((unsigned char)len); - return(sp); -} - - diff --git a/reactos/lib/crt/conio/cprintf.c b/reactos/lib/crt/conio/cprintf.c deleted file mode 100644 index bfee8e02de4..00000000000 --- a/reactos/lib/crt/conio/cprintf.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * COPYRIGHT: Winehq - * PROJECT: wine - * FILE: msvcrt/conio/cprintf.c - * PURPOSE: C Runtime - * PROGRAMMER: Magnus Olsen (Imported from wine cvs 2006-05-23) - */ - -#include - -/* - * @implemented - */ -int -_cprintf(const char *fmt, ...) -{ - char buf[2048], *mem = buf; - int written, resize = sizeof(buf), retval; - va_list valist; - - while ((written = _vsnprintf( mem, resize, fmt, valist )) == -1 || - written > resize) - { - resize = (written == -1 ? resize * 2 : written + 1); - if (mem != buf) - free (mem); - if (!(mem = (char *)malloc(resize))) - return EOF; - va_start( valist, fmt ); - } - va_end(valist); - retval = _cputs( mem ); - if (mem != buf) - free (mem); - return retval; -} diff --git a/reactos/lib/crt/conio/cputs.c b/reactos/lib/crt/conio/cputs.c deleted file mode 100644 index cc34736c2ca..00000000000 --- a/reactos/lib/crt/conio/cputs.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/conio/cputs.c - * PURPOSE: Writes a character to stdout - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -/* - * @implemented - */ -int _cputs(const char *_str) -{ - int len = strlen(_str); - DWORD written = 0; - if (!WriteFile( fdinfo(stdout->_file)->hFile ,_str,len,&written,NULL)) - return -1; - return 0; -} diff --git a/reactos/lib/crt/conio/getch.c b/reactos/lib/crt/conio/getch.c deleted file mode 100644 index aee3cf5a46d..00000000000 --- a/reactos/lib/crt/conio/getch.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/conio/getch.c - * PURPOSE: Writes a character to stdout - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -/* - * @implemented - */ -int _getch(void) -{ - DWORD NumberOfCharsRead = 0; - char c; - HANDLE ConsoleHandle; - BOOL RestoreMode; - DWORD ConsoleMode; - - if (char_avail) { - c = ungot_char; - char_avail = 0; - } else { - /* - * _getch() is documented to NOT echo characters. Testing shows it - * doesn't wait for a CR either. So we need to switch off - * ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT if they're currently - * switched on. - */ - ConsoleHandle = (HANDLE) _get_osfhandle(stdin->_file); - RestoreMode = GetConsoleMode(ConsoleHandle, &ConsoleMode) && - (0 != (ConsoleMode & - (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT))); - if (RestoreMode) { - SetConsoleMode(ConsoleHandle, - ConsoleMode & (~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT))); - } - ReadConsoleA((HANDLE)_get_osfhandle(stdin->_file), - &c, - 1, - &NumberOfCharsRead, - NULL); - if (RestoreMode) { - SetConsoleMode(ConsoleHandle, ConsoleMode); - } - } - if (c == 10) - c = 13; - return c; -} - diff --git a/reactos/lib/crt/conio/getche.c b/reactos/lib/crt/conio/getche.c deleted file mode 100644 index 137c207d50a..00000000000 --- a/reactos/lib/crt/conio/getche.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/conio/getche.c - * PURPOSE: Reads a character from stdin - * PROGRAMER: DJ Delorie - Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -int _getche(void) -{ - if (char_avail) - /* - * We don't know, wether the ungot char was already echoed - * we assume yes (for example in cscanf, probably the only - * place where ungetch is ever called. - * There is no way to check for this really, because - * ungetch could have been called with a character that - * hasn't been got by a conio function. - * We don't echo again. - */ - return(_getch()); - return (_putch(_getch())); -} diff --git a/reactos/lib/crt/conio/kbhit.c b/reactos/lib/crt/conio/kbhit.c deleted file mode 100644 index 60e3e06d8c0..00000000000 --- a/reactos/lib/crt/conio/kbhit.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/conio/kbhit.c - * PURPOSE: Checks for keyboard hits - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -/* - * FIXME PeekConsoleInput returns more than keyboard hits - * - * @unimplemented - */ -int _kbhit(void) -{ - //INPUT_RECORD InputRecord; - DWORD NumberRead=0; - if (char_avail) - return(1); - else { - //FIXME PeekConsoleInput might do DeviceIo - //PeekConsoleInput((HANDLE)stdin->_file,&InputRecord,1,&NumberRead); - return NumberRead; - } - return 0; -} diff --git a/reactos/lib/crt/conio/putch.c b/reactos/lib/crt/conio/putch.c deleted file mode 100644 index 16cf80e2aff..00000000000 --- a/reactos/lib/crt/conio/putch.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/conio/putch.c - * PURPOSE: Writes a character to stdout - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -/* - * @implemented - */ -int _putch(int c) -{ - DWORD NumberOfCharsWritten; - - if (WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL)) { - return -1; - } - return NumberOfCharsWritten; -} diff --git a/reactos/lib/crt/conio/ungetch.c b/reactos/lib/crt/conio/ungetch.c deleted file mode 100644 index 947ad736ae7..00000000000 --- a/reactos/lib/crt/conio/ungetch.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/conio/ungetch.c - * PURPOSE: Ungets a character from stdin - * PROGRAMER: DJ Delorie - Ariadne [ Adapted from djgpp libc ] - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -int char_avail = 0; -int ungot_char = 0; - - -/* - * @implemented - */ -int _ungetch(int c) -{ - if (char_avail) - return(EOF); - ungot_char = c; - char_avail = 1; - return(c); -} diff --git a/reactos/lib/crt/crt.rbuild b/reactos/lib/crt/crt.rbuild deleted file mode 100644 index 55b5d95cd94..00000000000 --- a/reactos/lib/crt/crt.rbuild +++ /dev/null @@ -1,415 +0,0 @@ - - . - include - - extern - - 0x600 - 0x501 - - - - - - precomp.h - - cgets.c - cprintf.c - cputs.c - getch.c - getche.c - kbhit.c - putch.c - ungetch.c - - - chdir.c - chdrive.c - getcwd.c - getdcwd.c - getdfree.c - getdrive.c - mkdir.c - rmdir.c - wchdir.c - wgetcwd.c - wgetdcwd.c - wmkdir.c - wrmdir.c - - - abnorter.c - exhand2.c - matherr.c - - - seh.s - unwind.c - - - xcptfil.c - - - chgsign.c - copysign.c - fpclass.c - fpecode.c - fpreset.c - isnan.c - nafter.c - scalb.c - - - - clearfp.c - cntrlfp.c - logb.c - statfp.c - - - - - access.c - chmod.c - chsize.c - close.c - commit.c - create.c - dup.c - dup2.c - eof.c - filelen.c - fileleni.c - find.c - fmode.c - isatty.c - locking.c - lseek.c - lseeki64.c - mktemp.c - open.c - pipe.c - read.c - setmode.c - sopen.c - stubs.c - tell.c - telli64.c - umask.c - unlink.c - utime.c - waccess.c - wchmod.c - wcreate.c - wfind.c - wmktemp.c - wopen.c - write.c - wunlink.c - wutime.c - - - locale.c - - - acos.c - adjust.c - asin.c - cabs.c - cosh.c - frexp.c - huge_val.c - hypot.c - j0_y0.c - j1_y1.c - jn_yn.c - modf.c - s_modf.c - sinh.c - stubs.c - tanh.c - pow_asm.c - - - - atan2.c - exp.c - fmod.c - ldexp.c - atan_asm.s - pow_asm.s - log10_asm.s - - - - - - - - hanzen.c - ischira.c - iskana.c - iskmoji.c - iskpun.c - islead.c - islwr.c - ismbal.c - ismbaln.c - ismbc.c - ismbgra.c - ismbkaln.c - ismblead.c - ismbpri.c - ismbpun.c - ismbtrl.c - isuppr.c - jistojms.c - jmstojis.c - mbbtype.c - mbccpy.c - mbclen.c - mbscat.c - mbschr.c - mbscmp.c - mbscoll.c - mbscpy.c - mbscspn.c - mbsdec.c - mbsdup.c - mbsicmp.c - mbsicoll.c - mbsinc.c - mbslen.c - mbslwr.c - mbsncat.c - mbsnccnt.c - mbsncmp.c - mbsncoll.c - mbsncpy.c - mbsnextc.c - mbsnicmp.c - mbsnicoll.c - mbsninc.c - mbsnset.c - mbspbrk.c - mbsrchr.c - mbsrev.c - mbsset.c - mbsspn.c - mbsspnp.c - mbsstr.c - mbstok.c - mbstrlen.c - mbsupr.c - - - amsg.c - assert.c - crtmain.c - environ.c - getargs.c - initterm.c - lock.c - purecall.c - stubs.c - tls.c - - - _cwait.c - _system.c - dll.c - process.c - procid.c - thread.c - threadid.c - threadx.c - wprocess.c - - - lfind.c - lsearch.c - - - - - - setjmp.s - - - - - - signal.c - xcptinfo.c - - - allocfil.c - clearerr.c - fclose.c - fdopen.c - feof.c - ferror.c - fflush.c - fgetc.c - fgetchar.c - fgetpos.c - fgets.c - fgetws.c - filbuf.c - fileno.c - flsbuf.c - fopen.c - fprintf.c - fputc.c - fputchar.c - fputs.c - fputws.c - fread.c - freopen.c - fseek.c - fsetpos.c - fsopen.c - ftell.c - fwalk.c - fwprintf.c - fwrite.c - getc.c - getchar.c - gets.c - getw.c - perror.c - popen.c - printf.c - putc.c - putchar.c - puts.c - putw.c - putwchar.c - remove.c - rename.c - rewind.c - rmtmp.c - setbuf.c - setvbuf.c - sprintf.c - swprintf.c - stdhnd.c - tempnam.c - tmpfile.c - tmpnam.c - ungetc.c - ungetwc.c - vfprintf.c - vfwprint.c - vprintf.c - vsprintf.c - vswprintf.c - vwprintf.c - wfdopen.c - wfopen.c - wfreopen.c - wfsopen.c - wpopen.c - wprintf.c - wremove.c - wrename.c - wtempnam.c - wtmpnam.c - - - _exit.c - abort.c - atexit.c - atof.c - div.c - ecvt.c - ecvtbuf.c - errno.c - fcvt.c - fcvtbuf.c - fullpath.c - gcvt.c - getenv.c - ldiv.c - makepath.c - malloc.c - mbtowc.c - obsol.c - putenv.c - rand.c - rot.c - senv.c - strtod.c - strtoul.c - strtoull.c - swab.c - wcstod.c - wcstombs.c - wctomb.c - wfulpath.c - wputenv.c - wsenv.c - wsplitp.c - wmakpath.c - - - lasttok.c - strcoll.c - strdup.c - strerror.c - strncoll.c - strrev.c - strset.c - strstr.c - strtok.c - strupr.c - strxfrm.c - - - fstat.c - fstati64.c - futime.c - stat.c - wstat.c - systime.c - - - clock.c - ctime.c - difftime.c - ftime.c - strdate.c - strftime.c - strtime.c - time.c - tz_vars.c - wctime.c - wstrdate.c - wstrtime.c - - - wcscoll.c - wcscspn.c - wcsdup.c - wcsicmp.c - wcslwr.c - wcsnicmp.c - wcspbrk.c - wcsrev.c - wcsset.c - wcsspn.c - wcsstr.c - wcstok.c - wcsupr.c - wcsxfrm.c - wlasttok.c - - - cpp.c - cppexcept.c - heap.c - scanf.c - thread.c - undname.c - - diff --git a/reactos/lib/crt/direct/chdir.c b/reactos/lib/crt/direct/chdir.c deleted file mode 100644 index d28ce2b0942..00000000000 --- a/reactos/lib/crt/direct/chdir.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include -#include - -/* - * @implemented - */ -int _tchdir(const _TCHAR* _path) -{ - if (!SetCurrentDirectory(_path)) { - _dosmaperr(_path?GetLastError():0); - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/direct/chdrive.c b/reactos/lib/crt/direct/chdrive.c deleted file mode 100644 index 2730a617a45..00000000000 --- a/reactos/lib/crt/direct/chdrive.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - * - * _chdrive (MSVCRT.@) - * - * Change the current drive. - * - * PARAMS - * newdrive [I] Drive number to change to (1 = 'A', 2 = 'B', ...) - * - * RETURNS - * Success: 0. The current drive is set to newdrive. - * Failure: -1. errno indicates the error. - * - * NOTES - * See SetCurrentDirectoryA. - */ -int _chdrive(int newdrive) -{ - WCHAR buffer[] = L"A:"; - - buffer[0] += newdrive - 1; - if (!SetCurrentDirectoryW( buffer )) - { - _dosmaperr(GetLastError()); - if (newdrive <= 0) - { - __set_errno(EACCES); - } - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/direct/getcwd.c b/reactos/lib/crt/direct/getcwd.c deleted file mode 100644 index 8ca4d336cc0..00000000000 --- a/reactos/lib/crt/direct/getcwd.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#include - -/* - * @implemented - */ -_TCHAR* _tgetcwd(_TCHAR* buf, int size) -{ - _TCHAR dir[MAX_PATH]; - DWORD dir_len = GetCurrentDirectory(MAX_PATH,dir); - - if (dir_len == 0) - { - _dosmaperr(GetLastError()); - return NULL; /* FIXME: Real return value untested */ - } - - if (!buf) - { - return _tcsdup(dir); - } - - if (dir_len >= (DWORD)size) - { - __set_errno(ERANGE); - return NULL; /* buf too small */ - } - - _tcscpy(buf,dir); - return buf; -} diff --git a/reactos/lib/crt/direct/getdcwd.c b/reactos/lib/crt/direct/getdcwd.c deleted file mode 100644 index baf6c5d182d..00000000000 --- a/reactos/lib/crt/direct/getdcwd.c +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include -#include - -/* - * @implemented - * - * _getdcwd (MSVCRT.@) - * - * Get the current working directory on a given disk. - * - * PARAMS - * drive [I] Drive letter to get the current working directory from. - * buf [O] Destination for the current working directory. - * size [I] Length of drive in characters. - * - * RETURNS - * Success: If drive is NULL, returns an allocated string containing the path. - * Otherwise populates drive with the path and returns it. - * Failure: NULL. errno indicates the error. - */ -_TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size) -{ - static _TCHAR* dummy; - - TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size); - - if (!drive || drive == _getdrive()) - return _tgetcwd(buf,size); /* current */ - else - { - _TCHAR dir[MAX_PATH]; - _TCHAR drivespec[] = _T("A:"); - int dir_len; - - drivespec[0] += drive - 1; - if (GetDriveType(drivespec) < DRIVE_REMOVABLE) - { - __set_errno(EACCES); - return NULL; - } - - /* GetFullPathName for X: means "get working directory on drive X", - * just like passing X: to SetCurrentDirectory means "switch to working - * directory on drive X". -Gunnar */ - dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy); - if (dir_len >= size || dir_len < 1) - { - __set_errno(ERANGE); - return NULL; /* buf too small */ - } - - TRACE(":returning '%s'\n", dir); - if (!buf) - return _tcsdup(dir); /* allocate */ - - _tcscpy(buf,dir); - } - return buf; -} - diff --git a/reactos/lib/crt/direct/getdfree.c b/reactos/lib/crt/direct/getdfree.c deleted file mode 100644 index 71feaa175b1..00000000000 --- a/reactos/lib/crt/direct/getdfree.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include - - -/* - * @implemented - */ -unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t* _diskspace) -{ - char RootPathName[10]; - - RootPathName[0] = toupper(_drive +'@'); - RootPathName[1] = ':'; - RootPathName[2] = '\\'; - RootPathName[3] = 0; - if (_diskspace == NULL) - return 0; - if (!GetDiskFreeSpaceA(RootPathName,(LPDWORD)&_diskspace->sectors_per_cluster,(LPDWORD)&_diskspace->bytes_per_sector, - (LPDWORD )&_diskspace->avail_clusters,(LPDWORD )&_diskspace->total_clusters)) - return 0; - return _diskspace->avail_clusters; -} diff --git a/reactos/lib/crt/direct/getdrive.c b/reactos/lib/crt/direct/getdrive.c deleted file mode 100644 index de790868d95..00000000000 --- a/reactos/lib/crt/direct/getdrive.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - - -/* - * @implemented - * - * _getdrive (MSVCRT.@) - * - * Get the current drive number. - * - * PARAMS - * None. - * - * RETURNS - * Success: The drive letter number from 1 to 26 ("A:" to "Z:"). - * Failure: 0. - */ -int _getdrive(void) -{ - WCHAR buffer[MAX_PATH]; - if (GetCurrentDirectoryW( MAX_PATH, buffer ) && - buffer[0] >= 'A' && buffer[0] <= 'z' && buffer[1] == ':') - return towupper(buffer[0]) - 'A' + 1; - return 0; -} - -/* - * @implemented - */ -unsigned long _getdrives(void) -{ - return GetLogicalDrives(); -} diff --git a/reactos/lib/crt/direct/mkdir.c b/reactos/lib/crt/direct/mkdir.c deleted file mode 100644 index a8f3ba3d99e..00000000000 --- a/reactos/lib/crt/direct/mkdir.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -int _tmkdir(const _TCHAR* _path) -{ - if (!CreateDirectory(_path, NULL)) { - _dosmaperr(GetLastError()); - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/direct/rmdir.c b/reactos/lib/crt/direct/rmdir.c deleted file mode 100644 index 158111988a3..00000000000 --- a/reactos/lib/crt/direct/rmdir.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -int _trmdir(const _TCHAR* _path) -{ - if (!RemoveDirectory(_path)) { - _dosmaperr(GetLastError()); - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/direct/wchdir.c b/reactos/lib/crt/direct/wchdir.c deleted file mode 100644 index 0271819c709..00000000000 --- a/reactos/lib/crt/direct/wchdir.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "chdir.c" - diff --git a/reactos/lib/crt/direct/wgetcwd.c b/reactos/lib/crt/direct/wgetcwd.c deleted file mode 100644 index 2e946c3fbb5..00000000000 --- a/reactos/lib/crt/direct/wgetcwd.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "getcwd.c" - diff --git a/reactos/lib/crt/direct/wgetdcwd.c b/reactos/lib/crt/direct/wgetdcwd.c deleted file mode 100644 index 3c5e8e28e01..00000000000 --- a/reactos/lib/crt/direct/wgetdcwd.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "getdcwd.c" - diff --git a/reactos/lib/crt/direct/wmkdir.c b/reactos/lib/crt/direct/wmkdir.c deleted file mode 100644 index f9e11d1fe47..00000000000 --- a/reactos/lib/crt/direct/wmkdir.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "mkdir.c" diff --git a/reactos/lib/crt/direct/wrmdir.c b/reactos/lib/crt/direct/wrmdir.c deleted file mode 100644 index b592e542605..00000000000 --- a/reactos/lib/crt/direct/wrmdir.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "rmdir.c" diff --git a/reactos/lib/crt/except/abnorter.c b/reactos/lib/crt/except/abnorter.c deleted file mode 100644 index 8cdf74c6efc..00000000000 --- a/reactos/lib/crt/except/abnorter.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#ifdef __GNUC__ - -/* - * @unimplemented - */ -int _abnormal_termination(void) -{ - printf("Abnormal Termination\n"); -// return AbnormalTermination(); - return 0; -} - -#else -#endif diff --git a/reactos/lib/crt/except/exhand2.c b/reactos/lib/crt/except/exhand2.c deleted file mode 100644 index 963e9730248..00000000000 --- a/reactos/lib/crt/except/exhand2.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -#ifdef __GNUC__ -#else -ULONG DbgPrint(PCH Format,...) -{ - return 0; -} -#endif - -VOID STDCALL -MsvcrtDebug(ULONG Value) -{ - //DbgPrint("MsvcrtDebug 0x%.08x\n", Value); -} - -struct _EXCEPTION_RECORD; -struct _CONTEXT; - -/* - * @implemented - */ -EXCEPTION_DISPOSITION -_except_handler2( -struct _EXCEPTION_RECORD *ExceptionRecord, -void *Frame, -struct _CONTEXT *ContextRecord, -void *DispatcherContext) -{ - //printf("_except_handler2()\n"); - return 0; -} diff --git a/reactos/lib/crt/except/i386/seh.s b/reactos/lib/crt/except/i386/seh.s deleted file mode 100755 index 8a2c984fc09..00000000000 --- a/reactos/lib/crt/except/i386/seh.s +++ /dev/null @@ -1,380 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS MSVCRT Runtime Library - * PURPOSE: Runtime library exception support for IA-32 - * FILE: lib/msvcrt/except/seh.s - * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) - * NOTES: This file is shared with ntoskrnl/rtl/i386/seh.s. - * Please keep them in sync. - */ - -#define ExceptionContinueExecution 0 -#define ExceptionContinueSearch 1 -#define ExceptionNestedException 2 -#define ExceptionCollidedUnwind 3 - -#define EXCEPTION_NONCONTINUABLE 0x01 -#define EXCEPTION_UNWINDING 0x02 -#define EXCEPTION_EXIT_UNWIND 0x04 -#define EXCEPTION_STACK_INVALID 0x08 -#define EXCEPTION_NESTED_CALL 0x10 -#define EXCEPTION_TARGET_UNWIND 0x20 -#define EXCEPTION_COLLIDED_UNWIND 0x40 - -#define EXCEPTION_UNWIND_MODE \ -( EXCEPTION_UNWINDING \ - | EXCEPTION_EXIT_UNWIND \ - | EXCEPTION_TARGET_UNWIND \ - | EXCEPTION_COLLIDED_UNWIND) - -#define EREC_CODE 0x00 -#define EREC_FLAGS 0x04 -#define EREC_RECORD 0x08 -#define EREC_ADDRESS 0x0C -#define EREC_NUMPARAMS 0x10 -#define EREC_INFO 0x14 - -#define TRYLEVEL_NONE -1 -#define TRYLEVEL_INVALID -2 - -#define ER_STANDARDESP -0x08 -#define ER_EPOINTERS -0x04 -#define ER_PREVFRAME 0x00 -#define ER_HANDLER 0x04 -#define ER_SCOPETABLE 0x08 -#define ER_TRYLEVEL 0x0C -#define ER_EBP 0x10 - -#define ST_TRYLEVEL 0x00 -#define ST_FILTER 0x04 -#define ST_HANDLER 0x08 - -#define CONTEXT_EDI 0x9C -#define CONTEXT_EBX 0xA4 -#define CONTEXT_EIP 0xB8 - -.globl __local_unwind2 -.globl __except_handler3 -.globl __EH_prolog - -// EAX = value to print -_do_debug: - pushal - pushl %eax - call _MsvcrtDebug@4 - popal - ret - -#define LU2_TRYLEVEL 0x08 -#define LU2_REGFRAME 0x04 - -// -// void -// _local_unwind2(PEXCEPTION_REGISTRATION RegistrationFrame, -// LONG TryLevel) -// -// Parameters: -// [EDX+08h] - PEXCEPTION_REGISTRATION RegistrationFrame -// [EDX+04h] - LONG TryLevel -// Registers: -// EBP - EBP of call frame we are unwinding -// Returns: -// Nothing -// Notes: -// Run all termination handlers for a call frame from the current -// try-level up to (but not including) the given stop try-level. -__local_unwind2: - // Setup our call frame so we can access parameters using EDX - //pushl %ebp - movl %esp, %edx - - // FIXME: Setup an EXCEPTION_REGISTRATION entry to protect the - // unwinding in case something goes wrong - -.lu2_next_scope: - - // Keep a pointer to the exception registration in EBX - movl LU2_REGFRAME(%edx), %ebx - - // If we have reached the end of the chain or we're asked to stop here - // by the caller then exit - test %ebx, %ebx - je .lu2_done - - movl ER_TRYLEVEL(%ebx), %eax - cmpl $-1, %eax - je .lu2_done - - cmpl LU2_TRYLEVEL(%edx), %eax - je .lu2_done - - // Keep a pointer to the scopetable in ESI - movl ER_SCOPETABLE(%ebx), %esi - - // Compute the offset of the entry in the scopetable that describes - // the scope that is to be unwound. Put the offset in EDI. - movl ST_TRYLEVEL(%esi), %edi - lea (%edi, %edi, 2), %edi - shll $2, %edi - addl %esi, %edi - - // If this is not a termination handler then skip it - cmpl $0, ST_FILTER(%edi) - jne .lu2_next_scope - - // Save the previous try-level in the exception registration structure - movl ST_TRYLEVEL(%edi), %eax - movl %eax, ER_TRYLEVEL(%ebx) - - // Fetch the address of the termination handler - movl ST_HANDLER(%edi), %eax - - // Termination handlers may trash all registers so save the - // important ones and then call the handler - pushl %edx - call *%eax - - // Get our base pointer back - popl %edx - - jmp .lu2_next_scope - -.lu2_done: - - // FIXME: Tear down the EXCEPTION_REGISTRATION entry setup to protect - // the unwinding - - //movl %esi, %esp - //popl %ebp - ret - -#define EH3_DISPCONTEXT 0x14 -#define EH3_CONTEXT 0x10 -#define EH3_REGFRAME 0x0C -#define EH3_ERECORD 0x08 - -// Parameters: -// [ESP+14h] - PVOID DispatcherContext -// [ESP+10h] - PCONTEXT Context -// [ESP+0Ch] - PEXCEPTION_REGISTRATION RegistrationFrame -// [ESP+08h] - PEXCEPTION_RECORD ExceptionRecord -// Registers: -// Unknown -// Returns: -// EXCEPTION_DISPOSITION - How this handler handled the exception -// Notes: -// Try to find an exception handler that will handle the exception. -// Traverse the entries in the scopetable that is associated with the -// exception registration passed as a parameter to this function. -// If an exception handler that will handle the exception is found, it -// is called and this function never returns -__except_handler3: - // Setup our call frame so we can access parameters using EBP - pushl %ebp // Standard ESP in frame (considered part of EXCEPTION_REGISTRATION) - movl %esp, %ebp - - // Don't trust the direction flag to be cleared - cld - - // Either we're called to handle an exception or we're called to unwind - movl EH3_ERECORD(%ebp), %eax - testl $EXCEPTION_UNWIND_MODE, EREC_FLAGS(%eax) - jnz .eh3_unwind - - // Keep a pointer to the exception registration in EBX - movl EH3_REGFRAME(%ebp), %ebx - - // Build an EXCEPTION_POINTERS structure on the stack and store it's - // address in the EXCEPTION_REGISTRATION structure - movl EH3_CONTEXT(%esp), %eax - pushl %ebx // Registration frame - pushl %eax // Context - movl %esp, ER_EPOINTERS(%ebx) // Pointer to EXCEPTION_REGISTRATION on the stack - - // Keep current try-level in EDI - movl ER_TRYLEVEL(%ebx), %edi - - // Keep a pointer to the scopetable in ESI - movl ER_SCOPETABLE(%ebx), %esi - -.eh3_next_scope: - - // If we have reached the end of the chain then exit - cmpl $-1, %edi - je .eh3_search - - // Compute the offset of the entry in the scopetable and store - // the absolute address in EAX - lea (%edi, %edi, 2), %eax - shll $2, %eax - addl %esi, %eax - - // Fetch the address of the filter routine - movl ST_FILTER(%eax), %eax - - // If this is a termination handler then skip it - cmpl $0, %eax - je .eh3_continue - - // Filter routines may trash all registers so save the important - // ones before restoring the call frame ebp and calling the handler - pushl %ebp - pushl %edi // Stop try-level - lea ER_EBP(%ebx), %ebp - call *%eax - popl %edi // Stop try-level - popl %ebp - - // Reload EBX with registration frame address - movl EH3_REGFRAME(%ebp), %ebx - - // Be more flexible here by checking if the return value is less than - // zero, equal to zero, or larger than zero instead of the defined - // values: - // -1 (EXCEPTION_CONTINUE_EXECUTION) - // 0 (EXCEPTION_CONTINUE_SEARCH) - // +1 (EXCEPTION_EXECUTE_HANDLER) - orl %eax, %eax - jz .eh3_continue - js .eh3_dismiss - - // Filter returned: EXCEPTION_EXECUTE_HANDLER - - // Ask the OS to perform global unwinding. - pushl %edi // Save stop try-level - pushl %ebx // Save registration frame address - pushl %ebx // Registration frame address - call __global_unwind2 - popl %eax // Remove parameter to __global_unwind2 - popl %ebx // Restore registration frame address - popl %edi // Restore stop try-level - - // Change the context structure so _except_finish is called in the - // correct context since we return ExceptionContinueExecution. - movl EH3_CONTEXT(%ebp), %eax - - movl %edi, CONTEXT_EDI(%eax) // Stop try-level - movl %ebx, CONTEXT_EBX(%eax) // Registration frame address - movl $_except_finish, CONTEXT_EIP(%eax) - - movl $ExceptionContinueExecution, %eax - jmp .eh3_return - - // Filter returned: EXCEPTION_CONTINUE_SEARCH -.eh3_continue: - - // Reload ESI because the filter routine may have trashed it - movl ER_SCOPETABLE(%ebx), %esi - - // Go one try-level closer to the top - lea (%edi, %edi, 2), %edi - shll $2, %edi - addl %esi, %edi - movl ST_TRYLEVEL(%edi), %edi - - jmp .eh3_next_scope - - // Filter returned: EXCEPTION_CONTINUE_EXECUTION - // Continue execution like nothing happened -.eh3_dismiss: - movl $ExceptionContinueExecution, %eax - jmp .eh3_return - - // Tell the OS to search for another handler that will handle the exception -.eh3_search: - - movl $ExceptionContinueSearch, %eax - jmp .eh3_return - - // Perform local unwinding -.eh3_unwind: - - testl $EXCEPTION_TARGET_UNWIND, EREC_FLAGS(%eax) - jnz .eh3_return - - // Save some important registers - pushl %ebp - - lea ER_EBP(%ebx), %ebp - pushl $-1 - pushl %ebx - call __local_unwind2 - addl $8, %esp - - // Restore some important registers - popl %ebp - - movl $ExceptionContinueSearch, %eax - - // Get me out of here -.eh3_return: - - movl %ebp, %esp - popl %ebp - ret - -// Parameters: -// None -// Registers: -// EBX - Pointer to exception registration structure -// EDI - Stop try-level -// Returns: -// - -// Notes: -// - -_except_finish: - - // Setup EBP for the exception handler. By doing this the exception - // handler can access local variables as normal - lea ER_EBP(%ebx), %ebp - - // Save some important registers - pushl %ebp - pushl %ebx - pushl %edi - - // Stop try-level - pushl %edi - - // Pointer to exception registration structure - pushl %ebx - call __local_unwind2 - addl $8, %esp - - // Restore some important registers - popl %edi - popl %ebx - popl %ebp - - // Keep a pointer to the scopetable in ESI - movl ER_SCOPETABLE(%ebx), %esi - - // Compute the offset of the entry in the scopetable and store - // the absolute address in EDI - lea (%edi, %edi, 2), %edi - shll $2, %edi - addl %esi, %edi - - // Set the current try-level to the previous try-level and call - // the exception handler - movl ST_TRYLEVEL(%edi), %eax - movl %eax, ER_TRYLEVEL(%ebx) - movl ST_HANDLER(%edi), %eax - - call *%eax - - // We should never get here - ret - -// Copied from Wine. -__EH_prolog: - pushl $-1 - pushl %eax - pushl %fs:0 - movl %esp, %fs:0 - movl 12(%esp), %eax - movl %ebp, 12(%esp) - leal 12(%esp), %ebp - pushl %eax - ret diff --git a/reactos/lib/crt/except/i386/unwind.c b/reactos/lib/crt/except/i386/unwind.c deleted file mode 100644 index 7ac0aaf14a0..00000000000 --- a/reactos/lib/crt/except/i386/unwind.c +++ /dev/null @@ -1,72 +0,0 @@ -#define WIN32_NO_STATUS -#include -#include -#define NTOS_MODE_USER -#include -#include -#include - -/* - * @implemented - */ -void __cdecl -_global_unwind2(PEXCEPTION_REGISTRATION_RECORD RegistrationFrame) -{ -#ifdef __GNUC__ - RtlUnwind(RegistrationFrame, &&__ret_label, NULL, 0); -__ret_label: - // return is important - return; -#else -#endif -} - - -/* VC++ extensions to Win32 SEH */ -typedef struct _SCOPETABLE -{ - int previousTryLevel; - int (*lpfnFilter)(PEXCEPTION_POINTERS); - int (*lpfnHandler)(void); -} SCOPETABLE, *PSCOPETABLE; - -typedef struct _MSVCRT_EXCEPTION_FRAME -{ - PEXCEPTION_REGISTRATION_RECORD *prev; - void (*handler)(PEXCEPTION_RECORD, PEXCEPTION_REGISTRATION_RECORD, - PCONTEXT, PEXCEPTION_RECORD); - PSCOPETABLE scopetable; - int trylevel; - int _ebp; - PEXCEPTION_POINTERS xpointers; -} MSVCRT_EXCEPTION_FRAME; - - -typedef struct __JUMP_BUFFER -{ - unsigned long Ebp; - unsigned long Ebx; - unsigned long Edi; - unsigned long Esi; - unsigned long Esp; - unsigned long Eip; - unsigned long Registration; - unsigned long TryLevel; - /* Start of new struct members */ - unsigned long Cookie; - unsigned long UnwindFunc; - unsigned long UnwindData[6]; -} _JUMP_BUFFER; - -void -_local_unwind2(MSVCRT_EXCEPTION_FRAME *RegistrationFrame, - LONG TryLevel); - -/* - * @implemented -*/ - -void __stdcall _seh_longjmp_unwind(_JUMP_BUFFER *jmp) -{ - _local_unwind2((MSVCRT_EXCEPTION_FRAME*) jmp->Registration, jmp->TryLevel); -} diff --git a/reactos/lib/crt/except/matherr.c b/reactos/lib/crt/except/matherr.c deleted file mode 100644 index 2684f1cb65a..00000000000 --- a/reactos/lib/crt/except/matherr.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - - -int _matherr(struct _exception* e) -{ - return 0; -} - -/* - * not exported by NTDLL - * - * @unimplemented - */ -void __setusermatherr(int (*handler)(struct _exception*)) -{ - -} - - -#define _FPIEEE_RECORD void - -/* - * @unimplemented - */ -int _fpieee_flt( - unsigned long exception_code, - struct _EXCEPTION_POINTERS* ExceptionPointer, - int (*handler)(_FPIEEE_RECORD*) - ) -{ - return 0; -} diff --git a/reactos/lib/crt/except/xcptfil.c b/reactos/lib/crt/except/xcptfil.c deleted file mode 100644 index 6a251555b68..00000000000 --- a/reactos/lib/crt/except/xcptfil.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - - -/* - * @unimplemented - */ -int -_XcptFilter(DWORD ExceptionCode, - struct _EXCEPTION_POINTERS * ExceptionInfo) -{ - //fixme XcptFilter -// return UnhandledExceptionFilter(ExceptionInfo); - return 0; -} - diff --git a/reactos/lib/crt/float/chgsign.c b/reactos/lib/crt/float/chgsign.c deleted file mode 100644 index 2cc440ff9de..00000000000 --- a/reactos/lib/crt/float/chgsign.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -#include - -/* - * @implemented - */ -double _chgsign( double __x ) -{ - union - { - double* __x; - double_t *x; - } u; - u.__x = &__x; - - if ( u.x->sign == 1 ) - u.x->sign = 0; - else - u.x->sign = 1; - - return __x; -} diff --git a/reactos/lib/crt/float/copysign.c b/reactos/lib/crt/float/copysign.c deleted file mode 100644 index 992f82c3cea..00000000000 --- a/reactos/lib/crt/float/copysign.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include -#include - -/* - * @implemented - */ -double _copysign (double __d, double __s) -{ - union - { - double* __d; - double_t* d; - } d; - union - { - double* __s; - double_t* s; - } s; - d.__d = &__d; - s.__s = &__s; - - d.d->sign = s.s->sign; - - return __d; -} - diff --git a/reactos/lib/crt/float/fpclass.c b/reactos/lib/crt/float/fpclass.c deleted file mode 100644 index 665379c21bf..00000000000 --- a/reactos/lib/crt/float/fpclass.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include -#include -#include - - -#define _FPCLASS_SNAN 0x0001 /* signaling NaN */ -#define _FPCLASS_QNAN 0x0002 /* quiet NaN */ -#define _FPCLASS_NINF 0x0004 /* negative infinity */ -#define _FPCLASS_NN 0x0008 /* negative normal */ -#define _FPCLASS_ND 0x0010 /* negative denormal */ -#define _FPCLASS_NZ 0x0020 /* -0 */ -#define _FPCLASS_PZ 0x0040 /* +0 */ -#define _FPCLASS_PD 0x0080 /* positive denormal */ -#define _FPCLASS_PN 0x0100 /* positive normal */ -#define _FPCLASS_PINF 0x0200 /* positive infinity */ - - -#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3 - -#define FP_SNAN 0x0001 // signaling NaN -#define FP_QNAN 0x0002 // quiet NaN -#define FP_NINF 0x0004 // negative infinity -#define FP_PINF 0x0200 // positive infinity -#define FP_NDENORM 0x0008 // negative denormalized non-zero -#define FP_PDENORM 0x0010 // positive denormalized non-zero -#define FP_NZERO 0x0020 // negative zero -#define FP_PZERO 0x0040 // positive zero -#define FP_NNORM 0x0080 // negative normalized non-zero -#define FP_PNORM 0x0100 // positive normalized non-zero - -#endif - -typedef int fpclass_t; - -/* - * @implemented - */ -fpclass_t _fpclass(double __d) -{ - union - { - double* __d; - double_t* d; - } d; - d.__d = &__d; - - if ( d.d->exponent == 0 ) { - if ( d.d->mantissah == 0 && d.d->mantissal == 0 ) { - if ( d.d->sign ==0 ) - return FP_NZERO; - else - return FP_PZERO; - } else { - if ( d.d->sign ==0 ) - return FP_NDENORM; - else - return FP_PDENORM; - } - } - if (d.d->exponent == 0x7ff ) { - if ( d.d->mantissah == 0 && d.d->mantissal == 0 ) { - if ( d.d->sign ==0 ) - return FP_NINF; - else - return FP_PINF; - } - else if ( d.d->mantissah == 0 && d.d->mantissal != 0 ) { - return FP_QNAN; - } - else if ( d.d->mantissah == 0 && d.d->mantissal != 0 ) { - return FP_SNAN; - } - - } - return 0; -} diff --git a/reactos/lib/crt/float/fpecode.c b/reactos/lib/crt/float/fpecode.c deleted file mode 100644 index 0fa317634e0..00000000000 --- a/reactos/lib/crt/float/fpecode.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include -#include - -/* - * @implemented - */ -int * __fpecode(void) -{ - return(&(GetThreadData()->fpecode)); -} diff --git a/reactos/lib/crt/float/fpreset.c b/reactos/lib/crt/float/fpreset.c deleted file mode 100644 index 6cbd4e2edf6..00000000000 --- a/reactos/lib/crt/float/fpreset.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @unimplemented - */ -void _fpreset(void) -{ - /* FIXME: This causes an exception */ -// __asm__ __volatile__("fninit\n\t"); - return; -} diff --git a/reactos/lib/crt/float/i386/clearfp.c b/reactos/lib/crt/float/i386/clearfp.c deleted file mode 100644 index 09923b989a4..00000000000 --- a/reactos/lib/crt/float/i386/clearfp.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -unsigned int _statusfp( void ); - -/* - * @implemented - */ -unsigned int _clearfp (void) -{ - unsigned short __res = _statusfp(); -#ifdef __GNUC__ -__asm__ __volatile__ ( - "fclex \n\t" - ); -#else -#endif /*__GNUC__*/ - return __res; -} - diff --git a/reactos/lib/crt/float/i386/cntrlfp.c b/reactos/lib/crt/float/i386/cntrlfp.c deleted file mode 100644 index 48ff7f8f34e..00000000000 --- a/reactos/lib/crt/float/i386/cntrlfp.c +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -#define X87_CW_IM (1<<0) /* Invalid operation mask */ -#define X87_CW_DM (1<<1) /* Denormal operand mask */ -#define X87_CW_ZM (1<<2) /* Zero divide mask */ -#define X87_CW_OM (1<<3) /* Overflow mask */ -#define X87_CW_UM (1<<4) /* Underflow mask */ -#define X87_CW_PM (1<<5) /* Precision mask */ - -#define X87_CW_PC_MASK (3<<8) /* precision control mask */ -#define X87_CW_PC24 (0<<8) /* 24 bit precision */ -#define X87_CW_PC53 (2<<8) /* 53 bit precision */ -#define X87_CW_PC64 (3<<8) /* 64 bit precision */ - -#define X87_CW_RC_MASK (3<<10) /* rounding control mask */ -#define X87_CW_RC_NEAREST (0<<10) /* round to nearest */ -#define X87_CW_RC_DOWN (1<<10) /* round down */ -#define X87_CW_RC_UP (2<<10) /* round up */ -#define X87_CW_RC_ZERO (3<<10) /* round toward zero (chop) */ - -#define X87_CW_IC (1<<12) /* infinity control flag */ - -/* - * @implemented - */ -unsigned int _controlfp(unsigned int unNew, unsigned int unMask) -{ - return _control87(unNew,unMask); -} - -/* - * @implemented - */ -unsigned int _control87(unsigned int unNew, unsigned int unMask) -{ - unsigned int FpuCw; - unsigned int DummyCw = 0; - - /* get the controlword */ - asm volatile("fstcw %0\n\t" : "=m"(FpuCw)); - FpuCw &= 0x0000ffff; - - /* translate it into _control87 format */ - if (FpuCw & X87_CW_IM) - DummyCw |= _EM_INVALID; - if (FpuCw & X87_CW_DM) - DummyCw |= _EM_DENORMAL; - if (FpuCw & X87_CW_ZM) - DummyCw |= _EM_ZERODIVIDE; - if (FpuCw & X87_CW_OM) - DummyCw |= _EM_OVERFLOW; - if (FpuCw & X87_CW_UM) - DummyCw |= _EM_UNDERFLOW; - if (FpuCw & X87_CW_PM) - DummyCw |= _EM_INEXACT; - - switch (FpuCw & X87_CW_PC_MASK) - { - case X87_CW_PC24: - DummyCw |= _PC_24; - break; - case X87_CW_PC53: - DummyCw |= _PC_53; - break; - case X87_CW_PC64: - DummyCw |= _PC_64; - break; - } - - switch (FpuCw & X87_CW_RC_MASK) - { - case X87_CW_RC_NEAREST: - DummyCw |= _RC_NEAR; - break; - case X87_CW_RC_DOWN: - DummyCw |= _RC_DOWN; - break; - case X87_CW_RC_UP: - DummyCw |= _RC_UP; - break; - case X87_CW_RC_ZERO: - DummyCw |= _RC_CHOP; - break; - } - - /* unset (un)masked bits */ - DummyCw &= ~unMask; - unNew &= unMask; - - /* set new bits */ - DummyCw |= unNew; - - /* translate back into x87 format - * FIXME: translate infinity control! - */ - FpuCw = 0; - if (DummyCw & _EM_INVALID) - FpuCw |= X87_CW_IM; - if (DummyCw & _EM_DENORMAL) - FpuCw |= X87_CW_DM; - if (DummyCw & _EM_ZERODIVIDE) - FpuCw |= X87_CW_ZM; - if (DummyCw & _EM_OVERFLOW) - FpuCw |= X87_CW_OM; - if (DummyCw & _EM_UNDERFLOW) - FpuCw |= X87_CW_UM; - if (DummyCw & _EM_INEXACT) - FpuCw |= X87_CW_PM; - - switch (DummyCw & _MCW_PC) - { - case _PC_24: - FpuCw |= X87_CW_PC24; - break; - case _PC_53: - FpuCw |= X87_CW_PC53; - break; - case _PC_64: - default: - FpuCw |= X87_CW_PC64; - break; - } - - switch (DummyCw & _MCW_RC) - { - case _RC_NEAR: - FpuCw |= X87_CW_RC_NEAREST; - break; - case _RC_DOWN: - FpuCw |= X87_CW_RC_DOWN; - break; - case _RC_UP: - FpuCw |= X87_CW_RC_UP; - break; - case _RC_CHOP: - FpuCw |= X87_CW_RC_ZERO; - break; - } - - /* set controlword */ - asm volatile("fldcw %0" : : "m"(FpuCw)); - - return DummyCw; - -#if 0 /* The follwing is the original code, broken I think! -blight */ -register unsigned int __res; -#ifdef __GNUC__ -__asm__ __volatile__ ( - "pushl %%eax \n\t" /* make room on stack */ - "fstcw (%%esp) \n\t" - "fwait \n\t" - "popl %%eax \n\t" - "andl $0xffff, %%eax \n\t" /* OK; we have the old value ready */ - - "movl %1, %%ecx \n\t" - "notl %%ecx \n\t" - "andl %%eax, %%ecx \n\t" /* the bits we want to keep */ - - "movl %2, %%edx \n\t" - "andl %1, %%edx \n\t" /* the bits we want to change */ - - "orl %%ecx, %%edx\n\t" /* the new value */ - "pushl %%edx \n\t" - "fldcw (%%esp) \n\t" - "popl %%edx \n\t" - - :"=a" (__res):"r" (unNew),"r" (unMask): "dx", "cx"); -#else -#endif /*__GNUC__*/ - return __res; -#endif -} diff --git a/reactos/lib/crt/float/i386/logb.c b/reactos/lib/crt/float/i386/logb.c deleted file mode 100644 index ac6bbb857db..00000000000 --- a/reactos/lib/crt/float/i386/logb.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Math functions for i387. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by John C. Bowman , 1995. - - 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 - -double _logb (double __x) -{ - register double __val; -#ifdef __GNUC__ - register double __junk; - __asm __volatile__ - ("fxtract\n\t" - : "=t" (__junk), "=u" (__val) : "0" (__x)); -#else -#endif /*__GNUC__*/ - return __val; -} diff --git a/reactos/lib/crt/float/i386/statfp.c b/reactos/lib/crt/float/i386/statfp.c deleted file mode 100644 index e612ed32bf7..00000000000 --- a/reactos/lib/crt/float/i386/statfp.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -unsigned int _statusfp (void) -{ - -register unsigned short __res; -#ifdef __GNUC__ -__asm__ __volatile__ ( - "fstsw %0 \n\t" -// "movzwl %ax, %eax" - :"=a" (__res) - ); -#else -#endif /*__GNUC__*/ - return __res; -} diff --git a/reactos/lib/crt/float/isnan.c b/reactos/lib/crt/float/isnan.c deleted file mode 100644 index c7d509b20bb..00000000000 --- a/reactos/lib/crt/float/isnan.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995 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 - - -/* - * @implemented - */ -int _isnan(double __x) -{ - union - { - double* __x; - double_t* x; - } x; - x.__x = &__x; - return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 )); -} - -int _isnanl(long double __x) -{ - /* Intel's extended format has the normally implicit 1 explicit - present. Sigh! */ - union - { - long double* __x; - long_double_t* x; - } x; - x.__x = &__x; - - - /* IEEE 854 NaN's have the maximum possible - exponent and a nonzero mantissa. */ - - return (( x.x->exponent == 0x7fff) - && ( (x.x->mantissah & 0x80000000) != 0) - && ( (x.x->mantissah & (unsigned int)0x7fffffff) != 0 || x.x->mantissal != 0 )); -} - -int _isinf(double __x) -{ - union - { - double* __x; - double_t* x; - } x; - - x.__x = &__x; - return ( x.x->exponent == 0x7ff && ( x.x->mantissah == 0 && x.x->mantissal == 0 )); -} - -/* - * @implemented - */ -int _finite( double x ) -{ - return !_isinf(x); -} - -int _isinfl(long double __x) -{ - /* Intel's extended format has the normally implicit 1 explicit - present. Sigh! */ - union - { - long double* __x; - long_double_t* x; - } x; - - x.__x = &__x; - - - /* An IEEE 854 infinity has an exponent with the - maximum possible value and a zero mantissa. */ - - - if ( x.x->exponent == 0x7fff && ( (x.x->mantissah == 0x80000000 ) && x.x->mantissal == 0 )) - return x.x->sign ? -1 : 1; - return 0; -} diff --git a/reactos/lib/crt/float/nafter.c b/reactos/lib/crt/float/nafter.c deleted file mode 100644 index 1d07b92f5d2..00000000000 --- a/reactos/lib/crt/float/nafter.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -double _nextafter( double x, double y ) -{ - if ( x == y) - return x; - - 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 deleted file mode 100644 index ac521d0e127..00000000000 --- a/reactos/lib/crt/float/scalb.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include -#include - -/* - * @implemented - */ -double _scalb( double __x, long e ) -{ - union - { - double* __x; - double_t* x; - } x; - - x.__x = &__x; - - x.x->exponent += e; - - return __x; -} diff --git a/reactos/lib/crt/include/float.h b/reactos/lib/crt/include/float.h deleted file mode 100644 index 86b1b4dfded..00000000000 --- a/reactos/lib/crt/include/float.h +++ /dev/null @@ -1,171 +0,0 @@ -/* - * float.h - * This file has no copyright assigned and is placed in the Public Domain. - * This file is a part of the mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within the package. - * - * Constants related to floating point arithmetic. - * - * Also included here are some non-ANSI bits for accessing the floating - * point controller. - * - * NOTE: GCC provides float.h, but it doesn't include the non-standard - * stuff for accessing the fp controller. We include_next the - * GCC-supplied header and just define the MS-specific extensions - * here. - * - */ -#ifdef __GNUC__ - #include_next -#endif -#ifndef _MINGW_FLOAT_H_ -#define _MINGW_FLOAT_H_ - -/* All the headers include this file. */ -#ifdef __GNUC__ - #include <_mingw.h> -#endif -/* - * Functions and definitions for controlling the FPU. - */ -#ifndef __STRICT_ANSI__ - -/* TODO: These constants are only valid for x86 machines */ - -/* Control word masks for unMask */ -#define _MCW_EM 0x0008001F /* Error masks */ -#define _MCW_IC 0x00040000 /* Infinity */ -#define _MCW_RC 0x00000300 /* Rounding */ -#define _MCW_PC 0x00030000 /* Precision */ - -/* Control word values for unNew (use with related unMask above) */ -#define _EM_INVALID 0x00000010 -#define _EM_DENORMAL 0x00080000 -#define _EM_ZERODIVIDE 0x00000008 -#define _EM_OVERFLOW 0x00000004 -#define _EM_UNDERFLOW 0x00000002 -#define _EM_INEXACT 0x00000001 -#define _IC_AFFINE 0x00040000 -#define _IC_PROJECTIVE 0x00000000 -#define _RC_CHOP 0x00000300 -#define _RC_UP 0x00000200 -#define _RC_DOWN 0x00000100 -#define _RC_NEAR 0x00000000 -#define _PC_24 0x00020000 -#define _PC_53 0x00010000 -#define _PC_64 0x00000000 - -/* These are also defined in Mingw math.h, needed to work around - GCC build issues. */ -/* Return values for fpclass. */ -#ifndef __MINGW_FPCLASS_DEFINED -#define __MINGW_FPCLASS_DEFINED 1 -#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */ -#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */ -#define _FPCLASS_NINF 0x0004 /* Negative Infinity */ -#define _FPCLASS_NN 0x0008 /* Negative Normal */ -#define _FPCLASS_ND 0x0010 /* Negative Denormal */ -#define _FPCLASS_NZ 0x0020 /* Negative Zero */ -#define _FPCLASS_PZ 0x0040 /* Positive Zero */ -#define _FPCLASS_PD 0x0080 /* Positive Denormal */ -#define _FPCLASS_PN 0x0100 /* Positive Normal */ -#define _FPCLASS_PINF 0x0200 /* Positive Infinity */ -#endif /* __MINGW_FPCLASS_DEFINED */ - -/* invalid subconditions (_SW_INVALID also set) */ -#define _SW_UNEMULATED 0x0040 /* unemulated instruction */ -#define _SW_SQRTNEG 0x0080 /* square root of a neg number */ -#define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */ -#define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */ - -/* Floating point error signals and return codes */ -#define _FPE_INVALID 0x81 -#define _FPE_DENORMAL 0x82 -#define _FPE_ZERODIVIDE 0x83 -#define _FPE_OVERFLOW 0x84 -#define _FPE_UNDERFLOW 0x85 -#define _FPE_INEXACT 0x86 -#define _FPE_UNEMULATED 0x87 -#define _FPE_SQRTNEG 0x88 -#define _FPE_STACKOVERFLOW 0x8a -#define _FPE_STACKUNDERFLOW 0x8b -#define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */ - -#ifndef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 -#endif -#ifndef S_IFIFO -#define S_IFIFO -1 -#endif -#ifndef UINT64_MAX -#define UINT64_MAX 0xffffffffffffffff -#endif - -#ifndef RC_INVOKED - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _CRTIMP -#ifdef _DLL -#define _CRTIMP __declspec(dllimport) -#else -#define _CRTIMP -#endif /* _DLL */ -#endif - -/* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask), - * i.e. change the bits in unMask to have the values they have in unNew, - * leaving other bits unchanged. */ -_CRTIMP unsigned int __cdecl _controlfp (unsigned int unNew, unsigned int unMask); -_CRTIMP unsigned int __cdecl _control87 (unsigned int unNew, unsigned int unMask); - - -_CRTIMP unsigned int __cdecl _clearfp (void); /* Clear the FPU status word */ -_CRTIMP unsigned int __cdecl _statusfp (void); /* Report the FPU status word */ -#define _clear87 _clearfp -#define _status87 _statusfp - - -/* - MSVCRT.dll _fpreset initializes the control register to 0x27f, - the status register to zero and the tag word to 0FFFFh. - This differs from asm instruction finit/fninit which set control - word to 0x37f (64 bit mantissa precison rather than 53 bit). - By default, the mingw version of _fpreset sets fp control as - per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when - building your application. -*/ -void __cdecl _fpreset (void); -void __cdecl fpreset (void); - -/* Global 'variable' for the current floating point error code. */ -_CRTIMP int * __cdecl __fpecode(void); -#define _fpecode (*(__fpecode())) - -/* - * IEEE recommended functions. MS puts them in float.h - * but they really belong in math.h. - */ - -_CRTIMP double __cdecl _chgsign (double); -_CRTIMP double __cdecl _copysign (double, double); -_CRTIMP double __cdecl _logb (double); -_CRTIMP double __cdecl _nextafter (double, double); -_CRTIMP double __cdecl _scalb (double, long); - -_CRTIMP int __cdecl _finite (double); -_CRTIMP int __cdecl _fpclass (double); -_CRTIMP int __cdecl _isnan (double); - -#ifdef __cplusplus -} -#endif - -#endif /* Not RC_INVOKED */ - -#endif /* Not __STRICT_ANSI__ */ - -#endif /* _FLOAT_H_ */ - diff --git a/reactos/lib/crt/include/internal/atexit.h b/reactos/lib/crt/include/internal/atexit.h deleted file mode 100644 index 626e8869abb..00000000000 --- a/reactos/lib/crt/include/internal/atexit.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#ifndef __CRT_INTERNAL_ATEXIT_H -#define __CRT_INTERNAL_ATEXIT_H - -#ifndef _CRT_PRECOMP_H -#error DO NOT INCLUDE THIS HEADER DIRECTLY -#endif - -struct __atexit { - struct __atexit* __next; - void (*__function)(void); -}; - -extern struct __atexit* __atexit_ptr; - - -#endif diff --git a/reactos/lib/crt/include/internal/console.h b/reactos/lib/crt/include/internal/console.h deleted file mode 100644 index 351fe1668ba..00000000000 --- a/reactos/lib/crt/include/internal/console.h +++ /dev/null @@ -1,16 +0,0 @@ -/* console.h */ - -#ifndef __CRT_INTERNAL_CONSOLE_H -#define __CRT_INTERNAL_CONSOLE_H - -#ifndef _CRT_PRECOMP_H -#error DO NOT INCLUDE THIS HEADER DIRECTLY -#endif - -extern int char_avail; -extern int ungot_char; - -#endif - -/* EOF */ - diff --git a/reactos/lib/crt/include/internal/debug.h b/reactos/lib/crt/include/internal/debug.h deleted file mode 100644 index de9b59bd5dc..00000000000 --- a/reactos/lib/crt/include/internal/debug.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: include/msvcrt/msvcrtdbg.h - * PURPOSE: Useful debugging macros - * PROGRAMMER: - * UPDATE HISTORY: - * - */ - -/* - * NOTE: Define NDEBUG before including this header to disable debugging - * macros - */ - -#ifndef __MSVCRT_DEBUG -#define __MSVCRT_DEBUG - -#include -#include - - -#define MK_STR(s) #s - -#ifdef _UNICODE - #define sT "S" -#else - #define sT "s" -#endif - -unsigned long DbgPrint(const char *Format,...); - -#ifdef __GNUC__ - #define TRACE(...) -#endif - -#ifdef DBG - #ifdef __GNUC__ - #define DPRINT1(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); - #else - #define DPRINT1 DbgPrint - #endif - #define CHECKPOINT1 do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0); -#else - #ifdef __GNUC__ - #define DPRINT1(args...) - #else - #define DPRINT DbgPrint - #endif - #define CHECKPOINT1 -#endif - -#if !defined(NDEBUG) && defined(DBG) - #ifdef __GNUC__ - #define DPRINT(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); - #endif - #define CHECKPOINT do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0); -#else - #ifdef __GNUC__ - #define DPRINT(args...) - #else - #define DPRINT DbgPrint - #endif - #define CHECKPOINT -#endif /* NDEBUG */ - - -#if 0 - - #define TRACE_RETURN(format_str, ret_type) \ - ret_type __return_value__; \ - static char* __return_format_str__ = "%s ret: "format_str"\n" - - #define FUNCTION(func) \ - static char* __func_name__ = #func - - #define TRACE(a,b...) DPRINT1(a"\n", b) - - #define RETURN(a) \ - do{ __return_value__ = (a); DPRINT1(__return_format_str__ ,__func_name__,__return_value__); return __return_value__ ; }while(0) - -#endif - - -/* ULONG CDECL DbgPrint(PCH Format, ...); */ -ULONG DbgPrint(PCCH Format,...); -/* unsigned long DbgPrint(const char* Format, ...); */ - - - -/* #define TRACE 0 ? (void)0 : Trace */ - -/* void Trace(TCHAR* lpszFormat, ...); */ - - - -#endif /* __MSVCRT_DEBUG */ diff --git a/reactos/lib/crt/include/internal/file.h b/reactos/lib/crt/include/internal/file.h deleted file mode 100644 index 1205a9488c8..00000000000 --- a/reactos/lib/crt/include/internal/file.h +++ /dev/null @@ -1,190 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* - * 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. - */ - -#ifndef __CRT_INTERNAL_FILE_H -#define __CRT_INTERNAL_FILE_H - -#ifndef _CRT_PRECOMP_H -#error DO NOT INCLUDE THIS HEADER DIRECTLY -#endif - -#include -#include - -#ifndef _IORMONCL -#define _IORMONCL 004000 /* remove on close, for temp files */ -#endif -/* if _flag & _IORMONCL, ._name_to_remove needs freeing */ - -#ifndef _IOUNGETC -#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */ -#endif - -/* might need check for IO_APPEND aswell */ -#define OPEN4WRITING(f) ((((f)->_flag & _IOWRT) == _IOWRT)) -#define OPEN4READING(f) ((((f)->_flag & _IOREAD) == _IOREAD)) - -/* might need check for IO_APPEND aswell */ -#define WRITE_STREAM(f) ((((f)->_flag & _IOWRT) == _IOWRT)) -#define READ_STREAM(f) ((((f)->_flag & _IOREAD) == _IOREAD)) - -char __validfp(FILE*); -int __set_errno(int err); -int __set_doserrno(int error); -void* filehnd(int fn); -char __is_text_file(FILE*); -int alloc_fd(void* hFile, char mode); -int _doprnt(const char* fmt, va_list args, FILE *); -int _doscan(FILE* iop, const char* fmt, va_list argp); -int __fileno_dup2(int handle1, int handle2); -char __fileno_getmode(int _fd); -int __fileno_setmode(int _fd, int _newmode); -void free_fd(int _fd); -void sigabort_handler(int sig); -char split_oflags(int oflags); - -unsigned create_io_inherit_block(STARTUPINFOA* si); -void UnixTimeToFileTime(time_t unix_time, FILETIME* filetime, DWORD remainder); -time_t FileTimeToUnixTime(const FILETIME* filetime, DWORD *remainder); - - -#define __FILE_REC_MAX 20 -typedef struct __file_rec -{ - struct __file_rec* next; - int count; - FILE* files[__FILE_REC_MAX]; -} __file_rec; - -extern __file_rec* __file_rec_list; - - -typedef struct _FDINFO -{ - HANDLE hFile; - char fdflags; - char pipechar; /* one char buffer for handles opened on pipes */ - int lockinitflag; - CRITICAL_SECTION lock; -} FDINFO; - -#define FDINFO_ENTRIES_PER_BUCKET_SHIFT 5 /* log2(32) = 5 */ -#define FDINFO_BUCKETS 64 -#define FDINFO_ENTRIES_PER_BUCKET 32 -#define FDINFO_ENTRIES (FDINFO_BUCKETS * FDINFO_ENTRIES_PER_BUCKET) - -/* pipech */ -#define LF 10 /* line feed */ -#define CR 13 /* carriage return */ -#define CTRLZ 26 /* ctrl-z means eof for text */ - -/* mode */ -#define FOPEN 0x01 /* file handle open */ -#define FEOFLAG 0x02 /* end of file has been encountered */ -#define FCRLF 0x04 /* CR-LF across read buffer (in text mode) */ -#define FPIPE 0x08 /* file refers to a pipe */ -#define FNOINHERIT 0x10 /* file handle opened _O_NOINHERIT */ -#define FAPPEND 0x20 /* file opened O_APPEND */ -#define FDEV 0x40 /* file refers to device */ -#define FTEXT 0x80 /* file is in text mode (absence = binary) */ - -/* get bucket index (0-63) from an fd */ -#define fdinfo_bucket_idx(i) ((i) >> FDINFO_ENTRIES_PER_BUCKET_SHIFT) -/* get position inside a bucket (0-31) from an fd */ -#define fdinfo_bucket_entry_idx(i) ((i) & (FDINFO_ENTRIES_PER_BUCKET - 1)) -/* get bucket ptr. (ptr. to first fdinfo inside a bucket) from an fd */ -#define fdinfo_bucket(i) ( __pioinfo[fdinfo_bucket_idx(i)]) -/* get fdinfo ptr. from an fd */ -#define fdinfo(i) (fdinfo_bucket(i) + fdinfo_bucket_entry_idx(i)) - -extern FDINFO* __pioinfo[]; - - -void _dosmaperr(unsigned long oserrcode); - - - -FILE* __alloc_file(void); - - - -int access_dirA(const char *_path); -int access_dirW(const wchar_t *_path); - -#ifdef _UNICODE - #define access_dirT access_dirW -#else - #define access_dirT access_dirA -#endif - - - -void _fwalk(void (*func)(FILE*)); // not exported - - - -#undef MB_CUR_MAX -#define MB_CUR_MAX __mb_cur_max - - -int _isnanl(long double x); -int _isinfl(long double x); -int _isnan(double x); -int _isinf(double x); - -/* Flags for the iobuf structure (for reference) */ -#if 0 -#define _IOREAD 1 /* currently reading */ -#define _IOWRT 2 /* currently writing */ -#define _IORW 0x0080 /* opened as "r+w" */ -#endif - -#ifndef F_OK -#define F_OK 0 /* Check for file existence */ -#endif -#ifndef W_OK -#define W_OK 2 /* Check for write permission */ -#endif - -/* internal FILE->_flag flags */ - -#define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */ -#define _IOEOF 0x0010 /* EOF reached on read */ -#define _IOERR 0x0020 /* I/O error from system */ -#define _IOSTRG 0x0040 /* Strange or no file descriptor */ -#define _IOBINARY 0x040000 -#define _IOTEXT 0x000000 -#define _IOCOMMIT 0x100000 -#define _IODIRTY 0x010000 -#define _IOAHEAD 0x020000 - -/* - * The three possible buffering mode (nMode) values for setvbuf. - * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered... - * maybe I'm testing it wrong? - */ -#define _IOFBF 0x0000 /* full buffered */ -#define _IOLBF 0x0040 /* line buffered */ -#define _IONBF 0x0004 /* not buffered */ -#define _IO_LBF 0x80000 /* this value is used insteat of _IOLBF within the - structure FILE as value for _flags, - because _IOLBF has the same value as _IOSTRG */ - -wint_t _filwbuf(FILE *f); - -#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 2 - int __cdecl _filbuf (FILE*); - int __cdecl _flsbuf (int, FILE*); -#endif - -#endif /* __dj_include_libc_file_h__ */ - diff --git a/reactos/lib/crt/include/internal/ieee.h b/reactos/lib/crt/include/internal/ieee.h deleted file mode 100644 index f397723feae..00000000000 --- a/reactos/lib/crt/include/internal/ieee.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __CRT_INTERNAL_IEEE_H -#define __CRT_INTERNAL_IEEE_H - -typedef struct { - unsigned int mantissa:23; - unsigned int exponent:8; - unsigned int sign:1; -} float_t; - -typedef struct { - unsigned int mantissal:32; - unsigned int mantissah:20; - unsigned int exponent:11; - unsigned int sign:1; -} double_t; - -typedef struct { - unsigned int mantissal:32; - unsigned int mantissah:32; - unsigned int exponent:15; - unsigned int sign:1; - unsigned int empty:16; -} long_double_t; - -#endif diff --git a/reactos/lib/crt/include/internal/math.h b/reactos/lib/crt/include/internal/math.h deleted file mode 100644 index 7f743072737..00000000000 --- a/reactos/lib/crt/include/internal/math.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __CRT_INTERNAL_MATH_H -#define __CRT_INTERNAL_MATH_H - -#ifndef _CRT_PRECOMP_H -#error DO NOT INCLUDE THIS HEADER DIRECTLY -#endif - -int _isinf (double); /* not exported */ -int _isnanl (long double); /* not exported */ -int _isinfl (long double); /* not exported */ - -#endif diff --git a/reactos/lib/crt/include/internal/mbstring.h b/reactos/lib/crt/include/internal/mbstring.h deleted file mode 100644 index 65d89d19c47..00000000000 --- a/reactos/lib/crt/include/internal/mbstring.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __CRT_INTERNAL_MBSTRING_H -#define __CRT_INTERNAL_MBSTRING_H - -#define _KNJ_M ((char)0x01) /* Non-punctuation of Kana-set */ -#define _KNJ_P ((char)0x02) /* Punctuation of Kana-set */ -#define _KNJ_1 ((char)0x04) /* Legal 1st byte of double byte stream */ -#define _KNJ_2 ((char)0x08) /* Legal 2nd btye of double byte stream */ - - -#define ___ 0 -#define _1_ _KNJ_1 /* Legal 1st byte of double byte code */ -#define __2 _KNJ_2 /* Legal 2nd byte of double byte code */ -#define _M_ _KNJ_M /* Non-puntuation in Kana-set */ -#define _P_ _KNJ_P /* Punctuation of Kana-set */ -#define _12 (_1_|__2) -#ifndef _M2 -#define _M2 (_M_|__2) -#endif -#define _P2 (_P_|__2) - -#if defined (_MSC_VER) - -#undef _ismbbkana -#undef _ismbbkpunct -#undef _ismbbalpha -#undef _ismbbalnum -#undef _ismbbgraph -#undef _ismbbkalnum -#undef _ismbblead -#undef _ismbbprint -#undef _ismbbpunct -#undef _ismbbtrail - -#endif - - -#endif diff --git a/reactos/lib/crt/include/internal/mtdll.h b/reactos/lib/crt/include/internal/mtdll.h deleted file mode 100644 index 40dbdae96b3..00000000000 --- a/reactos/lib/crt/include/internal/mtdll.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2002, TransGaming Technologies Inc. - * - * 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 - */ - -#ifndef __CRT_INTERNAL_WINE_MTDLL_H -#define __CRT_INTERNAL_WINE_MTDLL_H - -#if defined(_MT) - -#define _mlock(locknum) _lock(locknum) -#define _munlock(locknum) _unlock(locknum) - -void _unlock( int locknum ); -void _lock( int locknum ); - -#else - -#define _mlock(locknum) do {} while(0) -#define _munlock(locknum) do {} while(0) - -#endif - - -#define _SIGNAL_LOCK 1 -#define _IOB_SCAN_LOCK 2 -#define _TMPNAM_LOCK 3 -#define _INPUT_LOCK 4 -#define _OUTPUT_LOCK 5 -#define _CSCANF_LOCK 6 -#define _CPRINTF_LOCK 7 -#define _CONIO_LOCK 8 -#define _HEAP_LOCK 9 -#define _BHEAP_LOCK 10 /* No longer used? */ -#define _TIME_LOCK 11 -#define _ENV_LOCK 12 -#define _EXIT_LOCK1 13 -#define _EXIT_LOCK2 14 -#define _THREADDATA_LOCK 15 /* No longer used? */ -#define _POPEN_LOCK 16 -#define _LOCKTAB_LOCK 17 -#define _OSFHND_LOCK 18 -#define _SETLOCALE_LOCK 19 -#define _LC_COLLATE_LOCK 20 /* No longer used? */ -#define _LC_CTYPE_LOCK 21 /* No longer used? */ -#define _LC_MONETARY_LOCK 22 /* No longer used? */ -#define _LC_NUMERIC_LOCK 23 /* No longer used? */ -#define _LC_TIME_LOCK 24 /* No longer used? */ -#define _MB_CP_LOCK 25 -#define _NLG_LOCK 26 -#define _TYPEINFO_LOCK 27 -#define _STREAM_LOCKS 28 - -/* Must match definition in msvcrt/stdio.h */ -#define _IOB_ENTRIES 20 -#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_IOB_ENTRIES-1) -#define _TOTAL_LOCKS (_LAST_STREAM_LOCK+1) - -#endif /* WINE_MTDLL_H */ diff --git a/reactos/lib/crt/include/internal/rterror.h b/reactos/lib/crt/include/internal/rterror.h deleted file mode 100644 index b76698b78c5..00000000000 --- a/reactos/lib/crt/include/internal/rterror.h +++ /dev/null @@ -1,31 +0,0 @@ -/* rterror.h */ - -#ifndef __CRT_INTERNAL_RTERROR_H -#define __CRT_INTERNAL_RTERROR_H - - -#define _RT_STACK 0 /* stack overflow */ -#define _RT_NULLPTR 1 /* null pointer assignment */ -#define _RT_FLOAT 2 /* floating point not loaded */ -#define _RT_INTDIV 3 /* integer divide by 0 */ -#define _RT_SPACEARG 4 /* not enough space for arguments */ -#define _RT_SPACEENV 5 /* not enough space for environment */ -#define _RT_ABORT 6 /* abnormal program termination */ -#define _RT_THREAD 7 /* not enough space for thread data */ -#define _RT_LOCK 8 /* unexpected multi-thread lock error */ -#define _RT_HEAP 9 /* unexpected heap error */ -#define _RT_OPENCON 10 /* unable to open console device */ -#define _RT_NONCONT 11 /* non-continuable exception */ -#define _RT_INVALDISP 12 /* invalid disposition of exception */ -#define _RT_ONEXIT 13 /* insufficient heap to allocate - * initial table of function pointers - * used by _onexit()/atexit(). */ -#define _RT_PUREVIRT 14 /* pure virtual function call attempted - * (C++ error) */ -#define _RT_STDIOINIT 15 /* not enough space for stdio initialization */ -#define _RT_LOWIOINIT 16 /* not enough space for lowio initialization */ - -void _amsg_exit (int errnum); - - -#endif /* __MSVCRT_INTERNAL_RTERROR_H */ diff --git a/reactos/lib/crt/include/internal/tls.h b/reactos/lib/crt/include/internal/tls.h deleted file mode 100644 index 4adcc83f236..00000000000 --- a/reactos/lib/crt/include/internal/tls.h +++ /dev/null @@ -1,50 +0,0 @@ -/* tls.h */ - -#ifndef __CRT_INTERNAL_TLS_H -#define __CRT_INTERNAL_TLS_H - -#ifndef _CRT_PRECOMP_H -#error DO NOT INCLUDE THIS HEADER DIRECTLY -#endif - -#include - -#include -#include -#include - -#include - -typedef struct _ThreadData -{ - int terrno; /* *nix error code */ - unsigned long tdoserrno; /* Win32 error code (for I/O only) */ - unsigned __int64 tnext; /* used by rand/srand */ - - char *lasttoken; /* used by strtok */ - wchar_t *wlasttoken; /* used by wcstok */ - - - int fpecode; /* fp exception code */ - - /* qsort variables */ - int (*qcmp)(const void *, const void *); /* the comparison routine */ - int qsz; /* size of each record */ - int thresh; /* THRESHold in chars */ - int mthresh; /* MTHRESHold in chars */ - - EXCEPTION_RECORD *exc_record; /* Head of exception record list */ - -} THREADDATA, *PTHREADDATA; - - -int CreateThreadData(void); -void DestroyThreadData(void); - -void FreeThreadData(PTHREADDATA ptd); -PTHREADDATA GetThreadData(void); - -#endif /* __MSVCRT_INTERNAL_TLS_H */ - -/* EOF */ - diff --git a/reactos/lib/crt/include/internal/wine/cppexcept.h b/reactos/lib/crt/include/internal/wine/cppexcept.h deleted file mode 100644 index 3a822ed9ec0..00000000000 --- a/reactos/lib/crt/include/internal/wine/cppexcept.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * msvcrt C++ exception handling - * - * Copyright 2002 Alexandre Julliard - * - * 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 - */ - -#ifndef __MSVCRT_CPPEXCEPT_H -#define __MSVCRT_CPPEXCEPT_H - -#define CXX_FRAME_MAGIC 0x19930520 -#define CXX_EXCEPTION 0xe06d7363 - -typedef void (*vtable_ptr)(); - -/* type_info object, see cpp.c for inplementation */ -typedef struct __type_info -{ - vtable_ptr *vtable; - char *name; /* Unmangled name, allocated lazily */ - char mangled[32]; /* Variable length, but we declare it large enough for static RTTI */ -} type_info; - -/* the exception frame used by CxxFrameHandler */ -typedef struct __cxx_exception_frame -{ - EXCEPTION_REGISTRATION_RECORD frame; /* the standard exception frame */ - int trylevel; - DWORD ebp; -} cxx_exception_frame; - -/* info about a single catch {} block */ -typedef struct __catchblock_info -{ - UINT flags; /* flags (see below) */ - type_info *type_info; /* C++ type caught by this block */ - int offset; /* stack offset to copy exception object to */ - void (*handler)(); /* catch block handler code */ -} catchblock_info; -#define TYPE_FLAG_CONST 1 -#define TYPE_FLAG_VOLATILE 2 -#define TYPE_FLAG_REFERENCE 8 - -/* info about a single try {} block */ -typedef struct __tryblock_info -{ - int start_level; /* start trylevel of that block */ - int end_level; /* end trylevel of that block */ - int catch_level; /* initial trylevel of the catch block */ - int catchblock_count; /* count of catch blocks in array */ - catchblock_info *catchblock; /* array of catch blocks */ -} tryblock_info; - -/* info about the unwind handler for a given trylevel */ -typedef struct __unwind_info -{ - int prev; /* prev trylevel unwind handler, to run after this one */ - void (*handler)(); /* unwind handler */ -} unwind_info; - -/* descriptor of all try blocks of a given function */ -typedef struct __cxx_function_descr -{ - UINT magic; /* must be CXX_FRAME_MAGIC */ - UINT unwind_count; /* number of unwind handlers */ - unwind_info *unwind_table; /* array of unwind handlers */ - UINT tryblock_count; /* number of try blocks */ - tryblock_info *tryblock; /* array of try blocks */ - UINT unknown[3]; -} cxx_function_descr; - -typedef void (*cxx_copy_ctor)(void); - -/* complete information about a C++ type */ -typedef struct __cxx_type_info -{ - UINT flags; /* flags (see CLASS_* flags below) */ - type_info *type_info; /* C++ type info */ - int this_offset; /* offset of base class this pointer from start of object */ - int vbase_descr; /* offset of virtual base class descriptor */ - int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */ - size_t size; /* object size */ - cxx_copy_ctor copy_ctor; /* copy constructor */ -} cxx_type_info; -#define CLASS_IS_SIMPLE_TYPE 1 -#define CLASS_HAS_VIRTUAL_BASE_CLASS 4 - -/* table of C++ types that apply for a given object */ -typedef struct __cxx_type_info_table -{ - UINT count; /* number of types */ - const cxx_type_info *info[3]; /* variable length, we declare it large enough for static RTTI */ -} cxx_type_info_table; - -typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, cxx_exception_frame*, - PCONTEXT, EXCEPTION_REGISTRATION_RECORD**, - cxx_function_descr*, int nested_trylevel, - EXCEPTION_REGISTRATION_RECORD *nested_frame, DWORD unknown3 ); - -/* type information for an exception object */ -typedef struct __cxx_exception_type -{ - UINT flags; /* TYPE_FLAG flags */ - void (*destructor)(); /* exception object destructor */ - cxx_exc_custom_handler custom_handler; /* custom handler for this exception */ - const cxx_type_info_table *type_info_table; /* list of types for this exception object */ -} cxx_exception_type; - -void _CxxThrowException(void*,const cxx_exception_type*); - -#endif /* __MSVCRT_CPPEXCEPT_H */ diff --git a/reactos/lib/crt/include/internal/wine/eh.h b/reactos/lib/crt/include/internal/wine/eh.h deleted file mode 100644 index 14201fb0676..00000000000 --- a/reactos/lib/crt/include/internal/wine/eh.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * C++ exception handling facility - * - * Copyright 2000 Francois Gouget. - * - * 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 - */ -#ifndef __WINE_EH_H -#define __WINE_EH_H -#ifndef __WINE_USE_MSVCRT -#define __WINE_USE_MSVCRT -#endif - -#if !defined(__cplusplus) && !defined(USE_MSVCRT_PREFIX) -#error "eh.h is meant only for C++ applications" -#endif - -#ifndef MSVCRT -# ifdef USE_MSVCRT_PREFIX -# define MSVCRT(x) MSVCRT_##x -# else -# define MSVCRT(x) x -# endif -#endif - -struct _EXCEPTION_POINTERS; - -typedef void (*terminate_handler)(); -typedef void (*terminate_function)(); -typedef void (*unexpected_handler)(); -typedef void (*unexpected_function)(); -typedef void (*_se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info); - -terminate_function MSVCRT(set_terminate)(terminate_function func); -unexpected_function MSVCRT(set_unexpected)(unexpected_function func); -_se_translator_function MSVCRT(_set_se_translator)(_se_translator_function func); - -void MSVCRT(terminate)(); -void MSVCRT(unexpected)(); - -#endif /* __WINE_EH_H */ diff --git a/reactos/lib/crt/include/internal/wine/msvcrt.h b/reactos/lib/crt/include/internal/wine/msvcrt.h deleted file mode 100644 index 8a18c0be4b2..00000000000 --- a/reactos/lib/crt/include/internal/wine/msvcrt.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2001 Jon Griffiths - * - * 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 - */ - -#ifndef __WINE_MSVCRT_H -#define __WINE_MSVCRT_H - -#include -#include -#include - -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "winnls.h" - -//#include "msvcrt/string.h" -#include "eh.h" - -/* TLS data */ -extern DWORD MSVCRT_tls_index; - -typedef struct __MSVCRT_thread_data -{ - int _errno; // ros - unsigned long doserrno; - char *mbstok_next; /* next ptr for mbstok() */ - char *efcvt_buffer; /* buffer for ecvt/fcvt */ - terminate_function terminate_handler; - unexpected_function unexpected_handler; - _se_translator_function se_translator; - EXCEPTION_RECORD *exc_record; -} MSVCRT_thread_data; - -extern MSVCRT_thread_data *msvcrt_get_thread_data(void); - -extern int MSVCRT_current_lc_all_cp; - -void _purecall(void); -void MSVCRT__set_errno(int); -char* msvcrt_strndup(const char*,unsigned int); -#ifndef __REACTOS__ -MSVCRT_wchar_t *msvcrt_wstrndup(const MSVCRT_wchar_t*, unsigned int); -#endif -void MSVCRT__amsg_exit(int errnum); - -extern char **MSVCRT__environ; -#ifndef __REACTOS__ -extern MSVCRT_wchar_t **MSVCRT__wenviron; -extern char ** msvcrt_SnapshotOfEnvironmentA(char **); -extern MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **); -#endif - -/* FIXME: This should be declared in new.h but it's not an extern "C" so - * it would not be much use anyway. Even for Winelib applications. - */ -int MSVCRT__set_new_mode(int mode); - -void* MSVCRT_operator_new(unsigned long size); -void MSVCRT_operator_delete(void*); -#ifndef __REACTOS__ -typedef void* (*MSVCRT_malloc_func)(MSVCRT_size_t); -#endif -typedef void (*MSVCRT_free_func)(void*); -#ifndef __REACTOS__ -extern char* MSVCRT___unDName(int,const char*,int,MSVCRT_malloc_func,MSVCRT_free_func,unsigned int); -#endif - -/* Setup and teardown multi threaded locks */ -extern void msvcrt_init_mt_locks(void); -extern void msvcrt_free_mt_locks(void); - -extern void msvcrt_init_io(void); -extern void msvcrt_free_io(void); -extern void msvcrt_init_console(void); -extern void msvcrt_free_console(void); -extern void msvcrt_init_args(void); -extern void msvcrt_free_args(void); - -/* run-time error codes */ -#define _RT_STACK 0 -#define _RT_NULLPTR 1 -#define _RT_FLOAT 2 -#define _RT_INTDIV 3 -#define _RT_EXECMEM 5 -#define _RT_EXECFORM 6 -#define _RT_EXECENV 7 -#define _RT_SPACEARG 8 -#define _RT_SPACEENV 9 -#define _RT_ABORT 10 -#define _RT_NPTR 12 -#define _RT_FPTR 13 -#define _RT_BREAK 14 -#define _RT_INT 15 -#define _RT_THREAD 16 -#define _RT_LOCK 17 -#define _RT_HEAP 18 -#define _RT_OPENCON 19 -#define _RT_QWIN 20 -#define _RT_NOMAIN 21 -#define _RT_NONCONT 22 -#define _RT_INVALDISP 23 -#define _RT_ONEXIT 24 -#define _RT_PUREVIRT 25 -#define _RT_STDIOINIT 26 -#define _RT_LOWIOINIT 27 -#define _RT_HEAPINIT 28 -#define _RT_DOMAIN 120 -#define _RT_SING 121 -#define _RT_TLOSS 122 -#define _RT_CRNL 252 -#define _RT_BANNER 255 - -typedef void* (*malloc_func_t)(size_t); -typedef void (*free_func_t)(void*); -#define MSVCRT_malloc malloc -#define MSVCRT_free free -NTSYSAPI VOID NTAPI RtlAssert(PVOID FailedAssertion,PVOID FileName,ULONG LineNumber,PCHAR Message); -extern char* __unDName(char *,const char*,int,malloc_func_t,free_func_t,unsigned short int); - -#endif /* __WINE_MSVCRT_H */ diff --git a/reactos/lib/crt/io/access.c b/reactos/lib/crt/io/access.c deleted file mode 100644 index 18558fdd276..00000000000 --- a/reactos/lib/crt/io/access.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -#define NDEBUG -#include - -#ifdef _UNICODE - #define _TS S -#else - #define _TS s -#endif - - -/* - * @implemented - */ -int _taccess( const _TCHAR *_path, int _amode ) -{ - DWORD Attributes = GetFileAttributes(_path); - DPRINT(MK_STR(_taccess)"('%"sT"', %x)\n", _path, _amode); - - if (Attributes == (DWORD)-1) { - _dosmaperr(GetLastError()); - return -1; - } - if ((_amode & W_OK) == W_OK) { - if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) { - __set_errno(EACCES); - return -1; - } - } - - return 0; -} - - - -/* - * INTERNAL - */ -int access_dirT(const _TCHAR *_path) -{ - DWORD Attributes = GetFileAttributes(_path); - DPRINT(MK_STR(is_dirT)"('%"sT"')\n", _path); - - if (Attributes == (DWORD)-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 deleted file mode 100644 index 218d4741c04..00000000000 --- a/reactos/lib/crt/io/chmod.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include -#include -#include - -#define NDEBUG -#include - - -#define mode_t int - - -/* - * @implemented - */ -int _tchmod(const _TCHAR* filename, mode_t mode) -{ - DWORD FileAttributes = 0; - BOOLEAN Set = FALSE; - - DPRINT(MK_STR(_tchmod)"('%"sT"', %x)\n", filename, mode); - - FileAttributes = GetFileAttributes(filename); - if ( FileAttributes == (DWORD)-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 && SetFileAttributes(filename, FileAttributes) == FALSE) { - _dosmaperr(GetLastError()); - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/io/chsize.c b/reactos/lib/crt/io/chsize.c deleted file mode 100644 index 78410c0debd..00000000000 --- a/reactos/lib/crt/io/chsize.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -#include - -#define NDEBUG -#include - -/* - * @implemented - */ -int _chsize(int _fd, long size) -{ - DPRINT("_chsize(fd %d, size %d)\n", _fd, size); - long location = _lseek(_fd, 0, SEEK_CUR); - if (location == -1) return -1; - if (_lseek(_fd, size, 0) == -1) - return -1; - if (!SetEndOfFile((HANDLE)_get_osfhandle(_fd))) - return -1; - _lseek(_fd, location, SEEK_SET); - return 0; -} diff --git a/reactos/lib/crt/io/close.c b/reactos/lib/crt/io/close.c deleted file mode 100644 index 56138d4bb49..00000000000 --- a/reactos/lib/crt/io/close.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -#define NDEBUG -#include - -/* - * @implemented - */ -int _close(int _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 deleted file mode 100644 index b939cd98ac3..00000000000 --- a/reactos/lib/crt/io/commit.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -/* - * @implemented - */ -int _commit(int _fd) -{ - if (! FlushFileBuffers((HANDLE)_get_osfhandle(_fd)) ) { - __set_errno(EBADF); - return -1; - } - - return 0; -} diff --git a/reactos/lib/crt/io/create.c b/reactos/lib/crt/io/create.c deleted file mode 100644 index 8ef454219c9..00000000000 --- a/reactos/lib/crt/io/create.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -int _creat(const char* filename, int mode) -{ - DPRINT("_creat('%s', mode %x)\n", filename, mode); - return _open(filename,_O_CREAT|_O_TRUNC,mode); -} diff --git a/reactos/lib/crt/io/dup.c b/reactos/lib/crt/io/dup.c deleted file mode 100644 index 7231309ac08..00000000000 --- a/reactos/lib/crt/io/dup.c +++ /dev/null @@ -1,38 +0,0 @@ -#include - -/* - * @implemented - */ -int _dup(int handle) -{ - HANDLE hFile; - HANDLE hProcess = GetCurrentProcess(); - BOOL result; - int fd; - int mode; - - hFile = (HANDLE)_get_osfhandle(handle); - if (hFile == INVALID_HANDLE_VALUE) { - __set_errno(EBADF); - return -1; - } - mode = __fileno_getmode(handle); - result = DuplicateHandle(hProcess, - hFile, - hProcess, - &hFile, - 0, - mode & FNOINHERIT ? FALSE : TRUE, - DUPLICATE_SAME_ACCESS); - if (result == FALSE) { - _dosmaperr(GetLastError()); - return -1; - } - - fd = alloc_fd(hFile, mode); - if (fd < 0) - { - CloseHandle(hFile); - } - return fd; -} diff --git a/reactos/lib/crt/io/dup2.c b/reactos/lib/crt/io/dup2.c deleted file mode 100644 index c77c1131755..00000000000 --- a/reactos/lib/crt/io/dup2.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -/* - * @implemented - */ -int _dup2(int handle1, int handle2) -{ - return __fileno_dup2(handle1, handle2); -} diff --git a/reactos/lib/crt/io/eof.c b/reactos/lib/crt/io/eof.c deleted file mode 100644 index 026e7203479..00000000000 --- a/reactos/lib/crt/io/eof.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include - -/* - * @implemented - */ -int _eof(int _fd) -{ - __int64 cur_pos = _lseeki64(_fd, 0, SEEK_CUR); - __int64 end_pos = _lseeki64(_fd, 0, SEEK_END); - if ( cur_pos == -1 || end_pos == -1) - return -1; - - if (cur_pos == end_pos) - return 1; - - return 0; -} diff --git a/reactos/lib/crt/io/filelen.c b/reactos/lib/crt/io/filelen.c deleted file mode 100644 index 71489ecfc6e..00000000000 --- a/reactos/lib/crt/io/filelen.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -/* - * @implemented - */ -long _filelength(int _fd) -{ - DWORD len = GetFileSize((HANDLE)_get_osfhandle(_fd), NULL); - if (len == INVALID_FILE_SIZE) { - DWORD oserror = GetLastError(); - if (oserror != 0) { - _dosmaperr(oserror); - return -1L; - } - } - return (long)len; -} diff --git a/reactos/lib/crt/io/fileleni.c b/reactos/lib/crt/io/fileleni.c deleted file mode 100644 index cbcbde503a0..00000000000 --- a/reactos/lib/crt/io/fileleni.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -/* - * @implemented - */ -__int64 _filelengthi64(int _fd) -{ - DWORD lo_length, hi_length; - - lo_length = GetFileSize((HANDLE)_get_osfhandle(_fd), &hi_length); - if (lo_length == INVALID_FILE_SIZE) { - DWORD oserror = GetLastError(); - if (oserror != 0) { - _dosmaperr(oserror); - return (__int64)-1; - } - } - return((((__int64)hi_length) << 32) + lo_length); -} diff --git a/reactos/lib/crt/io/find.c b/reactos/lib/crt/io/find.c deleted file mode 100644 index 280f3d6e756..00000000000 --- a/reactos/lib/crt/io/find.c +++ /dev/null @@ -1,189 +0,0 @@ -#include -#include - -/* - * @implemented - */ -#if defined(_UNICODE) || !(__MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3) -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( -#if defined(_UNICODE) || !(__MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3) - 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 - */ -int _findclose( -#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3 - int handle -#else - long handle -#endif - ) -{ - // check no wildcards or invalid handle - if (handle == 0 || handle == -1) - return 0; - return FindClose((void*)handle); -} - -#endif diff --git a/reactos/lib/crt/io/fmode.c b/reactos/lib/crt/io/fmode.c deleted file mode 100644 index 97d5fa4cbc3..00000000000 --- a/reactos/lib/crt/io/fmode.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -int _fmode = O_TEXT; - -/* - * @implemented - */ -int *__p__fmode(void) -{ - return &_fmode; -} diff --git a/reactos/lib/crt/io/isatty.c b/reactos/lib/crt/io/isatty.c deleted file mode 100644 index 6e1573b8009..00000000000 --- a/reactos/lib/crt/io/isatty.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#define NDEBUG -#include - -/* - * @implemented - */ -int _isatty(int fd) -{ - HANDLE hFile = fdinfo(fd)->hFile; - if (hFile == INVALID_HANDLE_VALUE) - return 0; - return GetFileType(hFile) == FILE_TYPE_CHAR ? 1 : 0; -} diff --git a/reactos/lib/crt/io/locking.c b/reactos/lib/crt/io/locking.c deleted file mode 100644 index 3d8d7b5ebad..00000000000 --- a/reactos/lib/crt/io/locking.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -/* - * @implemented - */ -int _locking(int _fd, int mode, long nbytes) -{ - long offset = _lseek(_fd, 0L, 1); - if (offset == -1L) - return -1; - if (!LockFile((HANDLE)_get_osfhandle(_fd),offset,0,nbytes,0)) { - _dosmaperr(GetLastError()); - return -1; - } - - return 0; -} diff --git a/reactos/lib/crt/io/lseek.c b/reactos/lib/crt/io/lseek.c deleted file mode 100644 index 1a5c0e6d820..00000000000 --- a/reactos/lib/crt/io/lseek.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -/* - * @implemented - */ -long _lseek(int _fildes, long _offset, int _whence) -{ - DWORD newpos = SetFilePointer((HANDLE)fdinfo(_fildes)->hFile, _offset, NULL, _whence); - if (newpos == INVALID_SET_FILE_POINTER) { - DWORD oserror = GetLastError(); - if (oserror != 0) { - _dosmaperr(oserror); - return -1L; - } - } - return newpos; -} diff --git a/reactos/lib/crt/io/lseeki64.c b/reactos/lib/crt/io/lseeki64.c deleted file mode 100644 index f5265a731de..00000000000 --- a/reactos/lib/crt/io/lseeki64.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -//#define SETFILEPOINTEREX_AVAILABLE - -/* - * @implemented - */ -__int64 _lseeki64(int _fildes, __int64 _offset, int _whence) -{ -#ifdef SETFILEPOINTEREX_AVAILABLE - LARGE_INTEGER new_pos; - LARGE_INTEGER offset; - offset.QuadPart = _offset; - -// if (invalid_filehnd(_fildes)) { -// __set_errno ( EBADF ); -// return -1L; -// } - if (SetFilePointerEx((HANDLE)fdinfo(_fildes)->hFile, offset, &new_pos, _whence)) { - } else { - _dosmaperr(error); - return -1L; - } - return new_pos.QuadPart; -#else - //ULONG lo_pos; - //DWORD hi_pos = 0; // must equal 0 or -1 if supplied, -1 for negative 32 seek value - //lo_pos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, &hi_pos, _whence); - //return((((__int64)hi_pos) << 32) + lo_pos); - - LARGE_INTEGER offset; - offset.QuadPart = _offset; - - offset.u.LowPart = SetFilePointer((HANDLE)fdinfo(_fildes)->hFile, - offset.u.LowPart, &offset.u.HighPart, _whence); - return ((((__int64)offset.u.HighPart) << 32) + offset.u.LowPart); - -#endif /*SETFILEPOINTEREX_AVAILABLE*/ -} diff --git a/reactos/lib/crt/io/mktemp.c b/reactos/lib/crt/io/mktemp.c deleted file mode 100644 index 61ee41007fc..00000000000 --- a/reactos/lib/crt/io/mktemp.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/mktemp.c - * PURPOSE: Makes a temp file based on a template - * PROGRAMER: DJ Delorie - Ariadne - * UPDATE HISTORY: - * 28/12/98: Appropriated for the Reactos Kernel - */ - -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -#define NDEBUG -#include - -/* - * @implemented - */ -char* _mktemp(char* _template) -{ - static int count = 0; - char *cp, *dp; - int i, len, xcount, loopcnt; - - DPRINT("_mktemp('%s')\n", _template); - len = strlen (_template); - cp = _template + len; - - xcount = 0; - while (xcount < 6 && cp > _template && cp[-1] == 'X') - xcount++, cp--; - - if (xcount) { - dp = cp; - while (dp > _template && dp[-1] != '/' && dp[-1] != '\\' && dp[-1] != ':') - dp--; - - /* Keep the first characters of the template, but turn the rest into - Xs. */ - while (cp > dp + 8 - xcount) { - *--cp = 'X'; - xcount = (xcount >= 6) ? 6 : 1 + xcount; - } - - /* If dots occur too early -- squash them. */ - while (dp < cp) { - if (*dp == '.') *dp = 'a'; - dp++; - } - - /* Try to add ".tmp" to the filename. Truncate unused Xs. */ - if (cp + xcount + 3 < _template + len) - strcpy (cp + xcount, ".tmp"); - else - cp[xcount] = 0; - - /* This loop can run up to 2<<(5*6) times, or about 10^9 times. */ - for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) { - int c = count++; - for (i = 0; i < xcount; i++, c >>= 5) - cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f]; - if (_access(_template,0) == -1) - return _template; - } - } - - /* Failure: truncate the template and return NULL. */ - *_template = 0; - return 0; -} diff --git a/reactos/lib/crt/io/open.c b/reactos/lib/crt/io/open.c deleted file mode 100644 index 97fcd4c13ed..00000000000 --- a/reactos/lib/crt/io/open.c +++ /dev/null @@ -1,729 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/open.c - * PURPOSE: Opens a file and translates handles to fileno - * PROGRAMER: Ariadne - * 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 - -#if !defined(NDEBUG) && defined(DBG) -#include -#endif - -#include -#include -#include - -#define NDEBUG -#include - - - -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) - -///////////////////////////////////////// - -static int g_fdstart = 3; /* first unallocated fd */ -static int g_fdend = 3; /* highest allocated fd */ - -/* - * INTERNAL - */ - /* -static __inline FD_INFO* fdinfo(int fd) -{ - 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)); -} -*/ - - -/* - * INTERNAL - */ -__inline BOOL is_valid_fd(int fd) -{ - BOOL b = (fd >= 0 && fd < g_fdend && (fdinfo(fd)->fdflags & FOPEN)); - - if (!b){ - if (fd >= 0 && fd < g_fdend) - { - 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); - } - else - { - DPRINT1("not valid fd %i, g_fdend %i\n",fd,g_fdend); - } - - } - - 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 || fdinfo_bucket((p)->_file) == NULL ) - return FALSE; - return (!((p)->_flag&_IOSTRG) && (fdinfo((p)->_file)->fdflags & FTEXT)); -} - -/* - * @implemented - */ -int _open(const char* _path, int _oflag,...) -{ -#if !defined(NDEBUG) && defined(DBG) - va_list arg; - int pmode; -#endif - HANDLE hFile; - DWORD dwDesiredAccess = 0; - DWORD dwShareMode = 0; - DWORD dwCreationDistribution = 0; - DWORD dwFlagsAndAttributes = 0; - SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; - -#if !defined(NDEBUG) && defined(DBG) - va_start(arg, _oflag); - pmode = va_arg(arg, int); -#endif - - - TRACE("_open('%s', %x, (%x))\n", _path, _oflag); - - - if ((_oflag & S_IREAD ) == S_IREAD) - dwShareMode = FILE_SHARE_READ; - else if ((_oflag & S_IWRITE) == S_IWRITE) { - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - } - /* - * - * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.) - * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.) - * - * _O_APPEND Moves file pointer to end of file before every write operation. - */ -#ifdef _OLD_BUILD_ - if ((_oflag & _O_RDWR) == _O_RDWR) - dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ; - else if ((_oflag & O_RDONLY) == O_RDONLY) - dwDesiredAccess |= GENERIC_READ; - else if ((_oflag & _O_WRONLY) == _O_WRONLY) - dwDesiredAccess |= GENERIC_WRITE ; -#else - if ((_oflag & _O_WRONLY) == _O_WRONLY ) - dwDesiredAccess |= GENERIC_WRITE ; - else if ((_oflag & _O_RDWR) == _O_RDWR ) - dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ; - else //if ((_oflag & O_RDONLY) == O_RDONLY) - dwDesiredAccess |= GENERIC_READ; -#endif - - if (( _oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) - dwCreationDistribution |= CREATE_NEW; - - else if ((_oflag & O_TRUNC ) == O_TRUNC) { - if ((_oflag & O_CREAT ) == O_CREAT) - dwCreationDistribution |= CREATE_ALWAYS; - else if ((_oflag & O_RDONLY ) != O_RDONLY) - dwCreationDistribution |= TRUNCATE_EXISTING; - } - else if ((_oflag & _O_APPEND) == _O_APPEND) - dwCreationDistribution |= OPEN_EXISTING; - else if ((_oflag & _O_CREAT) == _O_CREAT) - dwCreationDistribution |= OPEN_ALWAYS; - else - dwCreationDistribution |= OPEN_EXISTING; - - if ((_oflag & _O_RANDOM) == _O_RANDOM ) - dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS; - if ((_oflag & _O_SEQUENTIAL) == _O_SEQUENTIAL) - dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN; - if ((_oflag & _O_TEMPORARY) == _O_TEMPORARY) { - dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; - DPRINT("FILE_FLAG_DELETE_ON_CLOSE\n"); - } - if ((_oflag & _O_SHORT_LIVED) == _O_SHORT_LIVED) { - dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; - DPRINT("FILE_FLAG_DELETE_ON_CLOSE\n"); - } - if (_oflag & _O_NOINHERIT) - sa.bInheritHandle = FALSE; - - if (dwCreationDistribution == OPEN_EXISTING && - (dwDesiredAccess & (GENERIC_WRITE|GENERIC_READ)) == GENERIC_READ) { - /* Allow always shared read for a file which is opened for read only */ - dwShareMode |= FILE_SHARE_READ; - } - - hFile = CreateFileA(_path, - dwDesiredAccess, - dwShareMode, - &sa, - dwCreationDistribution, - dwFlagsAndAttributes, - NULL); - if (hFile == (HANDLE)-1) { - _dosmaperr(GetLastError()); - return( -1); - } - DPRINT("OK\n"); - if (!(_oflag & (_O_TEXT|_O_BINARY))) { - _oflag |= _fmode; - } - return(alloc_fd(hFile, split_oflags(_oflag))); -} - - - -/* - * INTERNAL - */ -static void init_bucket(FDINFO* entry) -{ - 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; - } -} - -/* - * INTERNAL - */ -static BOOL alloc_init_bucket(int fd) -{ - fdinfo_bucket(fd) = malloc(FDINFO_ENTRIES_PER_BUCKET * sizeof(FDINFO)); - if (!fdinfo_bucket(fd)) return FALSE; - - init_bucket(fdinfo_bucket(fd)); - - return TRUE; -} - - - - -/* - * 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) -{ - - 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; - } - return fdinfo(fd)->fdflags; - -} - -/* - * INTERNAL - */ -void free_fd(int fd) -{ - 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(long osfhandle, int oflags) -{ - /* - 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 - */ -long _get_osfhandle(int fd) -{ - 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 >= FDINFO_ENTRIES || handle1 < 0 || handle2 >= FDINFO_ENTRIES || handle2 < 0) { - __set_errno(EBADF); - return -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 (fdinfo(handle2)->hFile != INVALID_HANDLE_VALUE) { - _close(handle2); - } - hProcess = GetCurrentProcess(); - result = DuplicateHandle(hProcess, - fdinfo(handle1)->hFile, - hProcess, - &fdinfo(handle2)->hFile, - 0, - fdinfo(handle1)->fdflags & FNOINHERIT ? FALSE : TRUE, - DUPLICATE_SAME_ACCESS); - if (result) { -// _pioinfo[handle2]->fd = handle2; - fdinfo(handle2)->fdflags = fdinfo(handle1)->fdflags; - switch (handle2) { - case 0: - SetStdHandle(STD_INPUT_HANDLE, fdinfo(handle2)->hFile); - break; - case 1: - SetStdHandle(STD_OUTPUT_HANDLE, fdinfo(handle2)->hFile); - break; - case 2: - SetStdHandle(STD_ERROR_HANDLE, fdinfo(handle2)->hFile); - break; - } - - return handle1; - } else { - __set_errno(EMFILE); // Is this the correct error no.? - return -1; - } -} - - -void* malloc(size_t sizeObject); - - - -/* - * INTERNAL - */ -BOOL __fileno_init(void) -{ - STARTUPINFOA si; - int i; - - init_bucket(first_bucket); - - GetStartupInfoA(&si); - - if (si.cbReserved2 != 0 && si.lpReserved2 != NULL) - { - 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; - } - - InitializeCriticalSection(&g_file_cs); - - - if (fdinfo(0)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(0)->fdflags & FOPEN)) { - fdinfo(0)->hFile = GetStdHandle(STD_INPUT_HANDLE); - if (fdinfo(0)->hFile == NULL) - fdinfo(0)->hFile = INVALID_HANDLE_VALUE; - fdinfo(0)->fdflags = FOPEN|FTEXT; - } - if (fdinfo(1)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(1)->fdflags & FOPEN)) { - fdinfo(1)->hFile = GetStdHandle(STD_OUTPUT_HANDLE); - if (fdinfo(1)->hFile == NULL) - fdinfo(1)->hFile = INVALID_HANDLE_VALUE; - fdinfo(1)->fdflags = FOPEN|FTEXT; - } - if (fdinfo(2)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(2)->fdflags & FOPEN)) { - fdinfo(2)->hFile = GetStdHandle(STD_ERROR_HANDLE); - if (fdinfo(2)->hFile == NULL) - fdinfo(2)->hFile = INVALID_HANDLE_VALUE; - fdinfo(2)->fdflags = FOPEN|FTEXT; - } - - - - - 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 deleted file mode 100644 index 0fff3ed07b1..00000000000 --- a/reactos/lib/crt/io/pipe.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/pipe.c - * PURPOSE: Creates a pipe - * PROGRAMER: DJ Delorie - * UPDATE HISTORY: - * 28/12/98: Appropriated for Reactos - */ - -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -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); - } - - if ((_fildes[0] = alloc_fd(hReadPipe, split_oflags(mode))) < 0) - { - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - __set_errno(EMFILE); - return(-1); - } - - if ((_fildes[1] = alloc_fd(hWritePipe, split_oflags(mode))) < 0) - { - free_fd(_fildes[0]); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - __set_errno(EMFILE); - return(-1); - } - return(0); -} diff --git a/reactos/lib/crt/io/read.c b/reactos/lib/crt/io/read.c deleted file mode 100644 index a614f73f8ed..00000000000 --- a/reactos/lib/crt/io/read.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/read.c - * PURPOSE: Reads a file - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/1998: Created - * 03/05/2002: made _read() non-greedy - it now returns as soon as - * any amount of data has been read. It's the expected - * behavior for line-buffered streams (KJK::Hyperion) - */ - -#include - -#define NDEBUG -#include - -/* - * @implemented - */ -int _read(int _fd, void *_buf, unsigned int _nbyte) -{ - DWORD _rbyte = 0, nbyte = _nbyte; - char *bufp = (char*)_buf; - HANDLE hfile; - int istext, error; - - DPRINT("_read(fd %d, buf %x, nbyte %d)\n", _fd, _buf, _nbyte); - - /* null read */ - if(_nbyte == 0) - return 0; - - hfile = (HANDLE)_get_osfhandle(_fd); - istext = __fileno_getmode(_fd) & O_TEXT; - - /* read data */ - if (!ReadFile(hfile, bufp, nbyte, &_rbyte, NULL)) - { - /* failure */ - error = GetLastError(); - if (error == ERROR_BROKEN_PIPE) - { - return 0; - } - _dosmaperr(error); - return -1; - } - - /* text mode */ - if (_rbyte && istext) - { - int found_cr = 0; - int cr = 0; - DWORD count = _rbyte; - - /* repeat for all bytes in the buffer */ - for(; count; bufp++, count--) - { -#if 1 - /* carriage return */ - if (*bufp == '\r') { - found_cr = 1; - if (cr != 0) { - *(bufp - cr) = *bufp; - } - continue; - } - if (found_cr) { - found_cr = 0; - if (*bufp == '\n') { - cr++; - *(bufp - cr) = *bufp; - } else { - } - } else if (cr != 0) { - *(bufp - cr) = *bufp; - } -#else - /* carriage return */ - if (*bufp == '\r') { - cr++; - } - /* shift characters back, to ignore carriage returns */ - else if (cr != 0) { - *(bufp - cr) = *bufp; - } -#endif - } - if (found_cr) { - cr++; - } - /* ignore the carriage returns */ - _rbyte -= cr; - } - DPRINT("%d\n", _rbyte); - return _rbyte; -} diff --git a/reactos/lib/crt/io/setmode.c b/reactos/lib/crt/io/setmode.c deleted file mode 100644 index 2a0c5baad81..00000000000 --- a/reactos/lib/crt/io/setmode.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/setmode.c - * PURPOSE: Sets the file translation mode - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ -#include - -#define NDEBUG -#include - - diff --git a/reactos/lib/crt/io/sopen.c b/reactos/lib/crt/io/sopen.c deleted file mode 100644 index 22ed00dd6a6..00000000000 --- a/reactos/lib/crt/io/sopen.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include - -/* - * @implemented - */ -int _sopen(const char *path, int access, int shflag, ... /*mode, permissin*/) -{ - //FIXME: vararg - return _open((path), (access)|(shflag));//, (mode)); -} diff --git a/reactos/lib/crt/io/stubs.c b/reactos/lib/crt/io/stubs.c deleted file mode 100644 index aadc2411f4c..00000000000 --- a/reactos/lib/crt/io/stubs.c +++ /dev/null @@ -1 +0,0 @@ -void *__badioinfo; diff --git a/reactos/lib/crt/io/tell.c b/reactos/lib/crt/io/tell.c deleted file mode 100644 index 150e8933c9d..00000000000 --- a/reactos/lib/crt/io/tell.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -off_t _tell(int _file) -{ - return _lseek(_file, 0, SEEK_CUR); -} diff --git a/reactos/lib/crt/io/telli64.c b/reactos/lib/crt/io/telli64.c deleted file mode 100644 index 8cae825168e..00000000000 --- a/reactos/lib/crt/io/telli64.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include - -/* - * @implemented - */ -__int64 _telli64(int _file) -{ - return _lseeki64(_file, 0, SEEK_CUR); -} diff --git a/reactos/lib/crt/io/umask.c b/reactos/lib/crt/io/umask.c deleted file mode 100644 index 28a498ff1eb..00000000000 --- a/reactos/lib/crt/io/umask.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -unsigned _unMode_dll = 022; - -/* - * @implemented - */ -unsigned _umask (unsigned unMode) -{ - unsigned old_mask = _unMode_dll; - _unMode_dll = unMode; - return old_mask; -} diff --git a/reactos/lib/crt/io/unlink.c b/reactos/lib/crt/io/unlink.c deleted file mode 100644 index d1a9b64a205..00000000000 --- a/reactos/lib/crt/io/unlink.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/unlink.c - * PURPOSE: Deletes a file - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -int _unlink(const char* filename) -{ - DPRINT("_unlink('%s')\n", filename); - if (!DeleteFileA(filename)) { - _dosmaperr(GetLastError()); - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/io/utime.c b/reactos/lib/crt/io/utime.c deleted file mode 100644 index 214c55f44ac..00000000000 --- a/reactos/lib/crt/io/utime.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include -#include - -/* - * @implemented - */ -int _utime(const char* filename, struct _utimbuf* buf) -{ - int fn; - int ret; - - fn = _open(filename, _O_RDWR); - if (fn == -1) { - __set_errno(EBADF); - return -1; - } - ret = _futime(fn, buf); - if (_close(fn) < 0) - return -1; - return ret; -} diff --git a/reactos/lib/crt/io/waccess.c b/reactos/lib/crt/io/waccess.c deleted file mode 100644 index 0ad50babfe8..00000000000 --- a/reactos/lib/crt/io/waccess.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "access.c" diff --git a/reactos/lib/crt/io/wchmod.c b/reactos/lib/crt/io/wchmod.c deleted file mode 100644 index 1a81c9e2a41..00000000000 --- a/reactos/lib/crt/io/wchmod.c +++ /dev/null @@ -1,4 +0,0 @@ -#define _UNICODE -#define UNICODE - -#include "chmod.c" diff --git a/reactos/lib/crt/io/wcreate.c b/reactos/lib/crt/io/wcreate.c deleted file mode 100644 index c4f7e5cc0cf..00000000000 --- a/reactos/lib/crt/io/wcreate.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -int _wcreat(const wchar_t* filename, int mode) -{ - DPRINT("_wcreat('%S', mode %x)\n", filename, mode); - return _wopen(filename,_O_CREAT|_O_TRUNC,mode); -} diff --git a/reactos/lib/crt/io/wfind.c b/reactos/lib/crt/io/wfind.c deleted file mode 100644 index 76c568f6c0e..00000000000 --- a/reactos/lib/crt/io/wfind.c +++ /dev/null @@ -1,5 +0,0 @@ - -#define UNICODE -#define _UNICODE - -#include "find.c" diff --git a/reactos/lib/crt/io/wmktemp.c b/reactos/lib/crt/io/wmktemp.c deleted file mode 100644 index 79b71b8f5c0..00000000000 --- a/reactos/lib/crt/io/wmktemp.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/mktemp.c - * PURPOSE: Makes a temp file based on a template - * PROGRAMER: DJ Delorie - Ariadne - * UPDATE HISTORY: - * 28/12/98: Appropriated for the Reactos Kernel - */ - -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -wchar_t* _wmktemp (wchar_t *_template) -{ - static int count = 0; - wchar_t *cp, *dp; - int i, len, xcount, loopcnt; - - DPRINT("_wmktemp('%S')\n", _template); - len = wcslen (_template); - cp = _template + len; - - xcount = 0; - while (xcount < 6 && cp > _template && cp[-1] == L'X') - xcount++, cp--; - - if (xcount) { - dp = cp; - while (dp > _template && dp[-1] != L'/' && dp[-1] != L'\\' && dp[-1] != L':') - dp--; - - /* Keep the first characters of the template, but turn the rest into - Xs. */ - while (cp > dp + 8 - xcount) { - *--cp = L'X'; - xcount = (xcount >= 6) ? 6 : 1 + xcount; - } - - /* If dots occur too early -- squash them. */ - while (dp < cp) { - if (*dp == L'.') *dp = L'a'; - dp++; - } - - /* Try to add ".tmp" to the filename. Truncate unused Xs. */ - if (cp + xcount + 3 < _template + len) - wcscpy (cp + xcount, L".tmp"); - else - cp[xcount] = 0; - - /* This loop can run up to 2<<(5*6) times, or about 10^9 times. */ - for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) { - int c = count++; - for (i = 0; i < xcount; i++, c >>= 5) - cp[i] = L"abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f]; - if (_waccess(_template,0) == -1) - return _template; - } - } - - /* Failure: truncate the template and return NULL. */ - *_template = 0; - return 0; -} diff --git a/reactos/lib/crt/io/wopen.c b/reactos/lib/crt/io/wopen.c deleted file mode 100644 index 32f9dc9d09b..00000000000 --- a/reactos/lib/crt/io/wopen.c +++ /dev/null @@ -1,143 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/open.c - * PURPOSE: Opens a file and translates handles to fileno - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -// rember to interlock the allocation of fileno when making this thread safe -// possibly store extra information at the handle - -#include -#if !defined(NDEBUG) && defined(DBG) -#include -#endif -#include -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -int _wopen(const wchar_t* _path, int _oflag, ...) -{ -#if !defined(NDEBUG) && defined(DBG) - va_list arg; - int pmode; -#endif - HANDLE hFile; - DWORD dwDesiredAccess = 0; - DWORD dwShareMode = 0; - DWORD dwCreationDistribution = 0; - DWORD dwFlagsAndAttributes = 0; - SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; - -#if !defined(NDEBUG) && defined(DBG) - va_start(arg, _oflag); - pmode = va_arg(arg, int); -#endif - -// DPRINT("_wopen('%S', %x, (%x))\n", _path, _oflag, pmode); - - if ((_oflag & S_IREAD) == S_IREAD) - dwShareMode = FILE_SHARE_READ; - else if ( ( _oflag & S_IWRITE) == S_IWRITE) { - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - } - - /* - * - * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.) - * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.) - * - * _O_APPEND Moves file pointer to end of file before every write operation. - */ -#if 0 - if ((_oflag & _O_RDWR) == _O_RDWR) - dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA | - FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | - FILE_WRITE_ATTRIBUTES; - else if ((_oflag & O_RDONLY) == O_RDONLY) - dwDesiredAccess |= GENERIC_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | - FILE_WRITE_ATTRIBUTES; - else if ((_oflag & _O_WRONLY) == _O_WRONLY) - dwDesiredAccess |= GENERIC_WRITE | FILE_WRITE_DATA | - FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES; -#else - if ((_oflag & _O_WRONLY) == _O_WRONLY) - dwDesiredAccess |= GENERIC_WRITE | FILE_WRITE_DATA | - FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES; - else if ((_oflag & _O_RDWR) == _O_RDWR) - dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA | - FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | - FILE_WRITE_ATTRIBUTES; - else //if ((_oflag & O_RDONLY) == O_RDONLY) - dwDesiredAccess |= GENERIC_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | - FILE_WRITE_ATTRIBUTES; -#endif - - if ((_oflag & S_IREAD) == S_IREAD) - dwShareMode |= FILE_SHARE_READ; - - if ((_oflag & S_IWRITE) == S_IWRITE) - dwShareMode |= FILE_SHARE_WRITE; - - if ((_oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) - dwCreationDistribution |= CREATE_NEW; - - else if ((_oflag & O_TRUNC) == O_TRUNC) { - if ((_oflag & O_CREAT) == O_CREAT) - dwCreationDistribution |= CREATE_ALWAYS; - else if ((_oflag & O_RDONLY) != O_RDONLY) - dwCreationDistribution |= TRUNCATE_EXISTING; - } - else if ((_oflag & _O_APPEND) == _O_APPEND) - dwCreationDistribution |= OPEN_EXISTING; - else if ((_oflag & _O_CREAT) == _O_CREAT) - dwCreationDistribution |= OPEN_ALWAYS; - else - dwCreationDistribution |= OPEN_EXISTING; - - if ((_oflag & _O_RANDOM) == _O_RANDOM) - dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS; - if ((_oflag & _O_SEQUENTIAL) == _O_SEQUENTIAL) - dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN; - - if ((_oflag & _O_TEMPORARY) == _O_TEMPORARY) - dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; - - if ((_oflag & _O_SHORT_LIVED) == _O_SHORT_LIVED) - dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; - - if (_oflag & _O_NOINHERIT) - sa.bInheritHandle = FALSE; - - hFile = CreateFileW(_path, - dwDesiredAccess, - dwShareMode, - &sa, - dwCreationDistribution, - dwFlagsAndAttributes, - NULL); - if (hFile == (HANDLE)-1) { - _dosmaperr(GetLastError()); - return -1; - } - return alloc_fd(hFile,split_oflags(_oflag)); -} - -/* - * @implemented - */ -int _wsopen(const wchar_t* path, int access, int shflag,.../* int 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 deleted file mode 100644 index 49f7d94b93b..00000000000 --- a/reactos/lib/crt/io/write.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/write.c - * PURPOSE: Writes to a file - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -#define NDEBUG -#include - -#define BUFSIZE 4096 -/* -void ReportLastError(void) -{ - DWORD error = GetLastError(); - if (error != ERROR_SUCCESS) { - PTSTR msg; - if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, - 0, error, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (PTSTR)&msg, 0, NULL)) { - printf("ReportLastError() %d - %s\n", error, msg); - } else { - printf("ReportLastError() %d - unknown error\n", error); - } - LocalFree(msg); - } -} - */ -/* - * @implemented - */ -int _write(int _fd, const void* _buf, unsigned int _nbyte) -{ - char *tmp, *in, *out; - int result; - unsigned int count; - DWORD wbyte; - - DPRINT("_write(fd %d, buf %x, nbyte %d)\n", _fd, _buf, _nbyte); - if (__fileno_getmode(_fd) & O_TEXT) { - result = _nbyte; - tmp = (char*) malloc(BUFSIZE); - if (tmp == NULL) { - __set_errno(ENOMEM); - return -1; - } - count = BUFSIZE; - out = tmp; - in = (char*) _buf; - while (_nbyte--) { - if (*in == 0x0a) { - *out++ = 0x0d; - count--; - if (count == 0) { - if (!WriteFile((HANDLE)_get_osfhandle(_fd), tmp, BUFSIZE, &wbyte, NULL)) { - //ReportLastError(); - _dosmaperr(GetLastError()); - result = -1; - break; - } - if (wbyte < BUFSIZE) { - result = in - (char*)_buf; - break; - } - count = BUFSIZE; - out = tmp; - } - } - *out++ = *in++; - count--; - if (count == 0 || _nbyte == 0) { - if (!WriteFile((HANDLE)_get_osfhandle(_fd), tmp, BUFSIZE - count, &wbyte, NULL)) { - _dosmaperr(GetLastError()); - result = -1; - break; - } - if (wbyte < (BUFSIZE - count)) { - result = in - (char*)_buf; - break; - } - count = BUFSIZE; - out = tmp; - } - } - free(tmp); - return result; - } else { - if(!WriteFile((HANDLE)_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL)) { - _dosmaperr(GetLastError()); - return -1; - } - return wbyte; - } -} diff --git a/reactos/lib/crt/io/wunlink.c b/reactos/lib/crt/io/wunlink.c deleted file mode 100644 index d8a5d1f5708..00000000000 --- a/reactos/lib/crt/io/wunlink.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/io/unlink.c - * PURPOSE: Deletes a file - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -#define NDEBUG -#include - -/* - * @implemented - */ -int _wunlink(const wchar_t* filename) -{ - DPRINT("_wunlink('%S')\n", filename); - if (!DeleteFileW(filename)) { - _dosmaperr(GetLastError()); - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/io/wutime.c b/reactos/lib/crt/io/wutime.c deleted file mode 100644 index 8de7492d32b..00000000000 --- a/reactos/lib/crt/io/wutime.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include -#include - -/* - * @implemented - */ -int _wutime(const wchar_t* filename, struct _utimbuf* buf) -{ - int fn; - int ret; - - fn = _wopen(filename, _O_RDWR); - if (fn == -1) { - __set_errno(EBADF); - return -1; - } - ret = _futime(fn, buf); - if (_close(fn) < 0) - return -1; - return ret; -} - diff --git a/reactos/lib/crt/locale/locale.c b/reactos/lib/crt/locale/locale.c deleted file mode 100644 index 253fcfc4c65..00000000000 --- a/reactos/lib/crt/locale/locale.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Some stuff takem from wine msvcrt\locale.c - * - * Copyright 2000 Jon Griffiths - */ - -#include -#include -#include - -#define NDEBUG -#include - -unsigned int __setlc_active; -unsigned int __unguarded_readlc_active; -int _current_category; /* used by setlocale */ -const char *_current_locale; - -int parse_locale(const char *locale, char *lang, char *country, char *code_page); - -/* - * @unimplemented - */ -char *setlocale(int category, const char *locale) -{ - char lang[100]; - char country[100]; - char code_page[100]; - if (NULL != locale) { - parse_locale(locale,lang,country,code_page); - } - - //printf("%s %s %s %s\n",locale,lang,country,code_page); - - - switch ( category ) - { - case LC_COLLATE: - break; - case LC_CTYPE: - break; - case LC_MONETARY: - break; - case LC_NUMERIC: - break; - case LC_TIME: - break; - case LC_ALL: - break; - default: - break; - } - - return "C"; - -} - -/* - -locale "lang[_country[.code_page]]" - | ".code_page" - | "" - | NULL - -*/ -int parse_locale(const char *locale, char *lang, char *country, char *code_page) -{ - while ( *locale != 0 && *locale != '.' && *locale != '_' ) - { - *lang = *locale; - lang++; - locale++; - } - *lang = 0; - if ( *locale == '_' ) { - locale++; - while ( *locale != 0 && *locale != '.' ) - { - *country = *locale; - country++; - locale++; - } - } - *country = 0; - - - if ( *locale == '.' ) { - locale++; - while ( *locale != 0 && *locale != '.' ) - { - *code_page = *locale; - code_page++; - locale++; - } - } - - *code_page = 0; - return 0; -} - -const struct map_lcid2str { - short langid; - const char *langname; - const char *country; -} languages[]={ - {0x0409,"English", "United States"}, - {0x0809,"English", "United Kingdom"}, - {0x0000,"Unknown", "Unknown"} - -}; - -const struct map_cntr { - const char *abrev; - const char *country; -} abrev[] = { - {"britain", "united kingdom"}, - {"england", "united kingdom"}, - {"gbr", "united kingdom"}, - {"great britain", "united kingdom"}, - {"uk", "united kingdom"}, - {"united kingdom", "united kingdom"}, - {"united-kingdom", "united kingdom"}, - {"america", "united states" }, - {"united states", "united states"}, - {"united-states", "united states"}, - {"us", "united states"}, - {"usa" "united states"} -}; - - -struct lconv _lconv = { -".", // decimal_point -",", // thousands_sep -"", // grouping; -"DOL", // int_curr_symbol -"$", // currency_symbol -".", // mon_decimal_point -",", // mon_thousands_sep -"", // mon_grouping; -"+", // positive_sign -"-", // negative_sign -127, // int_frac_digits -127, // frac_digits -127, // p_cs_precedes -127, // p_sep_by_space -127, // n_cs_precedes -127, // n_sep_by_space -127, // p_sign_posn; -127 // n_sign_posn; -}; - -/* - * @implemented - */ -struct lconv *localeconv(void) -{ - return (struct lconv *) &_lconv; -} - -/********************************************************************* - * _setmbcp (MSVCRT.@) - * - * @unimplemented - */ -void _setmbcp(int cp) -{ -DPRINT1("_setmbcp - stub\n"); -return; -} - - -/********************************************************************* - * __lc_collate_cp (MSVCRT.@) - * - * @unimplemented - */ -void __lc_collate_cp(int cp) -{ -DPRINT1("__lc_collate_cp - stub\n"); -return; -} - - -/********************************************************************* - * __lc_handle (MSVCRT.@) - * - * @unimplemented - */ -void __lc_handle(void) -{ -DPRINT1("__lc_handle - stub\n"); -return; -} - - -/********************************************************************* - * __lc_codepage (MSVCRT.@) - * - * @unimplemented - */ -void __lc_codepage(void) -{ -DPRINT1("__lc_codepage - stub\n"); -return; -} - - -/********************************************************************* - * _Gettnames (MSVCRT.@) - */ -void *_Gettnames(void) -{ - DPRINT1("(void), stub!\n"); - return NULL; -} - -/********************************************************************* - * __lconv_init (MSVCRT.@) - */ -void __lconv_init(void) -{ - DPRINT1(" stub\n"); -} - - -/********************************************************************* - * _Strftime (MSVCRT.@) - */ -const char* _Strftime(char *out, unsigned int len, const char *fmt, - const void *tm, void *foo) -{ - /* FIXME: */ - DPRINT1("(%p %d %s %p %p) stub\n", out, len, fmt, tm, foo); - return ""; -} - - -/********************************************************************* - * _Getdays (MSVCRT.@) - */ -const char* _Getdays(void) -{ - static const char *MSVCRT_days = ":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:" - "Wednesday:Thu:Thursday:Fri:Friday:Sat:Saturday"; - /* FIXME: Use locale */ - DPRINT1("(void) semi-stub\n"); - return MSVCRT_days; -} - -/********************************************************************* - * _Getmonths (MSVCRT.@) - */ -const char* _Getmonths(void) -{ - static const char *MSVCRT_months = ":Jan:January:Feb:February:Mar:March:Apr:" - "April:May:May:Jun:June:Jul:July:Aug:August:Sep:September:Oct:" - "October:Nov:November:Dec:December"; - /* FIXME: Use locale */ - DPRINT1("(void) semi-stub\n"); - return MSVCRT_months; -} - -/********************************************************************* - * __crtLCMapStringA (MSVCRT.@) - */ -int __crtLCMapStringA( - LCID lcid, DWORD mapflags, const char* src, int srclen, char* dst, - int dstlen, unsigned int codepage, int xflag -) { - DPRINT1("(lcid %lx, flags %lx, %s(%d), %p(%d), %x, %d), partial stub!\n", - lcid,mapflags,src,srclen,dst,dstlen,codepage,xflag); - /* FIXME: A bit incorrect. But msvcrt itself just converts its - * arguments to wide strings and then calls LCMapStringW - */ - return LCMapStringA(lcid,mapflags,src,srclen,dst,dstlen); -} diff --git a/reactos/lib/crt/math/acos.c b/reactos/lib/crt/math/acos.c deleted file mode 100644 index ea25c1cabec..00000000000 --- a/reactos/lib/crt/math/acos.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Math functions for i387. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by John C. Bowman , 1995. - - 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 - - -double acos(double __x) -{ - return atan2(sqrt(1.0 - __x * __x), __x); -} diff --git a/reactos/lib/crt/math/adjust.c b/reactos/lib/crt/math/adjust.c deleted file mode 100644 index f27c82511de..00000000000 --- a/reactos/lib/crt/math/adjust.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $Id$ - * - */ - -int _adjust_fdiv = 0; - -/* EOF */ diff --git a/reactos/lib/crt/math/asin.c b/reactos/lib/crt/math/asin.c deleted file mode 100644 index 5a64723ba38..00000000000 --- a/reactos/lib/crt/math/asin.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Math functions for i387. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by John C. Bowman , 1995. - - 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 - - -double asin(double __x) -{ - return atan2(__x, sqrt(1.0 - __x * __x)); -} diff --git a/reactos/lib/crt/math/cabs.c b/reactos/lib/crt/math/cabs.c deleted file mode 100644 index 04a0bc578bc..00000000000 --- a/reactos/lib/crt/math/cabs.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -/* - * @implemented - */ -double _cabs( struct _complex z ) -{ - return sqrt( z.x*z.x + z.y*z.y ); -// return hypot(z.x,z.y); -} - - - - diff --git a/reactos/lib/crt/math/cosh.c b/reactos/lib/crt/math/cosh.c deleted file mode 100644 index e81fde563f8..00000000000 --- a/reactos/lib/crt/math/cosh.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - - -/* - * @implemented - */ -double cosh(double x) -{ - const double ebig = exp(fabs(x)); - return (ebig + 1.0/ebig) / 2.0; -} diff --git a/reactos/lib/crt/math/frexp.c b/reactos/lib/crt/math/frexp.c deleted file mode 100644 index 913cc5c7271..00000000000 --- a/reactos/lib/crt/math/frexp.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -double -frexp(double __x, int *exptr) -{ - union - { - double* __x; - double_t* x; - } x; - - x.__x = &__x; - - if ( exptr != NULL ) - *exptr = x.x->exponent - 0x3FE; - - - x.x->exponent = 0x3FE; - - return __x; -} - - - diff --git a/reactos/lib/crt/math/huge_val.c b/reactos/lib/crt/math/huge_val.c deleted file mode 100644 index 66b5716bf80..00000000000 --- a/reactos/lib/crt/math/huge_val.c +++ /dev/null @@ -1,6 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#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 deleted file mode 100644 index 7004d8a5645..00000000000 --- a/reactos/lib/crt/math/hypot.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* - * hypot() function for DJGPP. - * - * hypot() computes sqrt(x^2 + y^2). The problem with the obvious - * naive implementation is that it might fail for very large or - * very small arguments. For instance, for large x or y the result - * might overflow even if the value of the function should not, - * because squaring a large number might trigger an overflow. For - * very small numbers, their square might underflow and will be - * silently replaced by zero; this won't cause an exception, but might - * have an adverse effect on the accuracy of the result. - * - * This implementation tries to avoid the above pitfals, without - * inflicting too much of a performance hit. - * - */ -#include - -/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers - between these two shouldn't neither overflow nor underflow - when squared. */ -#define __SQRT_DBL_MAX 1.3e+154 -#define __SQRT_DBL_MIN 2.3e-162 - -/* - * @implemented - */ -double -_hypot(double x, double y) -{ - double abig = fabs(x), asmall = fabs(y); - double ratio; - - /* Make abig = max(|x|, |y|), asmall = min(|x|, |y|). */ - if (abig < asmall) - { - double temp = abig; - - abig = asmall; - asmall = temp; - } - - /* Trivial case. */ - if (asmall == 0.) - return abig; - - /* Scale the numbers as much as possible by using its ratio. - For example, if both ABIG and ASMALL are VERY small, then - X^2 + Y^2 might be VERY inaccurate due to loss of - significant digits. Dividing ASMALL by ABIG scales them - to a certain degree, so that accuracy is better. */ - - if ((ratio = asmall / abig) > __SQRT_DBL_MIN && abig < __SQRT_DBL_MAX) - return abig * sqrt(1.0 + ratio*ratio); - else - { - /* Slower but safer algorithm due to Moler and Morrison. Never - produces any intermediate result greater than roughly the - larger of X and Y. Should converge to machine-precision - accuracy in 3 iterations. */ - - double r = ratio*ratio, t, s, p = abig, q = asmall; - - do { - t = 4. + r; - if (t == 4.) - break; - s = r / t; - p += 2. * s * p; - q *= s; - r = (q / p) * (q / p); - } while (1); - - return p; - } -} - -#ifdef TEST - -#include - -int -main(void) -{ - printf("hypot(3, 4) =\t\t\t %25.17e\n", _hypot(3., 4.)); - printf("hypot(3*10^150, 4*10^150) =\t %25.17g\n", _hypot(3.e+150, 4.e+150)); - printf("hypot(3*10^306, 4*10^306) =\t %25.17g\n", _hypot(3.e+306, 4.e+306)); - printf("hypot(3*10^-320, 4*10^-320) =\t %25.17g\n",_hypot(3.e-320, 4.e-320)); - printf("hypot(0.7*DBL_MAX, 0.7*DBL_MAX) =%25.17g\n",_hypot(0.7*DBL_MAX, 0.7*DBL_MAX)); - printf("hypot(DBL_MAX, 1.0) =\t\t %25.17g\n", _hypot(DBL_MAX, 1.0)); - printf("hypot(1.0, DBL_MAX) =\t\t %25.17g\n", _hypot(1.0, DBL_MAX)); - printf("hypot(0.0, DBL_MAX) =\t\t %25.17g\n", _hypot(0.0, DBL_MAX)); - - return 0; -} - -#endif diff --git a/reactos/lib/crt/math/i386/.gitignore b/reactos/lib/crt/math/i386/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/reactos/lib/crt/math/i386/atan2.c b/reactos/lib/crt/math/i386/atan2.c deleted file mode 100644 index 0fc14db4bf6..00000000000 --- a/reactos/lib/crt/math/i386/atan2.c +++ /dev/null @@ -1,21 +0,0 @@ - -#include - -double atan2 (double __y, double __x); - -/* - * @implemented - */ -double atan2 (double __y, double __x) -{ - register double __val; -#ifdef __GNUC__ - __asm __volatile__ - ("fpatan\n\t" - "fld %%st(0)" - : "=t" (__val) : "0" (__x), "u" (__y)); -#else - __val = linkme_atan2(__x, __y); -#endif /*__GNUC__*/ - return __val; -} diff --git a/reactos/lib/crt/math/i386/atan_asm.s b/reactos/lib/crt/math/i386/atan_asm.s deleted file mode 100644 index 6b21e2d49da..00000000000 --- a/reactos/lib/crt/math/i386/atan_asm.s +++ /dev/null @@ -1,22 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * PURPOSE: - * FILE: - * PROGRAMER: Magnus Olsen (magnus@greatlord.com) - * - */ - -.globl _atan - -.intel_syntax noprefix - -/* FUNCTIONS ***************************************************************/ - -_atan: - push ebp - mov ebp,esp - fld qword ptr [ebp+8] - fpatan - pop ebp - ret diff --git a/reactos/lib/crt/math/i386/exp.c b/reactos/lib/crt/math/i386/exp.c deleted file mode 100644 index 3a58be07ad8..00000000000 --- a/reactos/lib/crt/math/i386/exp.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Math functions for i387. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by John C. Bowman , 1995. - - 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 - -double exp (double __x); - -double exp (double __x) -{ -#ifdef __GNUC__ - register double __value, __exponent; - __asm __volatile__ - ("fldl2e # e^x = 2^(x * log2(e))\n\t" - "fmul %%st(1) # x * log2(e)\n\t" - "fst %%st(1)\n\t" - "frndint # int(x * log2(e))\n\t" - "fxch\n\t" - "fsub %%st(1) # fract(x * log2(e))\n\t" - "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" - : "=t" (__value), "=u" (__exponent) : "0" (__x)); - __value += 1.0; - __asm __volatile__ - ("fscale" - : "=t" (__value) : "0" (__value), "u" (__exponent)); - - return __value; -#else - return linkme_exp(__x); -#endif /*__GNUC__*/ -} diff --git a/reactos/lib/crt/math/i386/fmod.c b/reactos/lib/crt/math/i386/fmod.c deleted file mode 100644 index 7a1f0cef180..00000000000 --- a/reactos/lib/crt/math/i386/fmod.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Math functions for i387. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by John C. Bowman , 1995. - - 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 - -double fmod (double __x, double __y); - -double fmod (double __x, double __y) -{ - register double __val; -#ifdef __GNUC__ - __asm __volatile__ - ("1: fprem\n\t" - "fstsw %%ax\n\t" - "sahf\n\t" - "jp 1b" - : "=t" (__val) : "0" (__x), "u" (__y) : "ax", "cc"); -#else - __val = linkme_fmod(__x, __y); -#endif /*__GNUC__*/ - return __val; -} diff --git a/reactos/lib/crt/math/i386/ldexp.c b/reactos/lib/crt/math/i386/ldexp.c deleted file mode 100644 index 82175052d33..00000000000 --- a/reactos/lib/crt/math/i386/ldexp.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Math functions for i387. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by John C. Bowman , 1995. - - 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 - -double ldexp (double __x, int __y); - -double ldexp (double __x, int __y) -{ - register double __val; -#ifdef __GNUC__ - __asm __volatile__ - ("fscale" - : "=t" (__val) : "0" (__x), "u" ((double) __y)); -#else - __val = linkme_ldexp(__x, __y); -#endif /*__GNUC__*/ - return __val; -} diff --git a/reactos/lib/crt/math/i386/log10_asm.s b/reactos/lib/crt/math/i386/log10_asm.s deleted file mode 100644 index 6179f6221a2..00000000000 --- a/reactos/lib/crt/math/i386/log10_asm.s +++ /dev/null @@ -1,25 +0,0 @@ - - /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * PURPOSE: - * FILE: - * PROGRAMER: Magnus Olsen (magnus@greatlord.com) - * - */ - -.globl _log10 - -.intel_syntax noprefix - -/* FUNCTIONS ***************************************************************/ - -_log10: - push ebp - mov ebp,esp - fld qword ptr [ebp+8] - fldlg2 - fyl2x - pop ebp - ret - diff --git a/reactos/lib/crt/math/i386/pow_asm.s b/reactos/lib/crt/math/i386/pow_asm.s deleted file mode 100644 index 05eb36b9205..00000000000 --- a/reactos/lib/crt/math/i386/pow_asm.s +++ /dev/null @@ -1,140 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * PURPOSE: Run-Time Library - * FILE: lib/rtl/i386/pow.S - * PROGRAMER: Alex Ionescu (alex@relsoft.net) - * Eric Kohl (ekohl@rz-online.de) - * - * Copyright (C) 2002 Michael Ringgaard. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -.globl _pow - - /* DATA ********************************************************************/ - -fzero: - .long 0 // Floating point zero - .long 0 // Floating point zero - -.intel_syntax noprefix - -/* FUNCTIONS ***************************************************************/ - -_pow: - push ebp - mov ebp,esp - sub esp,12 // Allocate temporary space - push edi // Save register edi - push eax // Save register eax - mov dword ptr [ebp-12],0 // Set negation flag to zero - fld qword ptr [ebp+16] // Load real from stack - fld qword ptr [ebp+8] // Load real from stack - mov edi,offset flat:fzero // Point to real zero - fcom qword ptr [edi] // Compare x with zero - fstsw ax // Get the FPU status word - mov al,ah // Move condition flags to AL - lahf // Load Flags into AH - and al, 0b01000101 // Isolate C0, C2 and C3 - and ah, 0b10111010 // Turn off CF, PF and ZF - or ah,al // Set new CF, PF and ZF - sahf // Store AH into Flags - jb __fpow1 // Re-direct if x < 0 - ja __fpow3 // Re-direct if x > 0 - fxch // Swap st, st(1) - fcom qword ptr [edi] // Compare y with zero - fxch // Restore x as top of stack - fstsw ax // Get the FPU status word - mov al,ah // Move condition flags to AL - lahf // Load Flags into AH - and al, 0b01000101 // Isolate C0, C2 and C3 - and ah, 0b10111010 // Turn off CF, PF and ZF - or ah,al // Set new CF, PF and ZF - sahf // Store AH into Flags - ja __fpow3 // Re-direct if y > 0 - fstp st(1) // Set new stack top and pop - mov eax,1 // Set domain error (EDOM) - jmp __fpow5 // End of case -__fpow1: fxch // Put y on top of stack - fld st // Duplicate y as st(1) - frndint // Round to integer - fxch // Put y on top of stack - fcomp // y = int(y) ? - fstsw ax // Get the FPU status word - mov al,ah // Move condition flags to AL - lahf // Load Flags into AH - and al, 0b01000101 // Isolate C0, C2 and C3 - and ah, 0b10111010 // Turn off CF, PF and ZF - or ah,al // Set new CF, PF and ZF - sahf // Store AH into Flags - je __fpow2 // Proceed if y = int(y) - fstp st(1) // Set new stack top and pop - fldz // Set result to zero - fstp st(1) // Set new stack top and pop - mov eax,1 // Set domain error (EDOM) - jmp __fpow5 // End of case -__fpow2: fist dword ptr [ebp-12] // Store y as integer - and dword ptr [ebp-12],1 // Set bit if y is odd - fxch // Put x on top of stack - fabs // x = |x| -__fpow3: fldln2 // Load log base e of 2 - fxch st(1) // Exchange st, st(1) - fyl2x // Compute the natural log(x) - fmulp // Compute y * ln(x) - fldl2e // Load log base 2(e) - fmulp st(1),st // Multiply x * log base 2(e) - fst st(1) // Push result - frndint // Round to integer - fsub st(1),st // Subtract - fxch // Exchange st, st(1) - f2xm1 // Compute 2 to the (x - 1) - fld1 // Load real number 1 - faddp // 2 to the x - fscale // Scale by power of 2 - fstp st(1) // Set new stack top and pop - test dword ptr [ebp-12],1 // Negation required ? - jz __fpow4 // No, re-direct - fchs // Negate the result -__fpow4: fstp qword ptr [ebp-8] // Save (double)pow(x, y) - fld qword ptr [ebp-8] // Load (double)pow(x, y) - fxam // Examine st - fstsw ax // Get the FPU status word - cmp ah,5 // Infinity ? - jne __fpow6 // No, end of case - mov eax,2 // Set range error (ERANGE) - // Get errno pointer offset -__fpow5: int 3 - mov edi,0 // TODO: offset flat:__crt_errno - mov edi,[edi] // Get C errno variable pointer - mov dword ptr [edi],eax // Set errno -__fpow6: pop eax // Restore register eax - pop edi // Restore register edi - mov esp,ebp // Deallocate temporary space - pop ebp - ret diff --git a/reactos/lib/crt/math/j0_y0.c b/reactos/lib/crt/math/j0_y0.c deleted file mode 100644 index 32f198480ac..00000000000 --- a/reactos/lib/crt/math/j0_y0.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - - -/* - * @unimplemented - */ -double _j0(double x) -{ - return x; -} - -/* - * @unimplemented - */ -double _y0(double x) -{ - return x; -} diff --git a/reactos/lib/crt/math/j1_y1.c b/reactos/lib/crt/math/j1_y1.c deleted file mode 100644 index c345f7d00c5..00000000000 --- a/reactos/lib/crt/math/j1_y1.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - - -/* - * @unimplemented - */ -double _j1(double x) -{ - return x; -} - -/* - * @unimplemented - */ -double _y1(double x) -{ - return x; -} diff --git a/reactos/lib/crt/math/jn_yn.c b/reactos/lib/crt/math/jn_yn.c deleted file mode 100644 index 583826a1951..00000000000 --- a/reactos/lib/crt/math/jn_yn.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - - -/* - * @unimplemented - */ -double _jn(int n, double x) -{ - return x; -} - -/* - * @unimplemented - */ -double _yn(int n, double x) -{ - return x; -} diff --git a/reactos/lib/crt/math/modf.c b/reactos/lib/crt/math/modf.c deleted file mode 100644 index 72b937c36d5..00000000000 --- a/reactos/lib/crt/math/modf.c +++ /dev/null @@ -1,86 +0,0 @@ -/* @(#)s_modf.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include - -//static const double one = 1.0; - - - -long double modfl(long double __x, long double *__i) -{ - union - { - long double* __x; - long_double_t* x; - } x; - union - { - long double* __i; - long_double_t* iptr; - } iptr; - - int j0; - unsigned int i; - - x.__x = &__x; - iptr.__i = __i; - - - j0 = x.x->exponent - 0x3fff; /* exponent of x */ - - if(j0<32) { /* integer part in high x */ - if(j0<0) { /* |x|<1 */ - *__i = 0.0L; - iptr.iptr->sign = x.x->sign; - return __x; - } else { - - i = ((unsigned int)(0xffffffff))>>(j0+1); - if ( x.x->mantissal == 0 && (x.x->mantissal & i) == 0 ) { - *__i = __x; - __x = 0.0L; - x.x->sign = iptr.iptr->sign; - return __x; - } - iptr.iptr->sign = x.x->sign; - iptr.iptr->exponent = x.x->exponent; - iptr.iptr->mantissah = x.x->mantissah&((~i)); - iptr.iptr->mantissal = 0; - - return __x - *__i; - } - } else if (j0>63) { /* no fraction part */ - *__i = __x; - if ( _isnanl(__x) || _isinfl(__x) ) - return __x; - - __x = 0.0L; - x.x->sign = iptr.iptr->sign; - return __x; - } else { /* fraction part in low x */ - - i = ((unsigned int)(0xffffffff))>>(j0-32); - if ( x.x->mantissal == 0 ) { - *__i = __x; - __x = 0.0L; - x.x->sign = iptr.iptr->sign; - return __x; - } - iptr.iptr->sign = x.x->sign; - iptr.iptr->exponent = x.x->exponent; - iptr.iptr->mantissah = x.x->mantissah; - iptr.iptr->mantissal = x.x->mantissal&(~i); - - return __x - *__i; - } -} diff --git a/reactos/lib/crt/math/pow_asm.c b/reactos/lib/crt/math/pow_asm.c deleted file mode 100644 index 4f8ba9b0c3b..00000000000 --- a/reactos/lib/crt/math/pow_asm.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Math functions for i387. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by John C. Bowman , 1995. - - 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 - -/* - * @implemented - */ - -long double powl (long double __x,long double __y) -{ - return pow(__x,__y/2)*pow(__x,__y/2); -} diff --git a/reactos/lib/crt/math/s_modf.c b/reactos/lib/crt/math/s_modf.c deleted file mode 100644 index 12decacec7b..00000000000 --- a/reactos/lib/crt/math/s_modf.c +++ /dev/null @@ -1,194 +0,0 @@ - - -/* @(#)s_modf.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION - <>, <>---split fractional and integer parts - -INDEX - modf -INDEX - modff - -ANSI_SYNOPSIS - #include - double modf(double <[val]>, double *<[ipart]>); - float modff(float <[val]>, float *<[ipart]>); - -TRAD_SYNOPSIS - #include - double modf(<[val]>, <[ipart]>) - double <[val]>; - double *<[ipart]>; - - float modff(<[val]>, <[ipart]>) - float <[val]>; - float *<[ipart]>; - -DESCRIPTION - <> splits the double <[val]> apart into an integer part - and a fractional part, returning the fractional part and - storing the integer part in <<*<[ipart]>>>. No rounding - whatsoever is done; the sum of the integer and fractional - parts is guaranteed to be exactly equal to <[val]>. That - is, if . <[realpart]> = modf(<[val]>, &<[intpart]>); then - `<<<[realpart]>+<[intpart]>>>' is the same as <[val]>. - <> is identical, save that it takes and returns - <> rather than <> values. - -RETURNS - The fractional part is returned. Each result has the same - sign as the supplied argument <[val]>. - -PORTABILITY - <> is ANSI C. <> is an extension. - -QUICKREF - modf ansi pure - modff - pure - -*/ - -/* - * modf(double x, double *iptr) - * return fraction part of x, and return x's integral part in *iptr. - * Method: - * Bit twiddling. - * - * Exception: - * No exception. - */ - - -static const double one = 1.0; - -#define __int32_t long -#define __uint32_t unsigned long -#define __IEEE_LITTLE_ENDIAN - -#ifdef __IEEE_BIG_ENDIAN - -typedef union -{ - struct - { - __uint32_t msw; - __uint32_t lsw; - } parts; - double value; -} ieee_double_shape_type; - -#endif - -#ifdef __IEEE_LITTLE_ENDIAN - -typedef union -{ - struct - { - __uint32_t lsw; - __uint32_t msw; - } parts; - double value; -} ieee_double_shape_type; - -#endif - - -/* Get two 32 bit ints from a double. */ - -#define EXTRACT_WORDS(ix0,ix1,d) \ -do { \ - ieee_double_shape_type ew_u; \ - ew_u.value = (d); \ - (ix0) = ew_u.parts.msw; \ - (ix1) = ew_u.parts.lsw; \ -} while (0) - -/* Get the more significant 32 bit int from a double. */ - -#define GET_HIGH_WORD(i,d) \ -do { \ - ieee_double_shape_type gh_u; \ - gh_u.value = (d); \ - (i) = gh_u.parts.msw; \ -} while (0) - -/* Get the less significant 32 bit int from a double. */ - -#define GET_LOW_WORD(i,d) \ -do { \ - ieee_double_shape_type gl_u; \ - gl_u.value = (d); \ - (i) = gl_u.parts.lsw; \ -} while (0) - -/* Set a double from two 32 bit ints. */ - -#define INSERT_WORDS(d,ix0,ix1) \ -do { \ - ieee_double_shape_type iw_u; \ - iw_u.parts.msw = (ix0); \ - iw_u.parts.lsw = (ix1); \ - (d) = iw_u.value; \ -} while (0) - - - - -double modf(double x, double *iptr) -{ - __int32_t i0,i1,j_0; - __uint32_t i; - EXTRACT_WORDS(i0,i1,x); - j_0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */ - if(j_0<20) { /* integer part in high x */ - if(j_0<0) { /* |x|<1 */ - INSERT_WORDS(*iptr,i0&0x80000000U,0); /* *iptr = +-0 */ - return x; - } else { - i = (0x000fffff)>>j_0; - if(((i0&i)|i1)==0) { /* x is integral */ - __uint32_t high; - *iptr = x; - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000U,0); /* return +-0 */ - return x; - } else { - INSERT_WORDS(*iptr,i0&(~i),0); - return x - *iptr; - } - } - } else if (j_0>51) { /* no fraction part */ - __uint32_t high; - *iptr = x*one; - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000U,0); /* return +-0 */ - return x; - } else { /* fraction part in low x */ - i = ((__uint32_t)(0xffffffffU))>>(j_0-20); - if((i1&i)==0) { /* x is integral */ - __uint32_t high; - *iptr = x; - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000U,0); /* return +-0 */ - return x; - } else { - INSERT_WORDS(*iptr,i0,i1&(~i)); - return x - *iptr; - } - } -} - -//#endif /* _DOUBLE_IS_32BITS */ diff --git a/reactos/lib/crt/math/sinh.c b/reactos/lib/crt/math/sinh.c deleted file mode 100644 index fa9e5f7586d..00000000000 --- a/reactos/lib/crt/math/sinh.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -double sinh(double x) -{ - if(x >= 0.0) - { - const double epos = exp(x); - return (epos - 1.0/epos) / 2.0; - } - else - { - const double eneg = exp(-x); - return (1.0/eneg - eneg) / 2.0; - } -} diff --git a/reactos/lib/crt/math/stubs.c b/reactos/lib/crt/math/stubs.c deleted file mode 100644 index c0fd78da106..00000000000 --- a/reactos/lib/crt/math/stubs.c +++ /dev/null @@ -1,133 +0,0 @@ -#include - - -double _CIsin(double x); -double _CIcos(double x); -double _CItan(double x); -double _CIsinh(double x); -double _CIcosh(double x); -double _CItanh(double x); -double _CIasin(double x); -double _CIacos(double x); -double _CIatan(double x); -double _CIatan2(double y, double x); -double _CIexp(double x); -double _CIlog(double x); -double _CIlog10(double x); -double _CIpow(double x, double y); -double _CIsqrt(double x); -double _CIfmod(double x, double y); - - -/* - * @implemented - */ -double _CIsin(double x) -{ - return sin(x); -} -/* - * @implemented - */ -double _CIcos(double x) -{ - return cos(x); -} -/* - * @implemented - */ -double _CItan(double x) -{ - return tan(x); -} -/* - * @implemented - */ -double _CIsinh(double x) -{ - return sinh(x); -} -/* - * @implemented - */ -double _CIcosh(double x) -{ - return cosh(x); -} -/* - * @implemented - */ -double _CItanh(double x) -{ - return tanh(x); -} -/* - * @implemented - */ -double _CIasin(double x) -{ - return asin(x); -} -/* - * @implemented - */ -double _CIacos(double x) -{ - return acos(x); -} -/* - * @implemented - */ -double _CIatan(double x) -{ - return atan(x); -} -/* - * @implemented - */ -double _CIatan2(double y, double x) -{ - return atan2(y, x); -} -/* - * @implemented - */ -double _CIexp(double x) -{ - return exp(x); -} -/* - * @implemented - */ -double _CIlog(double x) -{ - return log(x); -} -/* - * @implemented - */ -double _CIlog10(double x) -{ - return log10(x); -} -/* - * @implemented - */ -double _CIpow(double x, double y) -{ - return pow(x, y); -} -/* - * @implemented - */ -double _CIsqrt(double x) -{ - return sqrt(x); -} -/* - * @implemented - */ -double _CIfmod(double x, double y) -{ - return fmod(x, y); -} diff --git a/reactos/lib/crt/math/tanh.c b/reactos/lib/crt/math/tanh.c deleted file mode 100644 index 8c231c12c3a..00000000000 --- a/reactos/lib/crt/math/tanh.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include - -/* - * @implemented - */ -double tanh(double x) -{ - if (x > 50) - return 1; - else if (x < -50) - return -1; - else - { - const double ebig = exp(x); - const double esmall = 1.0/ebig; - return (ebig - esmall) / (ebig + esmall); - } -} diff --git a/reactos/lib/crt/mbstring/hanzen.c b/reactos/lib/crt/mbstring/hanzen.c deleted file mode 100644 index 36ff0591811..00000000000 --- a/reactos/lib/crt/mbstring/hanzen.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/hanzen.c - * PURPOSE: Multibyte conversion routines formerly called hantozen and zentohan - * PROGRAMER: Ariadne, Taiji Yamada - * UPDATE HISTORY: - Modified from Taiji Yamada japanese code system utilities - * 12/04/99: Created - */ - -#include - -static unsigned short han_to_zen_ascii_table[0x5f] = { - 0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166, - 0x8169, 0x816a, 0x8196, 0x817b, 0x8143, 0x817c, 0x8144, 0x815e, - 0x824f, 0x8250, 0x8251, 0x8252, 0x8253, 0x8254, 0x8255, 0x8256, - 0x8257, 0x8258, 0x8146, 0x8147, 0x8183, 0x8181, 0x8184, 0x8148, - 0x8197, 0x8260, 0x8261, 0x8262, 0x8263, 0x8264, 0x8265, 0x8266, - 0x8267, 0x8268, 0x8269, 0x826a, 0x826b, 0x826c, 0x826d, 0x826e, - 0x826f, 0x8270, 0x8271, 0x8272, 0x8273, 0x8274, 0x8275, 0x8276, - 0x8277, 0x8278, 0x8279, 0x816d, 0x818f, 0x816e, 0x814f, 0x8151, - 0x8165, 0x8281, 0x8282, 0x8283, 0x8284, 0x8285, 0x8286, 0x8287, - 0x8288, 0x8289, 0x828a, 0x828b, 0x828c, 0x828d, 0x828e, 0x828f, - 0x8290, 0x8291, 0x8292, 0x8293, 0x8294, 0x8295, 0x8296, 0x8297, - 0x8298, 0x8299, 0x829a, 0x816f, 0x8162, 0x8170, 0x8150 -}; -static unsigned short han_to_zen_kana_table[0x40] = { - 0x8140, 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340, - 0x8342, 0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362, - 0x815b, 0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834a, 0x834c, - 0x834e, 0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835a, 0x835c, - 0x835e, 0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836a, 0x836b, - 0x836c, 0x836d, 0x836e, 0x8371, 0x8374, 0x8377, 0x837a, 0x837d, - 0x837e, 0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389, - 0x838a, 0x838b, 0x838c, 0x838d, 0x838f, 0x8393, 0x814a, 0x814b -}; -static unsigned char zen_to_han_kana_table[0x8396-0x8340+1] = { - 0xa7, 0xb1, 0xa8, 0xb2, 0xa9, 0xb3, 0xaa, 0xb4, - 0xab, 0xb5, 0xb6, 0xb6, 0xb7, 0xb7, 0xb8, 0xb8, - 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb, 0xbc, 0xbc, - 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0xc0, 0xc0, - 0xc1, 0xc1, 0xaf, 0xc2, 0xc2, 0xc3, 0xc3, 0xc4, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xca, - 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc, 0xcd, - 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xd0, 0, - 0xd1, 0xd2, 0xd3, 0xac, 0xd4, 0xad, 0xd5, 0xae, - 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdc, - 0xb2, 0xb4, 0xa6, 0xdd, 0xb3, 0xb6, 0xb9 -}; -#define ZTOH_SYMBOLS 9 -static unsigned short zen_to_han_symbol_table_1[ZTOH_SYMBOLS] = { - 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x815b, 0x814a, 0x814b -}; -static unsigned char zen_to_han_symbol_table_2[ZTOH_SYMBOLS] = { - 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xb0, 0xde, 0xdf -}; -#define ISKANA(c) ((c) >= 0xa1 && (c) <= 0xdf) -#define JISHIRA(c) ((c) >= 0x829f && (c) <= 0x82f1) -#define JISKANA(c) ((c) >= 0x8340 && (c) <= 0x8396 && (c) != 0x837f) -#define JTOKANA(c) ((c) <= 0x82dd ? (c) + 0xa1 : (c) + 0xa2) - - -/* - * @implemented - */ -unsigned short _mbbtombc(unsigned short c) -{ - if (c >= 0x20 && c <= 0x7e) { - return han_to_zen_ascii_table[c - 0x20]; - } else if (ISKANA(c)) { - return han_to_zen_kana_table[c - 0xa0]; - } - return c; -} - - -/* - * @implemented - */ -unsigned short _mbctombb(unsigned short c) -{ - int i; - unsigned short *p; - - if (JISKANA(c)) { - return zen_to_han_kana_table[c - 0x8340]; - } else if (JISHIRA(c)) { - c = JTOKANA(c); - return zen_to_han_kana_table[c - 0x8340]; - } else if (c <= 0x8396) { - for (i = 0x20, p = han_to_zen_ascii_table; i <= 0x7e; i++, p++) { - if (*p == c) { - return i; - } - } - for (i = 0; i < ZTOH_SYMBOLS; i++) { - if (zen_to_han_symbol_table_1[i] == c) { - return zen_to_han_symbol_table_2[i]; - } - } - } - return c; -} - - - diff --git a/reactos/lib/crt/mbstring/ischira.c b/reactos/lib/crt/mbstring/ischira.c deleted file mode 100644 index 43ba5e5a44f..00000000000 --- a/reactos/lib/crt/mbstring/ischira.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/ischira.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include -#include - - -/* - * @implemented - */ -int _ismbchira( unsigned int c ) -{ - return ((c>=0x829F) && (c<=0x82F1)); -} - -/* - * @implemented - */ -int _ismbckata( unsigned int c ) -{ - return ((c>=0x8340) && (c<=0x8396)); -} - -/* - * @unimplemented - */ -unsigned int _mbctohira( unsigned int c ) -{ - return c; -} - -/* - * @unimplemented - */ -unsigned int _mbctokata( unsigned int c ) -{ - return c; -} - diff --git a/reactos/lib/crt/mbstring/iskana.c b/reactos/lib/crt/mbstring/iskana.c deleted file mode 100644 index 750466c1195..00000000000 --- a/reactos/lib/crt/mbstring/iskana.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/iskana.c - * PURPOSE: Checks for kana character - * PROGRAMER: Ariadne, Taiji Yamada - * UPDATE HISTORY: - Modified from Taiji Yamada japanese code system utilities - * 12/04/99: Created - */ -#include -#include -#include - -/* - * @implemented - */ -int _ismbbkana(unsigned int c) -{ - 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 deleted file mode 100644 index a9c01ec0447..00000000000 --- a/reactos/lib/crt/mbstring/iskmoji.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int _ismbbkalpha(unsigned char c) -{ - return (0xA7 <= c && c <= 0xDF); -} diff --git a/reactos/lib/crt/mbstring/iskpun.c b/reactos/lib/crt/mbstring/iskpun.c deleted file mode 100644 index 8747fb96b62..00000000000 --- a/reactos/lib/crt/mbstring/iskpun.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/iskpun.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include -#include -/* - * @implemented - */ -int _ismbbkpunct( unsigned int c ) -{ - return ((_mbctype+1)[(unsigned char)(c)] & (_KNJ_P)); -} diff --git a/reactos/lib/crt/mbstring/islead.c b/reactos/lib/crt/mbstring/islead.c deleted file mode 100644 index 81a219f8b5d..00000000000 --- a/reactos/lib/crt/mbstring/islead.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -/* - * @unimplemented - */ -int isleadbyte(int byte) -{ - return 0; - //return IsDBCSLeadByteEx(0,*c); -} diff --git a/reactos/lib/crt/mbstring/islwr.c b/reactos/lib/crt/mbstring/islwr.c deleted file mode 100644 index b840a7f8e18..00000000000 --- a/reactos/lib/crt/mbstring/islwr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/islwr.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include - -/* - * code page 952 only - * - * @implemented - */ -int _ismbclower( unsigned int c ) -{ - if ((c & 0xFF00) != 0) { - if ( c >= 0x829A && c<= 0x829A ) - return 1; - } - - return islower(c); -} diff --git a/reactos/lib/crt/mbstring/ismbal.c b/reactos/lib/crt/mbstring/ismbal.c deleted file mode 100644 index e0eb4383ab1..00000000000 --- a/reactos/lib/crt/mbstring/ismbal.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/ismbal.c - * PURPOSE: Checks for alphabetic multibyte character - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include -#include - -/* - * @implemented - */ -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 deleted file mode 100644 index ac8948ef3a8..00000000000 --- a/reactos/lib/crt/mbstring/ismbaln.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -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 deleted file mode 100644 index b28ef2127a6..00000000000 --- a/reactos/lib/crt/mbstring/ismbc.c +++ /dev/null @@ -1,135 +0,0 @@ -#include - -int _ismbbalpha(unsigned char c); -int _ismbbalnum(unsigned char c); - -/* - * @implemented - */ -int _ismbcalnum( unsigned int c ) -{ - if ((c & 0xFF00) != 0) { - // true multibyte character - return 0; - } - else - return _ismbbalnum(c); - - return 0; -} - -/* - * @implemented - */ -int _ismbcalpha( unsigned int c ) -{ - if ((c & 0xFF00) != 0) { - // true multibyte character - return 0; - } - else - return _ismbbalpha(c); - - return 0; -} - -/* - * @implemented - */ -int _ismbcdigit( unsigned int c ) -{ - if ((c & 0xFF00) != 0) { - // true multibyte character - return 0; - } - else - return 0; -// return _ismbbdigit(c); - - return 0; -} - -/* - * @unimplemented - */ -int _ismbcprint( unsigned int c ) -{ - if ((c & 0xFF00) != 0) { - // true multibyte character - return 0; - } - else - return 0; -// return _ismbbdigit(c); - - return 0; -} - -/* - * @unimplemented - */ -int _ismbcsymbol( unsigned int c ) -{ - if ((c & 0xFF00) != 0) { - // true multibyte character - return 0; - } - else - return 0; -// return _ismbbdigit(c); - - return 0; -} - -/* - * @unimplemented - */ -int _ismbcspace( unsigned int c ) -{ - if ((c & 0xFF00) != 0) { - // true multibyte character - return 0; - } - else - return 0; -// return _ismbbdigit(c); - - return 0; -} -/* - * @implemented - */ -int _ismbclegal(unsigned int c) -{ - if ((c & 0xFF00) != 0) { - return _ismbblead(c>>8) && _ismbbtrail(c&0xFF); - } - else - return _ismbbtrail(c&0xFF); - - return 0; -} - -/* - * @unimplemented - */ -int _ismbcl0(unsigned int c) -{ - return 0; -} - -/* - * @unimplemented - */ -int _ismbcl1(unsigned int c) -{ - return 0; -} - -/* - * @unimplemented - */ -int _ismbcl2(unsigned int c) -{ - return 0; -} diff --git a/reactos/lib/crt/mbstring/ismbgra.c b/reactos/lib/crt/mbstring/ismbgra.c deleted file mode 100644 index 76afacaa85e..00000000000 --- a/reactos/lib/crt/mbstring/ismbgra.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -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 deleted file mode 100644 index fd16c05cd97..00000000000 --- a/reactos/lib/crt/mbstring/ismbkaln.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/ismbkaln.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include -#include -#include -/* - * @implemented - */ -int _ismbbkalnum( unsigned int c ) -{ - return ((_mbctype+1)[(unsigned char)(c)] & (_KNJ_P)); -} diff --git a/reactos/lib/crt/mbstring/ismblead.c b/reactos/lib/crt/mbstring/ismblead.c deleted file mode 100644 index 5834399a2d4..00000000000 --- a/reactos/lib/crt/mbstring/ismblead.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/ismblead.c - * PURPOSE: Checks for a lead byte - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * Modified from Taiji Yamada japanese code system utilities - * 12/04/99: Created - */ - -#include -#include -#include -#include - -size_t _mbclen2(const unsigned int s); - -unsigned char _mbctype[257] = { -/*-1*/ ___, -/*0x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, -/*1x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, -/*2x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, -/*3x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, -/*4x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2, -/*5x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2, -/*6x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2, -/*7x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,___, -/*8x*/ __2,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12, -/*9x*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12, -/*Ax*/ __2,_P2,_P2,_P2,_P2,_P2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2, -/*Bx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2, -/*Cx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2, -/*Dx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2, -/*Ex*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12, -/*Fx*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,___,___,___ -}; - -//unsigned char _mbctype = _jctype; -/* - * @implemented - */ -int _ismbblead(unsigned int c) -{ - return ((_mbctype+1)[(unsigned char)(c)] & _KNJ_1); -} -//int _ismbblead(unsigned int byte) -//{ -// -// return (int)IsDBCSLeadByte(byte) -//} - -/* - * @implemented - */ -int _ismbslead( const unsigned char *str, const unsigned char *t) -{ - unsigned char *s = (unsigned char *)str; - while(*s != 0 && s != t) - { - - s+= _mbclen2(*s); - } - return _ismbblead( *s); -} - diff --git a/reactos/lib/crt/mbstring/ismbpri.c b/reactos/lib/crt/mbstring/ismbpri.c deleted file mode 100644 index b66063bab7c..00000000000 --- a/reactos/lib/crt/mbstring/ismbpri.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -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 deleted file mode 100644 index f8858a7518a..00000000000 --- a/reactos/lib/crt/mbstring/ismbpun.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -#include -#include -#include - - -/* - * @implemented - */ -int _ismbbpunct(unsigned int c) -{ -// (0xA1 <= c <= 0xA6) - return (ispunct(c) || _ismbbkana(c)); -} - - //iskana() :(0xA1 <= c <= 0xDF) - //iskpun() :(0xA1 <= c <= 0xA6) - //iskmoji() :(0xA7 <= c <= 0xDF) diff --git a/reactos/lib/crt/mbstring/ismbtrl.c b/reactos/lib/crt/mbstring/ismbtrl.c deleted file mode 100644 index 41c4448113c..00000000000 --- a/reactos/lib/crt/mbstring/ismbtrl.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/ismbtrl.c - * PURPOSE: Checks for a trailing byte - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include -#include -#include - -size_t _mbclen2(const unsigned int s); - -// iskanji2() : (0x40 <= c <= 0x7E 0x80 <= c <= 0xFC) - -/* - * @implemented - */ -int _ismbbtrail(unsigned int c) -{ - return ((_mbctype+1)[(unsigned char)(c)] & _KNJ_2); -} - -//int _ismbbtrail( unsigned int b) -//{ -// return ((b >= 0x40 && b <= 0x7e ) || (b >= 0x80 && b <= 0xfc ) ); -//} - - -/* - * @implemented - */ -int _ismbstrail( const unsigned char *str, const unsigned char *t) -{ - unsigned char *s = (unsigned char *)str; - while(*s != 0 && s != t) - { - - s+= _mbclen2(*s); - } - - return _ismbbtrail(*s); -} diff --git a/reactos/lib/crt/mbstring/isuppr.c b/reactos/lib/crt/mbstring/isuppr.c deleted file mode 100644 index e32e06bc868..00000000000 --- a/reactos/lib/crt/mbstring/isuppr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/isuppr.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include - -/* - * code page 952 only - * - * @implemented - */ -int _ismbcupper( unsigned int c ) -{ - if ((c & 0xFF00) != 0) { - if ( c >= 0x8260 && c<= 0x8279 ) - return 1; - } - - return isupper(c); -} diff --git a/reactos/lib/crt/mbstring/jistojms.c b/reactos/lib/crt/mbstring/jistojms.c deleted file mode 100644 index bddb6caef00..00000000000 --- a/reactos/lib/crt/mbstring/jistojms.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned int _mbcjistojms(unsigned int c) -{ - int c1, c2; - - c2 = (unsigned char)c; - c1 = c >> 8; - if (c1 >= 0x21 && c1 <= 0x7e && c2 >= 0x21 && c2 <= 0x7e) { - if (c1 & 0x01) { - c2 += 0x1f; - if (c2 >= 0x7f) - c2 ++; - } else { - c2 += 0x7e; - } - c1 += 0xe1; - c1 >>= 1; - if (c1 >= 0xa0) - c1 += 0x40; - return ((c1 << 8) | c2); - } - return 0; -} diff --git a/reactos/lib/crt/mbstring/jmstojis.c b/reactos/lib/crt/mbstring/jmstojis.c deleted file mode 100644 index 8e634c3e67d..00000000000 --- a/reactos/lib/crt/mbstring/jmstojis.c +++ /dev/null @@ -1,28 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned int _mbcjmstojis(unsigned int c) -{ - int c1, c2; - - c2 = (unsigned char)c; - c1 = c >> 8; - if (c1 < 0xf0 && _ismbblead(c1) && _ismbbtrail(c2)) { - if (c1 >= 0xe0) - c1 -= 0x40; - c1 -= 0x70; - c1 <<= 1; - if (c2 < 0x9f) { - c1 --; - c2 -= 0x1f; - if (c2 >= (0x80-0x1f)) - c2 --; - } else { - c2 -= 0x7e; - } - return ((c1 << 8) | c2); - } - return 0; -} diff --git a/reactos/lib/crt/mbstring/mbbtype.c b/reactos/lib/crt/mbstring/mbbtype.c deleted file mode 100644 index 7f1f7748873..00000000000 --- a/reactos/lib/crt/mbstring/mbbtype.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbbtype.c - * PURPOSE: Determines the type of a multibyte character - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include - -#include -#include - -/* - * @implemented - */ -int _mbbtype(unsigned char c , int type) -{ - if ( type == 1 ) { - if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) ) - { - return _MBC_TRAIL; - } - else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) || - ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) ) - return _MBC_ILLEGAL; - else - return 0; - } else { - if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) { - return _MBC_SINGLE; - } - else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) ) - return _MBC_LEAD; - else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) || - ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) ) - return _MBC_ILLEGAL; - else - return 0; - } - return 0; -} - -/* - * @implemented - */ -int _mbsbtype( const unsigned char *str, size_t n ) -{ - if ( str == NULL ) - return -1; - return _mbbtype(*(str+n),1); -} diff --git a/reactos/lib/crt/mbstring/mbccpy.c b/reactos/lib/crt/mbstring/mbccpy.c deleted file mode 100644 index b48e1261485..00000000000 --- a/reactos/lib/crt/mbstring/mbccpy.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -size_t _mbclen2(const unsigned int s); - -/* - * @implemented - */ -void _mbccpy(unsigned char *dst, const unsigned char *src) -{ - if (!_ismbblead(*src) ) - return; - - memcpy(dst,src,_mbclen2(*src)); -} diff --git a/reactos/lib/crt/mbstring/mbclen.c b/reactos/lib/crt/mbstring/mbclen.c deleted file mode 100644 index 414852d04b4..00000000000 --- a/reactos/lib/crt/mbstring/mbclen.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -size_t _mbclen(const unsigned char *s) -{ - return (_ismbblead(*s>>8) && _ismbbtrail(*s&0x00FF)) ? 2 : 1; -} - -size_t _mbclen2(const unsigned int s) -{ - return (_ismbblead(s>>8) && _ismbbtrail(s&0x00FF)) ? 2 : 1; -} - -/* - * assume MB_CUR_MAX == 2 - * - * @implemented - */ -int mblen( const char *s, size_t count ) -{ - size_t l; - if ( s == NULL ) - return 0; - - l = _mbclen((const unsigned char *)s); - if ( l < count ) - return -1; - return l; -} diff --git a/reactos/lib/crt/mbstring/mbscat.c b/reactos/lib/crt/mbstring/mbscat.c deleted file mode 100644 index 48412b627df..00000000000 --- a/reactos/lib/crt/mbstring/mbscat.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -/* - * @implemented - */ -unsigned char * _mbscat(unsigned char *dst, const unsigned char *src) -{ - return (unsigned char *)strcat((char*)dst,(const char*)src); -} diff --git a/reactos/lib/crt/mbstring/mbschr.c b/reactos/lib/crt/mbstring/mbschr.c deleted file mode 100644 index e635e3f1ff7..00000000000 --- a/reactos/lib/crt/mbstring/mbschr.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned char * _mbschr(const unsigned char *str, unsigned int c) -{ - return (unsigned char *)strchr((const char*)str, c); -} diff --git a/reactos/lib/crt/mbstring/mbscmp.c b/reactos/lib/crt/mbstring/mbscmp.c deleted file mode 100644 index 611d086cc45..00000000000 --- a/reactos/lib/crt/mbstring/mbscmp.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -/* - * @implemented - */ -int _mbscmp(const unsigned char *str1, const unsigned char *str2) -{ - return strcmp((const char*)str1, (char*)str2); -} diff --git a/reactos/lib/crt/mbstring/mbscoll.c b/reactos/lib/crt/mbstring/mbscoll.c deleted file mode 100644 index 8049ef39b19..00000000000 --- a/reactos/lib/crt/mbstring/mbscoll.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbscoll.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include - -int colldif(unsigned short c1, unsigned short c2); - -/* - * @implemented - */ -int _mbscoll(const unsigned char *str1, const unsigned char *str2) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - int l1, l2; - - while ( *s1 != 0 ) { - - if (*s1 == 0) - break; - - l1 = _ismbblead(*s1); - l2 = _ismbblead(*s2); - if ( !l1 && !l2 ) { - - if (*s1 != *s2) - return colldif(*s1, *s2); - else { - s1 += 1; - s2 += 1; - } - } - else if ( l1 && l2 ){ - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - if ( *short_s1 != *short_s2 ) - return colldif(*short_s1, *short_s2); - else { - s1 += 2; - s2 += 2; - - } - } - else - return colldif(*s1, *s2); - } ; - return 0; -} - -#if 0 -int _mbsbcoll(const unsigned char *str1, const unsigned char *str2) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - int l1, l2; - - - while ( *s1 != 0 ) { - - - l1 = _ismbblead(*s1); - l2 = _ismbblead(*s2); - if ( !l1 && !l2 ) { - - if (*s1 != *s2) - return colldif(*s1, *s2); - else { - s1 += 1; - s2 += 1; - } - } - else if ( l1 && l2 ){ - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - if ( *short_s1 != *short_s2 ) - return colldif(*short_s1, *short_s2); - else { - s1 += 2; - s2 += 2; - } - } - else - return colldif(*s1, *s2); - } ; - return 0; -} -#endif diff --git a/reactos/lib/crt/mbstring/mbscpy.c b/reactos/lib/crt/mbstring/mbscpy.c deleted file mode 100644 index c3c5564affd..00000000000 --- a/reactos/lib/crt/mbstring/mbscpy.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -unsigned char * _mbscpy(unsigned char *dst, const unsigned char *str) -{ - return (unsigned char*)strcpy((char*)dst,(const char*)str); -} diff --git a/reactos/lib/crt/mbstring/mbscspn.c b/reactos/lib/crt/mbstring/mbscspn.c deleted file mode 100644 index 59936778fc6..00000000000 --- a/reactos/lib/crt/mbstring/mbscspn.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -/* - * FIXME not correct - * - * @unimplemented - */ -size_t _mbscspn(const unsigned char *s1, const unsigned char *s2) -{ - const unsigned char *p, *spanp; - char c, sc; - - for (p = s1;;) - { - c = *p++; - spanp = s2; - do { - if ((sc = *spanp++) == c) - return (size_t)(p - 1) - (size_t)s1; - } while (sc != 0); - } - /* NOTREACHED */ -} diff --git a/reactos/lib/crt/mbstring/mbsdec.c b/reactos/lib/crt/mbstring/mbsdec.c deleted file mode 100644 index 97d17128fa0..00000000000 --- a/reactos/lib/crt/mbstring/mbsdec.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -/* - * @implemented - */ -unsigned char * _mbsdec(const unsigned char *str, const unsigned char *cur) -{ - unsigned char *s = (unsigned char *)cur; - if ( str >= cur ) - return NULL; - - s--; - if (_ismbblead(*(s-1)) ) - s--; - - return s; -} diff --git a/reactos/lib/crt/mbstring/mbsdup.c b/reactos/lib/crt/mbstring/mbsdup.c deleted file mode 100644 index 8ae909cfcc2..00000000000 --- a/reactos/lib/crt/mbstring/mbsdup.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsdup.c - * PURPOSE: Duplicates a multi byte string - * PROGRAMER: Ariadne - * UPDATE HISTORY: - Modified from DJGPP strdup - * 12/04/99: Created - */ - -#include -#include -#include - -/* - * @implemented - */ -unsigned char * _mbsdup(const unsigned char *_s) -{ - unsigned char *rv; - if (_s == 0) - return 0; - rv = (unsigned char *)malloc(_mbslen(_s) + 1); - if (rv == 0) - return 0; - _mbscpy(rv, _s); - return rv; -} diff --git a/reactos/lib/crt/mbstring/mbsicmp.c b/reactos/lib/crt/mbstring/mbsicmp.c deleted file mode 100644 index 8777e6b9f4a..00000000000 --- a/reactos/lib/crt/mbstring/mbsicmp.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsicmp.c - * PURPOSE: Duplicates a multi byte string - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include -#include -#include - -/* - * @implemented - */ -int _mbsicmp(const unsigned char *str1, const unsigned char *str2) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - int l1, l2; - - do { - - if (*s1 == 0) - break; - - l1 = _ismbblead(*s1); - l2 = _ismbblead(*s2); - if ( !l1 && !l2 ) { - - if (toupper(*s1) != toupper(*s2)) - return toupper(*s1) - toupper(*s2); - else { - s1 += 1; - s2 += 1; - } - } - else if ( l1 && l2 ){ - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 )) - return _mbctoupper(*short_s1) - _mbctoupper(*short_s2); - else { - s1 += 2; - s2 += 2; - } - } - else - return *s1 - *s2; - } while (*s1 != 0); - return 0; - - while (toupper(*s1) == toupper(*s2)) - { - if (*s1 == 0) - return 0; - s1++; - s2++; - } - return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2)); -} diff --git a/reactos/lib/crt/mbstring/mbsicoll.c b/reactos/lib/crt/mbstring/mbsicoll.c deleted file mode 100644 index 874a4ffc891..00000000000 --- a/reactos/lib/crt/mbstring/mbsicoll.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsicoll.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include -#include -#include - -int colldif(unsigned short c1, unsigned short c2); -/* - * @implemented - */ -int _mbsicoll(const unsigned char *str1, const unsigned char *str2) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - int l1, l2; - - while ( *s1 != 0 ) { - - if (*s1 == 0) - break; - - l1 = _ismbblead(*s1); - l2 = _ismbblead(*s2); - if ( !l1 && !l2 ) { - - if (toupper(*s1) != toupper(*s2)) - return colldif(*s1, *s2); - else { - s1 += 1; - s2 += 1; - } - } - else if ( l1 && l2 ){ - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 )) - return colldif(*short_s1, *short_s2); - else { - s1 += 2; - s2 += 2; - - } - } - else - return colldif(*s1, *s2); - } ; - return 0; -} diff --git a/reactos/lib/crt/mbstring/mbsinc.c b/reactos/lib/crt/mbstring/mbsinc.c deleted file mode 100644 index fedd8eeef2e..00000000000 --- a/reactos/lib/crt/mbstring/mbsinc.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned char * _mbsinc(const unsigned char *s) -{ - unsigned char *c = (unsigned char *)s; - if (_ismbblead(*s) ) - c++; - c++; - return c; -} diff --git a/reactos/lib/crt/mbstring/mbslen.c b/reactos/lib/crt/mbstring/mbslen.c deleted file mode 100644 index 67733298e2c..00000000000 --- a/reactos/lib/crt/mbstring/mbslen.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -size_t _mbclen2(const unsigned int s); - -/* - * @implemented - */ -size_t _mbslen(const unsigned char *str) -{ - int i = 0; - unsigned char *s; - - if (str == 0) - return 0; - - for (s = (unsigned char *)str; *s; s+=_mbclen2(*s),i++); - return i; -} diff --git a/reactos/lib/crt/mbstring/mbslwr.c b/reactos/lib/crt/mbstring/mbslwr.c deleted file mode 100644 index c5d24cb361f..00000000000 --- a/reactos/lib/crt/mbstring/mbslwr.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include - -unsigned int _mbbtolower(unsigned int c) -{ - if (!_ismbblead(c) ) - return tolower(c); - return c; -} - -// code page 952 -#define CASE_DIFF (0x8281 - 0x8260) - -/* - * @implemented - */ -unsigned int _mbctolower(unsigned int c) -{ - if ((c & 0xFF00) != 0) { - // true multibyte case conversion needed - if (_ismbclower(c)) - return c + CASE_DIFF; - } else { - return _mbbtolower(c); - } - return 0; -} - -/* - * @implemented - */ -unsigned char * _mbslwr(unsigned char *x) -{ - unsigned char *y=x; - - while (*y) { - if (!_ismbblead(*y)) { - *y = tolower(*y); - } else { - *y=_mbctolower(*(unsigned short *)y); - y++; - } - } - return x; -} diff --git a/reactos/lib/crt/mbstring/mbsncat.c b/reactos/lib/crt/mbstring/mbsncat.c deleted file mode 100644 index d1e5ce2ec8e..00000000000 --- a/reactos/lib/crt/mbstring/mbsncat.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsncat.c - * PURPOSE: Concatenate two multi byte string to maximum of n characters or bytes - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include -#include - -size_t _mbclen2(const unsigned int s); - -/* - * @implemented - */ -unsigned char * _mbsncat(unsigned char *dst, const unsigned char *src, size_t n) -{ - unsigned char *d = dst; - const unsigned char *s = src; - if (n != 0) { - d = dst + _mbslen(dst); // get the end of string - d += _mbclen2(*d); // move 1 or 2 up - - do { - if ((*d++ = *s++) == 0) - { - while (--n != 0) - *d++ = 0; - break; - } - if (!_ismbblead(*s) ) - n--; - } while (n > 0); - } - return dst; -} - -/* - * @implemented - */ -unsigned char * _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t n) -{ - unsigned char *d; - const unsigned char *s = src; - if (n != 0) { - d = dst + _mbslen(dst); // get the end of string - d += _mbclen2(*d); // move 1 or 2 up - - do { - if ((*d++ = *s++) == 0) - { - while (--n != 0) - *d++ = 0; - break; - } - if ( !(n==1 && _ismbblead(*s)) ) - n--; - } while (n > 0); - } - return dst; -} diff --git a/reactos/lib/crt/mbstring/mbsnccnt.c b/reactos/lib/crt/mbstring/mbsnccnt.c deleted file mode 100644 index bc4ccc2f277..00000000000 --- a/reactos/lib/crt/mbstring/mbsnccnt.c +++ /dev/null @@ -1,35 +0,0 @@ -#include - -/* - * @implemented - */ -size_t _mbsnccnt(const unsigned char *str, size_t n) -{ - unsigned char *s = (unsigned char *)str; - size_t cnt = 0; - while(*s != 0 && n > 0) { - if (_ismbblead(*s) ) - s++; - else - n--; - s++; - cnt++; - } - - return cnt; -} - -/* - * @implemented - */ -size_t _mbsnbcnt(const unsigned char *str, size_t n) -{ - unsigned char *s = (unsigned char *)str; - while(*s != 0 && n > 0) { - if (!_ismbblead(*s) ) - n--; - s++; - } - - return (size_t)(s - str); -} diff --git a/reactos/lib/crt/mbstring/mbsncmp.c b/reactos/lib/crt/mbstring/mbsncmp.c deleted file mode 100644 index 4d34301efb2..00000000000 --- a/reactos/lib/crt/mbstring/mbsncmp.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsncmp.c - * PURPOSE: Compares two strings to a maximum of n bytes or characters - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include - -/* - * @implemented - */ -int _mbsncmp(const unsigned char *str1, const unsigned char *str2, size_t n) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - int l1, l2; - - if (n == 0) - return 0; - do { - - if (*s1 == 0) - break; - - l1 = _ismbblead(*s1); - l2 = _ismbblead(*s2); - if ( !l1 && !l2 ) { - - if (*s1 != *s2) - return *s1 - *s2; - else { - s1 += 1; - s2 += 1; - n--; - } - } - else if ( l1 && l2 ){ - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - if ( *short_s1 != *short_s2 ) - return *short_s1 - *short_s2; - else { - s1 += 2; - s2 += 2; - n--; - - } - } - else - return *s1 - *s2; - } while (n > 0); - return 0; -} - -/* - * @implemented - */ -int _mbsnbcmp(const unsigned char *str1, const unsigned char *str2, size_t n) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - int l1, l2; - - if (n == 0) - return 0; - do { - - if (*s1 == 0) - break; - - l1 = _ismbblead(*s1); - l2 = _ismbblead(*s2); - if ( !l1 && !l2 ) { - - if (*s1 != *s2) - return *s1 - *s2; - else { - s1 += 1; - s2 += 1; - n--; - } - } - else if ( l1 && l2 ){ - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - if ( *short_s1 != *short_s2 ) - return *short_s1 - *short_s2; - else { - s1 += 2; - s2 += 2; - n-=2; - - } - } - else - return *s1 - *s2; - } while (n > 0); - return 0; -} diff --git a/reactos/lib/crt/mbstring/mbsncoll.c b/reactos/lib/crt/mbstring/mbsncoll.c deleted file mode 100644 index 229bc314038..00000000000 --- a/reactos/lib/crt/mbstring/mbsncoll.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsncoll.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include - -int colldif(unsigned short c1, unsigned short c2); - -/* - * @implemented - */ -int _mbsncoll(const unsigned char *str1, const unsigned char *str2, size_t n) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - int l1, l2; - - if (n == 0) - return 0; - do { - - if (*s1 == 0) - break; - - l1 = _ismbblead(*s1); - l2 = _ismbblead(*s2); - if ( !l1 && !l2 ) { - - if (*s1 != *s2) - return colldif(*s1, *s2); - else { - s1 += 1; - s2 += 1; - n--; - } - } - else if ( l1 && l2 ){ - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - if ( *short_s1 != *short_s2 ) - return colldif(*short_s1, *short_s2); - else { - s1 += 2; - s2 += 2; - n--; - - } - } - else - return colldif(*s1, *s2); - } while (n > 0); - return 0; -} - -/* - * @implemented - */ -int _mbsnbcoll(const unsigned char *str1, const unsigned char *str2, size_t n) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - int l1, l2; - - if (n == 0) - return 0; - do { - - if (*s1 == 0) - break; - - l1 = _ismbblead(*s1); - l2 = _ismbblead(*s2); - if ( !l1 && !l2 ) { - - if (*s1 != *s2) - return colldif(*s1, *s2); - else { - s1 += 1; - s2 += 1; - n--; - } - } - else if ( l1 && l2 ){ - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - if ( *short_s1 != *short_s2 ) - return colldif(*short_s1, *short_s2); - else { - s1 += 2; - s2 += 2; - n-=2; - - } - } - else - return colldif(*s1, *s2); - } while (n > 0); - return 0; -} - -int colldif(unsigned short c1, unsigned short c2) -{ - return c1 - c2; -} diff --git a/reactos/lib/crt/mbstring/mbsncpy.c b/reactos/lib/crt/mbstring/mbsncpy.c deleted file mode 100644 index 2b176bf986d..00000000000 --- a/reactos/lib/crt/mbstring/mbsncpy.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsncpy.c - * PURPOSE: Copies a string to a maximum of n bytes or characters - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include - - -/* - * @implemented - */ -unsigned char* _mbsncpy(unsigned char *str1, const unsigned char *str2, size_t n) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - if (n == 0) - return 0; - do { - - if (*s2 == 0) - break; - - if ( !_ismbblead(*s2) ) { - - *s1 = *s2; - s1 += 1; - s2 += 1; - n--; - } - else { - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - *short_s1 = *short_s2; - s1 += 2; - s2 += 2; - n--; - } - } while (n > 0); - return str1; -} - - -/* - * The _mbsnbcpy function copies count bytes from src to dest. If src is shorter - * than dest, the string is padded with null characters. If dest is less than or - * equal to count it is not terminated with a null character. - * - * @implemented - */ -unsigned char * _mbsnbcpy(unsigned char *str1, const unsigned char *str2, size_t n) -{ - unsigned char *s1 = (unsigned char *)str1; - unsigned char *s2 = (unsigned char *)str2; - - unsigned short *short_s1, *short_s2; - - if (n == 0) - return 0; - do { - - if (*s2 == 0) { - *s1 = *s2; - break; - } - - if ( !_ismbblead(*s2) ) { - - *s1 = *s2; - s1 += 1; - s2 += 1; - n--; - } - else { - short_s1 = (unsigned short *)s1; - short_s2 = (unsigned short *)s2; - *short_s1 = *short_s2; - s1 += 2; - s2 += 2; - n-=2; - } - } while (n > 0); - return str1; -} diff --git a/reactos/lib/crt/mbstring/mbsnextc.c b/reactos/lib/crt/mbstring/mbsnextc.c deleted file mode 100644 index ee75c6f915c..00000000000 --- a/reactos/lib/crt/mbstring/mbsnextc.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -/* - * @implemented - */ -unsigned int _mbsnextc (const unsigned char *src) -{ - unsigned char *char_src = (unsigned char *)src; - unsigned short *short_src = (unsigned short *)src; - - if (src == NULL) - return 0; - - if (!_ismbblead(*src)) - return *char_src; - else - return *short_src; - return 0; -} diff --git a/reactos/lib/crt/mbstring/mbsnicmp.c b/reactos/lib/crt/mbstring/mbsnicmp.c deleted file mode 100644 index 0a554b2176c..00000000000 --- a/reactos/lib/crt/mbstring/mbsnicmp.c +++ /dev/null @@ -1,47 +0,0 @@ -#include - - -size_t _mbclen2(const unsigned int s); -unsigned int _mbbtoupper(unsigned int c); - - -/* - * @implemented - */ -int _mbsnicmp(const unsigned char *s1, const unsigned char *s2, size_t n) -{ - if (n == 0) - return 0; - do { - if (_mbbtoupper(*s1) != _mbbtoupper(*s2)) - return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2); - s1 += _mbclen2(*s1); - s2 += _mbclen2(*s2); - - if (*s1 == 0) - break; - if (!_ismbblead(*s1)) - n--; - } while (n > 0); - return 0; -} - -/* - * @implemented - */ -int _mbsnbicmp(const unsigned char *s1, const unsigned char *s2, size_t n) -{ - if (n == 0) - return 0; - do { - if (_mbbtoupper(*s1) != _mbbtoupper(*s2)) - return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2); - s1 += _mbclen2(*s1); - s2 += _mbclen2(*s2); - - if (*s1 == 0) - break; - n--; - } while (n > 0); - return 0; -} diff --git a/reactos/lib/crt/mbstring/mbsnicoll.c b/reactos/lib/crt/mbstring/mbsnicoll.c deleted file mode 100644 index bfc67e5e1df..00000000000 --- a/reactos/lib/crt/mbstring/mbsnicoll.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -/* - * @unimplemented - */ -int _mbsnicoll(const unsigned char *s1, const unsigned char *s2, size_t n) -{ - return 0; -} - -/* - * @unimplemented - */ -int _mbsnbicoll(const unsigned char *s1, const unsigned char *s2, size_t n) -{ - return 0; -} diff --git a/reactos/lib/crt/mbstring/mbsninc.c b/reactos/lib/crt/mbstring/mbsninc.c deleted file mode 100644 index 67f2fac2c87..00000000000 --- a/reactos/lib/crt/mbstring/mbsninc.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned char * _mbsninc(const unsigned char *str, size_t n) -{ - unsigned char *s = (unsigned char *)str; - while(*s != 0 && n > 0) { - if (!_ismbblead(*s) ) - n--; - s++; - } - - return s; -} diff --git a/reactos/lib/crt/mbstring/mbsnset.c b/reactos/lib/crt/mbstring/mbsnset.c deleted file mode 100644 index 5de7983a0a8..00000000000 --- a/reactos/lib/crt/mbstring/mbsnset.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsnset.c - * PURPOSE: Fills a string with a multibyte character - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include - -size_t _mbclen2(const unsigned int s); - -/* - * @implemented - */ -unsigned char * _mbsnset(unsigned char *src, unsigned int val, size_t count) -{ - unsigned char *char_src = (unsigned char *)src; - unsigned short *short_src = (unsigned short *)src; - - if ( _mbclen2(val) == 1 ) { - - while(count > 0) { - *char_src = val; - char_src++; - count--; - } - *char_src = 0; - } - else { - while(count > 0) { - *short_src = val; - short_src++; - count-=2; - } - *short_src = 0; - } - - return src; -} - -/* - * @implemented - */ -unsigned char * _mbsnbset(unsigned char *src, unsigned int val, size_t count) -{ - unsigned char *char_src = (unsigned char *)src; - unsigned short *short_src = (unsigned short *)src; - - if ( _mbclen2(val) == 1 ) { - - while(count > 0) { - *char_src = val; - char_src++; - count--; - } - *char_src = 0; - } - else { - while(count > 0) { - *short_src = val; - short_src++; - count-=2; - } - *short_src = 0; - } - - return src; -} diff --git a/reactos/lib/crt/mbstring/mbspbrk.c b/reactos/lib/crt/mbstring/mbspbrk.c deleted file mode 100644 index 83b5b1085be..00000000000 --- a/reactos/lib/crt/mbstring/mbspbrk.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -int isleadbyte(int byte); - -/* - * not correct - * - * @implemented - */ -unsigned char * _mbspbrk(const unsigned char *s1, const unsigned char *s2) -{ - const unsigned char* p; - - while (*s1) - { - for (p = s2; *p; p += (isleadbyte(*p) ? 2 : 1)) - { - if (*p == *s1) - if (!isleadbyte(*p) || (*(p+1) == *(s1 + 1))) - return (unsigned char*)s1; - } - s1 += (isleadbyte(*s1) ? 2 : 1); - } - return NULL; -} diff --git a/reactos/lib/crt/mbstring/mbsrchr.c b/reactos/lib/crt/mbstring/mbsrchr.c deleted file mode 100644 index 7fdfc2d7ba4..00000000000 --- a/reactos/lib/crt/mbstring/mbsrchr.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsrchr.c - * PURPOSE: Searches for a character in reverse - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include -#include - -/* - * @implemented - */ -unsigned char * _mbsrchr(const unsigned char *src, unsigned int val) -{ - unsigned int c; - unsigned char *match = NULL; - - if (!src) - return NULL; - - while (1) - { - c = _mbsnextc(src); - if (c == val) - match = (unsigned char*)src; - if (!c) - return match; - src += (c > 255) ? 2 : 1; - } -} diff --git a/reactos/lib/crt/mbstring/mbsrev.c b/reactos/lib/crt/mbstring/mbsrev.c deleted file mode 100644 index fbd590fc134..00000000000 --- a/reactos/lib/crt/mbstring/mbsrev.c +++ /dev/null @@ -1,33 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned char * _mbsrev(unsigned char *s) -{ - unsigned char *e; - unsigned char a; - unsigned char *e2; - e=s; - while (*e) { - if ( _ismbblead(*e) ) { - a = *e; - e2 = e; - *e2 = *++e; - if ( *e == 0 ) - break; - *e = a; - } - e++; - } - while (s - -size_t _mbclen2(const unsigned int s); - -/* - * @implemented - */ -unsigned char * _mbsset(unsigned char *src, unsigned int c) -{ - unsigned char *char_src = src; - unsigned short *short_src = (unsigned short *)src; - - if ( _mbclen2(c) == 1 ) { - - while(*char_src != 0) { - *char_src = c; - char_src++; - } - *char_src = 0; - } - else { - while(*short_src != 0) { - *short_src = c; - short_src++; - } - *short_src = 0; - } - - return src; -} diff --git a/reactos/lib/crt/mbstring/mbsspn.c b/reactos/lib/crt/mbstring/mbsspn.c deleted file mode 100644 index 3d654feb0a7..00000000000 --- a/reactos/lib/crt/mbstring/mbsspn.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -/* - * FIXME not correct - * - * @unimplemented - */ -size_t _mbsspn(const unsigned char *s1, const unsigned char *s2) -{ - const unsigned char *p = s1, *spanp; - char c, sc; - - cont: - c = *p++; - for (spanp = s2; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (size_t)(p - 1) - (size_t)s1; -// - (char *)s1); -} diff --git a/reactos/lib/crt/mbstring/mbsspnp.c b/reactos/lib/crt/mbstring/mbsspnp.c deleted file mode 100644 index 07a698ae443..00000000000 --- a/reactos/lib/crt/mbstring/mbsspnp.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -/* - * FIXME not correct - * - * @unimplemented - */ -unsigned char * _mbsspnp(const unsigned char *s1, const unsigned char *s2) -{ - const unsigned char *p = s1, *spanp; - char c, sc; - - cont: - c = *p++; - for (spanp = s2; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (unsigned char *)p; -} diff --git a/reactos/lib/crt/mbstring/mbsstr.c b/reactos/lib/crt/mbstring/mbsstr.c deleted file mode 100644 index 318de319c70..00000000000 --- a/reactos/lib/crt/mbstring/mbsstr.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -/* - * @implemented - */ -unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2) -{ - int len; - - if (src2 ==NULL || *src2 == 0) - return (unsigned char *)src1; - - len = _mbslen(src2); - - while(*src1) - { - if ((*src1 == *src2) && (_mbsncmp(src1,src2,len) == 0)) - return (unsigned char *)src1; - src1 = (unsigned char *)_mbsinc(src1); - } - return NULL; -} diff --git a/reactos/lib/crt/mbstring/mbstok.c b/reactos/lib/crt/mbstring/mbstok.c deleted file mode 100644 index d575e73f3f5..00000000000 --- a/reactos/lib/crt/mbstring/mbstok.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -/* - * @implemented - */ -unsigned char * _mbstok(unsigned char *s, const unsigned char *delim) -{ - const unsigned char *spanp; - int c, sc; - unsigned char *tok; - static unsigned char *last; - - - if (s == NULL && (s = last) == NULL) - return (NULL); - - /* - * Skip (span) leading delimiters (s += strspn(s, delim), sort of). - */ - cont: - c = *s; - s = _mbsinc(s); - - for (spanp = delim; (sc = *spanp) != 0; spanp = _mbsinc(spanp)) { - if (c == sc) - goto cont; - } - - if (c == 0) { /* no non-delimiter characters */ - last = NULL; - return (NULL); - } - tok = s - 1; - - /* - * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). - * Note that delim must have one NUL; we stop if we see that, too. - */ - for (;;) { - c = *s; - s = _mbsinc(s); - spanp = delim; - do { - if ((sc = *spanp) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - last = s; - return (tok); - } - spanp = _mbsinc(spanp); - } while (sc != 0); - } - /* NOTREACHED */ -} diff --git a/reactos/lib/crt/mbstring/mbstrlen.c b/reactos/lib/crt/mbstring/mbstrlen.c deleted file mode 100644 index e4411f1f708..00000000000 --- a/reactos/lib/crt/mbstring/mbstrlen.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -/* - * @implemented - */ -size_t _mbstrlen( const char *string ) -{ - char *s = (char *)string; - size_t i = 0; - - while ( *s != 0 ) { - if ( _ismbblead(*s) ) - s++; - s++; - i++; - } - return i; -} diff --git a/reactos/lib/crt/mbstring/mbsupr.c b/reactos/lib/crt/mbstring/mbsupr.c deleted file mode 100644 index 8b713c561ff..00000000000 --- a/reactos/lib/crt/mbstring/mbsupr.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/mbstring/mbsupr.c - * PURPOSE: - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 12/04/99: Created - */ -#include -#include - -unsigned int _mbbtoupper(unsigned int c) -{ - if (!_ismbblead(c) ) - return toupper(c); - - return c; -} - -// codepage 952 -#define CASE_DIFF (0x8281 - 0x8260) - -/* - * @implemented - */ -unsigned int _mbctoupper(unsigned int c) -{ - - if ((c & 0xFF00) != 0) { -// true multibyte case conversion needed - if ( _ismbcupper(c) ) - return c + CASE_DIFF; - - } else - return _mbbtoupper(c); - - return 0; -} - -/* - * @implemented - */ -unsigned char * _mbsupr(unsigned char *x) -{ - unsigned char *y=x; - while (*y) { - if (!_ismbblead(*y) ) - *y = toupper(*y); - else { - *y=_mbctoupper(*(unsigned short *)y); - y++; - } - } - return x; -} diff --git a/reactos/lib/crt/misc/amsg.c b/reactos/lib/crt/misc/amsg.c deleted file mode 100644 index 8d5220e8e40..00000000000 --- a/reactos/lib/crt/misc/amsg.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/misc/amsg.c - * PURPOSE: Print runtime error messages - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -static char *__rt_err_msg[] = -{ - "stack overflow", /* _RT_STACK */ - "null pointer assignment", /* _RT_NULLPTR */ - "floating point not loaded", /* _RT_FLOAT */ - "integer divide by 0", /* _RT_INTDIV */ - "not enough space for arguments", /* _RT_SPACEARG */ - "not enough space for environment", /* _RT_SPACEENV */ - "abnormal program termination", /* _RT_ABORT */ - "not enough space for thread data", /* _RT_THREAD */ - "unexpected multithread lock error", /* _RT_LOCK */ - "unexpected heap error", /* _RT_HEAP */ - "unable to open console device", /* _RT_OPENCON */ - "non-continuable exception", /* _RT_NONCONT */ - "invalid exception disposition", /* _RT_INVALDISP */ - "not enough space for _onexit/atexit table", /* _RT_ONEXIT */ - "pure virtual function call", /* _RT_PUREVIRT */ - "not enough space for stdio initialization", /* _RT_STDIOINIT */ - "not enough space for lowio initialization", /* _RT_LOWIOINIT */ -}; - - -/* - * @implemented - */ -int _aexit_rtn(int exitcode) -{ - _exit(exitcode); - return 0; -} - -/* - * @implemented - */ -void _amsg_exit(int errnum) -{ - fprintf(stderr, "runtime error - %s\n", __rt_err_msg[errnum]); - _aexit_rtn(-1); -} - diff --git a/reactos/lib/crt/misc/assert.c b/reactos/lib/crt/misc/assert.c deleted file mode 100644 index f656976da1d..00000000000 --- a/reactos/lib/crt/misc/assert.c +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include - - -/* - * @implemented - */ -void _assert(const char *msg, const char *file, int line) -{ - /* Assertion failed at foo.c line 45: x - -#define NDEBUG -#include - -#ifndef __GNUC__ - -/* GLOBAL VARIABLES *******************************************************/ - -int _fltused; - - -/* FUNCTIONS **************************************************************/ - -/* - * @unimplemented - */ -int -STDCALL -_except_handler3(void) -{ - return 0; -} - -/* - * @unimplemented - */ -int -STDCALL -_local_unwind2(void) -{ - return 0; -} - -#else /*__GNUC__*/ - -#endif /*__GNUC__*/ - - -/* -int __cdecl _allmul(void) -{ - return 0; -} - -int __cdecl _allshl(void) -{ - return 0; -} - -void __cdecl _chkesp(int value1, int value2) -{ -} - -int __cdecl _alloca_probe(void) -{ - return 0; -} - -int STDCALL _abnormal_termination(void) -{ - return 0; -} - -int STDCALL _setjmp(void) -{ - return 0; -} -*/ -/* -BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved); - -int STDCALL _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) -{ - BOOL result; - - //__fileno_init(); - //result = DllMain(hInst, ul_reason_for_call, lpReserved); - - result = DllMain(hInst, DLL_PROCESS_ATTACH, lpReserved); - - - return (result ? 1 : 0); -} - */ - -/* EOF */ diff --git a/reactos/lib/crt/misc/environ.c b/reactos/lib/crt/misc/environ.c deleted file mode 100644 index 02f83455769..00000000000 --- a/reactos/lib/crt/misc/environ.c +++ /dev/null @@ -1,471 +0,0 @@ -/* $Id$ - * - * dllmain.c - * - * ReactOS MSVCRT.DLL Compatibility Library - */ - -#include -#include -#include -#include - -#define NDEBUG -#include - - -unsigned int _osver = 0; -unsigned int _winminor = 0; -unsigned int _winmajor = 0; -unsigned int _winver = 0; - - -char *_acmdln = NULL; /* pointer to ascii command line */ -wchar_t *_wcmdln = NULL; /* pointer to wide character command line */ -#undef _environ -#undef _wenviron -char **_environ = NULL; /* pointer to environment block */ -wchar_t **_wenviron = NULL; /* pointer to environment block */ -char **__initenv = NULL; /* pointer to initial environment block */ -wchar_t **__winitenv = NULL; /* pointer to initial environment block */ -#undef _pgmptr -char *_pgmptr = NULL; /* pointer to program name */ -#undef _wpgmptr -wchar_t *_wpgmptr = NULL; /* pointer to program name */ -int __app_type = 0; //_UNKNOWN_APP; /* application type */ -int __mb_cur_max = 1; - -int _commode = _IOCOMMIT; - - -int BlockEnvToEnvironA(void) -{ - char *ptr, *environment_strings; - char **envptr; - int count = 1, len; - - DPRINT("BlockEnvToEnvironA()\n"); - - environment_strings = GetEnvironmentStringsA(); - if (environment_strings == NULL) { - return -1; - } - - for (ptr = environment_strings; *ptr; ptr += len) - { - len = strlen(ptr) + 1; - /* Skip drive letter settings. */ - if (*ptr != '=') - count++; - } - - __initenv = _environ = malloc(count * sizeof(char*)); - if (_environ) - { - for (ptr = environment_strings, envptr = _environ; count > 1; ptr += len) - { - len = strlen(ptr) + 1; - /* Skip drive letter settings. */ - if (*ptr != '=') - { - if ((*envptr = malloc(len)) == NULL) - { - for (envptr--; envptr >= _environ; envptr--); - free(*envptr); - FreeEnvironmentStringsA(environment_strings); - free(_environ); - __initenv = _environ = NULL; - return -1; - } - memcpy(*envptr++, ptr, len); - count--; - } - } - /* Add terminating NULL entry. */ - *envptr = NULL; - } - - FreeEnvironmentStringsA(environment_strings); - return _environ ? 0 : -1; -} - -int BlockEnvToEnvironW(void) -{ - wchar_t *ptr, *environment_strings; - wchar_t **envptr; - int count = 1, len; - - DPRINT("BlockEnvToEnvironW()\n"); - - environment_strings = GetEnvironmentStringsW(); - if (environment_strings == NULL) { - return -1; - } - - for (ptr = environment_strings; *ptr; ptr += len) - { - len = wcslen(ptr) + 1; - /* Skip drive letter settings. */ - if (*ptr != '=') - count++; - } - - __winitenv = _wenviron = malloc(count * sizeof(wchar_t*)); - if (_wenviron) - { - for (ptr = environment_strings, envptr = _wenviron; count > 1; ptr += len) - { - len = wcslen(ptr) + 1; - /* Skip drive letter settings. */ - if (*ptr != '=') - { - if ((*envptr = malloc(len * sizeof(wchar_t))) == NULL) - { - for (envptr--; envptr >= _wenviron; envptr--); - free(*envptr); - FreeEnvironmentStringsW(environment_strings); - free(_wenviron); - __winitenv = _wenviron = NULL; - return -1; - } - memcpy(*envptr++, ptr, len * sizeof(wchar_t)); - count--; - } - } - /* Add terminating NULL entry. */ - *envptr = NULL; - } - - FreeEnvironmentStringsW(environment_strings); - return _wenviron ? 0 : -1; -} - -/** - * Internal function to duplicate environment block. Although it's - * parameter are defined as char**, it's able to work also with - * wide character environment block which are of type wchar_t**. - * - * @param original_environment - * Environment to duplicate. - * @param wide - * Set to zero for multibyte environments, non-zero otherwise. - * - * @return Original environment in case of failure, otherwise - * pointer to new environment block. - */ -char **DuplicateEnvironment(char **original_environment, int wide) -{ - int count = 1; - char **envptr, **newenvptr, **newenv; - - for (envptr = original_environment; *envptr != NULL; envptr++, count++) - ; - - newenvptr = newenv = malloc(count * sizeof(char*)); - if (newenv == NULL) - return original_environment; - - for (envptr = original_environment; count > 1; newenvptr++, count--) - { - if (wide) - *newenvptr = (char*)_wcsdup((wchar_t*)*envptr++); - else - *newenvptr = _strdup(*envptr++); - if (*newenvptr == NULL) - { - for (newenvptr--; newenvptr >= newenv; newenvptr--); - free(*newenvptr); - free(newenv); - return original_environment; - } - } - *newenvptr = NULL; - - return newenv; -} - -/** - * Internal function to deallocate environment block. Although it's - * parameter are defined as char**, it's able to work also with - * wide character environment block which are of type wchar_t**. - * - * @param environment - * Environment to free. - */ -void FreeEnvironment(char **environment) -{ - char **envptr; - for (envptr = environment; *envptr != NULL; envptr++) - free(*envptr); - free(environment); -} - -/** - * Internal version of _wputenv and _putenv. It works duplicates the - * original envirnments created during initilization if needed to prevent - * having spurious pointers floating around. Then it updates the internal - * environment tables (_environ and _wenviron) and at last updates the - * OS environemnt. - * - * Note that there can happen situation when the internal [_w]environ - * arrays will be updated, but the OS environment update will fail. In - * this case we don't undo the changes to the [_w]environ tables to - * comply with the Microsoft behaviour (and it's also much easier :-). - */ -int SetEnv(const wchar_t *option) -{ - wchar_t *epos, *name; - wchar_t **wenvptr; - wchar_t *woption; - char *mboption; - int remove, index, count, size, result = 0, found = 0; - - if (option == NULL || (epos = wcschr(option, L'=')) == NULL) - return -1; - remove = (epos[1] == 0); - - /* Duplicate environment if needed. */ - if (_environ == __initenv) - { - if ((_environ = DuplicateEnvironment(_environ, 0)) == __initenv) - return -1; - } - if (_wenviron == __winitenv) - { - if ((_wenviron = (wchar_t**)DuplicateEnvironment((char**)_wenviron, 1)) == - __winitenv) - return -1; - } - - /* Create a copy of the option name. */ - name = malloc((epos - option + 1) * sizeof(wchar_t)); - if (name == NULL) - return -1; - memcpy(name, option, (epos - option) * sizeof(wchar_t)); - name[epos - option] = 0; - - /* Find the option we're trying to modify. */ - for (index = 0, wenvptr = _wenviron; *wenvptr != NULL; wenvptr++, index++) - { - if (!_wcsnicmp(*wenvptr, option, epos - option)) - { - found = 1; - break; - } - } - - if (remove) - { - if (!found) - { - free(name); - return 0; - } - - /* Remove the option from wide character environment. */ - free(*wenvptr); - for (count = index; *wenvptr != NULL; wenvptr++, count++) - *wenvptr = *(wenvptr + 1); - _wenviron = realloc(_wenviron, count * sizeof(wchar_t*)); - - /* Remove the option from multibyte environment. We assume - * the environments are in sync and the option is at the - * same position. */ - free(_environ[index]); - memmove(&_environ[index], &_environ[index+1], (count - index) * sizeof(char*)); - _environ = realloc(_environ, count * sizeof(char*)); - - result = SetEnvironmentVariableW(name, NULL) ? 0 : -1; - } - else - { - /* Make a copy of the option that we will store in the environment block. */ - woption = _wcsdup((wchar_t*)option); - if (woption == NULL) - { - free(name); - return -1; - } - - /* Create a multibyte copy of the option. */ - size = WideCharToMultiByte(CP_ACP, 0, option, -1, NULL, 0, NULL, NULL); - mboption = malloc(size); - if (mboption == NULL) - { - free(name); - free(woption); - return -1; - } - WideCharToMultiByte(CP_ACP, 0, option, -1, mboption, size, NULL, NULL); - - if (found) - { - /* Replace the current entry. */ - free(*wenvptr); - *wenvptr = woption; - free(_environ[index]); - _environ[index] = mboption; - } - else - { - wchar_t **wnewenv; - char **mbnewenv; - - /* Get the size of the original environment. */ - for (count = index; *wenvptr != NULL; wenvptr++, count++) - ; - - /* Create a new entry. */ - if ((wnewenv = realloc(_wenviron, (count + 2) * sizeof(wchar_t*))) == NULL) - { - free(name); - free(mboption); - free(woption); - return -1; - } - _wenviron = wnewenv; - if ((mbnewenv = realloc(_environ, (count + 2) * sizeof(char*))) == NULL) - { - free(name); - free(mboption); - free(woption); - return -1; - } - _environ = mbnewenv; - - /* Set the last entry to our option. */ - _wenviron[count] = woption; - _environ[count] = mboption; - _wenviron[count + 1] = NULL; - _environ[count + 1] = NULL; - } - - /* And finally update the OS environment. */ - result = SetEnvironmentVariableW(name, epos + 1) ? 0 : -1; - } - free(name); - - return result; -} - -/* - * @implemented - */ -int *__p__commode(void) // not exported by NTDLL -{ - return &_commode; -} - -/* - * @implemented - */ -void __set_app_type(int app_type) -{ - __app_type = app_type; -} - -/* - * @implemented - */ -char **__p__acmdln(void) -{ - return &_acmdln; -} - -/* - * @implemented - */ -wchar_t **__p__wcmdln(void) -{ - return &_wcmdln; -} - -/* - * @implemented - */ -char ***__p__environ(void) -{ - return &_environ; -} - -/* - * @implemented - */ -wchar_t ***__p__wenviron(void) -{ - return &_wenviron; -} - -/* - * @implemented - */ -char ***__p___initenv(void) -{ - return &__initenv; -} - -/* - * @implemented - */ -wchar_t ***__p___winitenv(void) -{ - return &__winitenv; -} - -/* - * @implemented - */ -int *__p___mb_cur_max(void) -{ - return &__mb_cur_max; -} - -/* - * @implemented - */ -unsigned int *__p__osver(void) -{ - return &_osver; -} - -/* - * @implemented - */ -char **__p__pgmptr(void) -{ - return &_pgmptr; -} - -/* - * @implemented - */ -wchar_t **__p__wpgmptr(void) -{ - return &_wpgmptr; -} - -/* - * @implemented - */ -unsigned int *__p__winmajor(void) -{ - return &_winmajor; -} - -/* - * @implemented - */ -unsigned int *__p__winminor(void) -{ - return &_winminor; -} - -/* - * @implemented - */ -unsigned int *__p__winver(void) -{ - return &_winver; -} - -/* EOF */ diff --git a/reactos/lib/crt/misc/getargs.c b/reactos/lib/crt/misc/getargs.c deleted file mode 100644 index d8de6e2d9b4..00000000000 --- a/reactos/lib/crt/misc/getargs.c +++ /dev/null @@ -1,350 +0,0 @@ -#include -#include -#include - - -extern char*_acmdln; -extern wchar_t* _wcmdln; -#undef _pgmptr -extern char*_pgmptr; -#undef _wpgmptr -extern wchar_t*_wpgmptr; -#undef _environ -extern char**_environ; - -#undef __argv -#undef __argc - -char**__argv = NULL; -#undef __wargv -wchar_t**__wargv = NULL; -int __argc = 0; - -extern wchar_t **__winitenv; - -extern HANDLE hHeap; - -char* strndup(char* name, int len) -{ - char *s = malloc(len + 1); - if (s != NULL) - { - memcpy(s, name, len); - s[len] = 0; - } - return s; -} - -wchar_t* wcsndup(wchar_t* name, int len) -{ - wchar_t *s = malloc((len + 1) * sizeof(wchar_t)); - if (s != NULL) - { - memcpy(s, name, len*sizeof(wchar_t)); - s[len] = 0; - } - return s; -} - -#define SIZE (4096 / sizeof(char*)) - -int wadd(wchar_t* name) -{ - wchar_t** _new; - if ((__argc % SIZE) == 0) - { - if (__wargv == NULL) - _new = malloc(sizeof(wchar_t*) * (1 + SIZE)); - else - _new = realloc(__wargv, sizeof(wchar_t*) * (__argc + 1 + SIZE)); - if (_new == NULL) - return -1; - __wargv = _new; - } - __wargv[__argc++] = name; - __wargv[__argc] = NULL; - return 0; -} - -int wexpand(wchar_t* name, int expand_wildcards) -{ - wchar_t* s; - WIN32_FIND_DATAW fd; - HANDLE hFile; - BOOLEAN first = TRUE; - wchar_t buffer[256]; - int pos; - - if (expand_wildcards && (s = wcspbrk(name, L"*?"))) - { - hFile = FindFirstFileW(name, &fd); - if (hFile != INVALID_HANDLE_VALUE) - { - while(s != name && *s != L'/' && *s != L'\\') - s--; - pos = s - name; - if (*s == L'/' || *s == L'\\') - pos++; - wcsncpy(buffer, name, pos); - do - { - if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - wcscpy(&buffer[pos], fd.cFileName); - if (wadd(_wcsdup(buffer)) < 0) - { - FindClose(hFile); - return -1; - } - first = FALSE; - } - } - while(FindNextFileW(hFile, &fd)); - FindClose(hFile); - } - } - if (first) - { - if (wadd(name) < 0) - return -1; - } - else - free(name); - return 0; -} - -int aadd(char* name) -{ - char** _new; - if ((__argc % SIZE) == 0) - { - if (__argv == NULL) - _new = malloc(sizeof(char*) * (1 + SIZE)); - else - _new = realloc(__argv, sizeof(char*) * (__argc + 1 + SIZE)); - if (_new == NULL) - return -1; - __argv = _new; - } - __argv[__argc++] = name; - __argv[__argc] = NULL; - return 0; -} - -int aexpand(char* name, int expand_wildcards) -{ - char* s; - WIN32_FIND_DATAA fd; - HANDLE hFile; - BOOLEAN first = TRUE; - char buffer[256]; - int pos; - - if (expand_wildcards && (s = strpbrk(name, "*?"))) - { - hFile = FindFirstFileA(name, &fd); - if (hFile != INVALID_HANDLE_VALUE) - { - while(s != name && *s != '/' && *s != '\\') - s--; - pos = s - name; - if (*s == '/' || *s == '\\') - pos++; - strncpy(buffer, name, pos); - do - { - if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - strcpy(&buffer[pos], fd.cFileName); - if (aadd(_strdup(buffer)) < 0) - { - FindClose(hFile); - return -1; - } - first = FALSE; - } - } - while(FindNextFileA(hFile, &fd)); - FindClose(hFile); - } - } - if (first) - { - if (aadd(name) < 0) - return -1; - } - else - free(name); - return 0; -} - -/* - * @unimplemented - */ -void __getmainargs(int* argc, char*** argv, char*** env, int expand_wildcards, int* new_mode) -{ - int i, afterlastspace, ignorespace, len, doexpand; - - /* missing threading init */ - - i = 0; - afterlastspace = 0; - ignorespace = 0; - doexpand = expand_wildcards; - - len = strlen(_acmdln); - - while (_acmdln[i]) - { - if (_acmdln[i] == '"') - { - if(ignorespace) - { - ignorespace = 0; - } - else - { - ignorespace = 1; - doexpand = 0; - } - memmove(_acmdln + i, _acmdln + i + 1, len - i); - len--; - continue; - } - - if (_acmdln[i] == ' ' && !ignorespace) - { - aexpand(strndup(_acmdln + afterlastspace, i - afterlastspace), doexpand); - i++; - while (_acmdln[i]==' ') - i++; - afterlastspace=i; - doexpand = expand_wildcards; - } - else - { - i++; - } - } - - if (_acmdln[afterlastspace] != 0) - { - aexpand(strndup(_acmdln+afterlastspace, i - afterlastspace), doexpand); - } - - HeapValidate(hHeap, 0, NULL); - - *argc = __argc; - if (__argv == NULL) - { - __argv = (char**)malloc(sizeof(char*)); - __argv[0] = 0; - } - *argv = __argv; - *env = _environ; - _pgmptr = _strdup(__argv[0]); - - // if (new_mode) _set_new_mode(*new_mode); -} - -/* - * @unimplemented - */ -void __wgetmainargs(int* argc, wchar_t*** wargv, wchar_t*** wenv, - int expand_wildcards, int* new_mode) -{ - int i, afterlastspace, ignorespace, len, doexpand; - - /* missing threading init */ - - i = 0; - afterlastspace = 0; - ignorespace = 0; - doexpand = expand_wildcards; - - len = wcslen(_wcmdln); - - while (_wcmdln[i]) - { - if (_wcmdln[i] == L'"') - { - if(ignorespace) - { - ignorespace = 0; - } - else - { - ignorespace = 1; - doexpand = 0; - } - memmove(_wcmdln + i, _wcmdln + i + 1, (len - i) * sizeof(wchar_t)); - len--; - continue; - } - - if (_wcmdln[i] == L' ' && !ignorespace) - { - wexpand(wcsndup(_wcmdln + afterlastspace, i - afterlastspace), doexpand); - i++; - while (_wcmdln[i]==L' ') - i++; - afterlastspace=i; - doexpand = expand_wildcards; - } - else - { - i++; - } - } - - if (_wcmdln[afterlastspace] != 0) - { - wexpand(wcsndup(_wcmdln+afterlastspace, i - afterlastspace), doexpand); - } - - HeapValidate(hHeap, 0, NULL); - - *argc = __argc; - if (__wargv == NULL) - { - __wargv = (wchar_t**)malloc(sizeof(wchar_t*)); - __wargv[0] = 0; - } - *wargv = __wargv; - *wenv = __winitenv; - _wpgmptr = _wcsdup(__wargv[0]); - - // if (new_mode) _set_new_mode(*new_mode); -} - -/* - * @implemented - */ -int* __p___argc(void) -{ - return &__argc; -} - -/* - * @implemented - */ -char*** __p___argv(void) -{ - return &__argv; -} - -/* - * @implemented - */ -wchar_t*** __p___wargv(void) -{ - return &__wargv; -} - - -#if 0 -int _chkstk(void) -{ - return 0; -} -#endif diff --git a/reactos/lib/crt/misc/initterm.c b/reactos/lib/crt/misc/initterm.c deleted file mode 100644 index 54963ad9add..00000000000 --- a/reactos/lib/crt/misc/initterm.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - - -/* - * @implemented - */ -void _initterm(void (*fStart[])(void), void (*fEnd[])(void)) -{ - int i = 0; - - if ( fStart == NULL || fEnd == NULL ) - return; - - while ( &fStart[i] < fEnd ) - { - if ( fStart[i] != NULL ) - (*fStart[i])(); - i++; - } -} diff --git a/reactos/lib/crt/misc/lock.c b/reactos/lib/crt/misc/lock.c deleted file mode 100644 index 989be017d25..00000000000 --- a/reactos/lib/crt/misc/lock.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2002, TransGaming Technologies Inc. - * - * 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 - -#define NDEBUG -#include -#include - -typedef struct -{ - BOOL bInit; - CRITICAL_SECTION crit; -} LOCKTABLEENTRY; - -static LOCKTABLEENTRY lock_table[ _TOTAL_LOCKS ]; - -static __inline void msvcrt_mlock_set_entry_initialized( int locknum, BOOL initialized ) -{ - lock_table[ locknum ].bInit = initialized; -} - -static __inline void msvcrt_initialize_mlock( int locknum ) -{ - InitializeCriticalSection( &(lock_table[ locknum ].crit) ); - msvcrt_mlock_set_entry_initialized( locknum, TRUE ); -} - -static __inline void msvcrt_uninitialize_mlock( int locknum ) -{ - DeleteCriticalSection( &(lock_table[ locknum ].crit) ); - msvcrt_mlock_set_entry_initialized( locknum, FALSE ); -} - -/********************************************************************** - * msvcrt_init_mt_locks (internal) - * - * Initialize the table lock. All other locks will be initialized - * upon first use. - * - */ -void msvcrt_init_mt_locks(void) -{ - int i; - - DPRINT( "initializing mtlocks\n" ); - - /* Initialize the table */ - for( i=0; i < _TOTAL_LOCKS; i++ ) - { - msvcrt_mlock_set_entry_initialized( i, FALSE ); - } - - /* Initialize our lock table lock */ - msvcrt_initialize_mlock( _LOCKTAB_LOCK ); -} - -/********************************************************************** - * msvcrt_free_mt_locks (internal) - * - * Uninitialize all mt locks. Assume that neither _lock or _unlock will - * be called once we're calling this routine (ie _LOCKTAB_LOCK can be deleted) - * - */ -void msvcrt_free_mt_locks(void) -{ - int i; - - DPRINT(": uninitializing all mtlocks\n" ); - - /* Uninitialize the table */ - for( i=0; i < _TOTAL_LOCKS; i++ ) - { - if( lock_table[ i ].bInit == TRUE ) - { - msvcrt_uninitialize_mlock( i ); - } - } -} - - -/********************************************************************** - * _lock (MSVCRT.@) - */ -void _lock( int locknum ) -{ - DPRINT( "(%d)\n", locknum ); - - /* If the lock doesn't exist yet, create it */ - if( lock_table[ locknum ].bInit == FALSE ) - { - /* Lock while we're changing the lock table */ - _lock( _LOCKTAB_LOCK ); - - /* Check again if we've got a bit of a race on lock creation */ - if( lock_table[ locknum ].bInit == FALSE ) - { - DPRINT( ": creating lock #%d\n", locknum ); - msvcrt_initialize_mlock( locknum ); - } - - /* Unlock ourselves */ - _unlock( _LOCKTAB_LOCK ); - } - - EnterCriticalSection( &(lock_table[ locknum ].crit) ); -} - -/********************************************************************** - * _unlock (MSVCRT.@) - * - * NOTE: There is no error detection to make sure the lock exists and is acquired. - */ -void _unlock( int locknum ) -{ - DPRINT( "(%d)\n", locknum ); - - LeaveCriticalSection( &(lock_table[ locknum ].crit) ); -} - diff --git a/reactos/lib/crt/misc/purecall.c b/reactos/lib/crt/misc/purecall.c deleted file mode 100644 index 28612a9aaf5..00000000000 --- a/reactos/lib/crt/misc/purecall.c +++ /dev/null @@ -1,10 +0,0 @@ - -#include - -/* - * @implemented - */ -void _purecall(void) -{ - _amsg_exit(_RT_PUREVIRT); -} diff --git a/reactos/lib/crt/misc/stubs.c b/reactos/lib/crt/misc/stubs.c deleted file mode 100644 index dd7e8bf3d15..00000000000 --- a/reactos/lib/crt/misc/stubs.c +++ /dev/null @@ -1,144 +0,0 @@ -#include - -#define NDEBUG -#include - -/********************************************************************* - * $I10_OUTPUT (MSVCRT.@) - * Function not really understood but needed to make the DLL work - */ -void MSVCRT_I10_OUTPUT(void) -{ - /* FIXME: This is probably data, not a function */ -} - -/*********************************************************************** - * _adj_fdiv_m32 (MSVCRT.@) - * - * NOTE - * I _think_ this function is intended to work around the Pentium - * fdiv bug. - */ -void __stdcall _adj_fdiv_m32( unsigned int arg ) -{ - DPRINT1("_adj_fdiv_m32 stub\n"); -} - -/*********************************************************************** - * _adj_fdiv_m32i (MSVCRT.@) - * - * NOTE - * I _think_ this function is intended to work around the Pentium - * fdiv bug. - */ -void __stdcall _adj_fdiv_m32i( int arg ) -{ - DPRINT1("_adj_fdiv_m32i stub\n"); -} - -/*********************************************************************** - * _adj_fdiv_m64 (MSVCRT.@) - * - * NOTE - * I _think_ this function is intended to work around the Pentium - * fdiv bug. - */ -void __stdcall _adj_fdiv_m64( unsigned __int64 arg ) -{ - DPRINT1("_adj_fdiv_m64 stub\n"); -} - -/*********************************************************************** - * _adj_fdiv_r (MSVCRT.@) - * FIXME - * This function is likely to have the wrong number of arguments. - * - * NOTE - * I _think_ this function is intended to work around the Pentium - * fdiv bug. - */ -void _adj_fdiv_r(void) -{ - DPRINT1("_adj_fdiv_r stub\n"); -} - -/*********************************************************************** - * _adj_fdivr_m32 (MSVCRT.@) - * - * NOTE - * I _think_ this function is intended to work around the Pentium - * fdiv bug. - */ -void __stdcall _adj_fdivr_m32( unsigned int arg ) -{ - DPRINT1("_adj_fdivr_m32i stub\n"); -} - -/*********************************************************************** - * _adj_fdivr_m32i (MSVCRT.@) - * - * NOTE - * I _think_ this function is intended to work around the Pentium - * fdiv bug. - */ -void __stdcall _adj_fdivr_m32i( int arg ) -{ - DPRINT1("_adj_fdivr_m32i stub\n"); -} - -/*********************************************************************** - * _adj_fdivr_m64 (MSVCRT.@) - * - * NOTE - * I _think_ this function is intended to work around the Pentium - * fdiv bug. - */ -void __stdcall _adj_fdivr_m64( unsigned __int64 arg ) -{ - DPRINT1("_adj_fdivr_m64 stub\n"); -} - -/*********************************************************************** - * _adj_fpatan (MSVCRT.@) - * FIXME - * This function is likely to have the wrong number of arguments. - * - * NOTE - * I _think_ this function is intended to work around the Pentium - * fdiv bug. - */ -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 deleted file mode 100644 index 71723211106..00000000000 --- a/reactos/lib/crt/misc/tls.c +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include -#include -#include - - -static unsigned long TlsIndex = (unsigned long)-1; - - -static void InitThreadData(PTHREADDATA ThreadData) -{ - ThreadData->terrno = 0; - ThreadData->tdoserrno = 0; - - ThreadData->fpecode = 0; - - ThreadData->tnext = 1; - - /* FIXME: init more thread local data */ - -} - - -int CreateThreadData(void) -{ - PTHREADDATA ThreadData; - - TlsIndex = TlsAlloc(); - if (TlsIndex == (unsigned long)-1) - return FALSE; - - ThreadData = (PTHREADDATA)calloc(1, sizeof(THREADDATA)); - if (ThreadData == NULL) - return FALSE; - - if(!TlsSetValue(TlsIndex, (LPVOID)ThreadData)) - return FALSE; - - InitThreadData(ThreadData); - - return TRUE; -} - - -void DestroyThreadData(void) -{ - if (TlsIndex != (unsigned long)-1) - { - TlsFree(TlsIndex); - TlsIndex = (unsigned long)-1; - } -} - - -void FreeThreadData(PTHREADDATA ThreadData) -{ - if (TlsIndex != (unsigned long)-1) - { - if (ThreadData == NULL) - ThreadData = TlsGetValue(TlsIndex); - - if (ThreadData != NULL) - { - /* FIXME: free more thread local data */ - - free(ThreadData); - } - - TlsSetValue(TlsIndex, NULL); - } -} - - -PTHREADDATA GetThreadData(void) -{ - PTHREADDATA ThreadData; - DWORD LastError; - - LastError = GetLastError(); - ThreadData = TlsGetValue(TlsIndex); - if (ThreadData == NULL) - { - ThreadData = (PTHREADDATA)calloc(1, sizeof(THREADDATA)); - if (ThreadData != NULL) - { - TlsSetValue(TlsIndex, (LPVOID)ThreadData); - - InitThreadData(ThreadData); - } - else - { - _amsg_exit(_RT_THREAD); /* write message and die */ - } - } - - SetLastError(LastError); - - return ThreadData; -} - -/* EOF */ - diff --git a/reactos/lib/crt/precomp.h b/reactos/lib/crt/precomp.h deleted file mode 100644 index 800909853c6..00000000000 --- a/reactos/lib/crt/precomp.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _CRT_PRECOMP_H -#define _CRT_PRECOMP_H - -/* We don't want to use the Microsoft CRT inline functions - so we hack around them in msvc build */ -#define _INC_WTIME_INL -#define _INC_UTIME_INL -#define _INC_TIME_INL - -/* Headers to be compiled */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* PSDK/NDK Headers */ -#define WIN32_NO_STATUS -#include -#include -#include - -#if !defined(_MSC_VER) - #include -#endif - -/* CRT Internal data */ -#include -#include -#include -#include -#include - -#endif /* _CRT_PRECOMP_H */ diff --git a/reactos/lib/crt/process/_cwait.c b/reactos/lib/crt/process/_cwait.c deleted file mode 100644 index 180e0eb0d37..00000000000 --- a/reactos/lib/crt/process/_cwait.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/process/cwait.c - * PURPOSE: Waits for a process to exit - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 04/03/99: Created - */ - -#include - -/* - * @implemented - */ -int _cwait(int* pnStatus, int hProc, int nAction) -{ - DWORD ExitCode; - - nAction = 0; - if (WaitForSingleObject((void*)ULongToPtr(hProc), INFINITE) != WAIT_OBJECT_0) { - __set_errno(ECHILD); - return -1; - } - - if (!GetExitCodeProcess((void*)ULongToPtr(hProc), &ExitCode)) - return -1; - if (pnStatus != NULL) - *pnStatus = (int)ExitCode; - CloseHandle((HANDLE)ULongToPtr(hProc)); - return hProc; -} diff --git a/reactos/lib/crt/process/_system.c b/reactos/lib/crt/process/_system.c deleted file mode 100644 index 937277fa63e..00000000000 --- a/reactos/lib/crt/process/_system.c +++ /dev/null @@ -1,114 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/process/system.c - * PURPOSE: Excutes a shell command - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 04/03/99: Created - */ - -#include -#include -#include -#include - -/* - * @implemented - */ -int system(const char *command) -{ - char *szCmdLine = NULL; - char *szComSpec = NULL; - - PROCESS_INFORMATION ProcessInformation; - STARTUPINFOA StartupInfo; - char *s; - BOOL result; - - int nStatus; - - szComSpec = getenv("COMSPEC"); - -// system should return 0 if command is null and the shell is found - - if (command == NULL) { - if (szComSpec == NULL) - return 0; - else - return -1; - } - -// should return 127 or 0 ( MS ) if the shell is not found -// __set_errno(ENOENT); - - if (szComSpec == NULL) - { - szComSpec = "cmd.exe"; - } - - /* split the path from shell command */ - s = max(strrchr(szComSpec, '\\'), strrchr(szComSpec, '/')); - if (s == NULL) - s = szComSpec; - else - s++; - - szCmdLine = malloc(strlen(s) + 4 + strlen(command) + 1); - if (szCmdLine == NULL) - { - __set_errno(ENOMEM); - return -1; - } - - strcpy(szCmdLine, s); - s = strrchr(szCmdLine, '.'); - if (s) - *s = 0; - strcat(szCmdLine, " /C "); - strcat(szCmdLine, command); - -//command file has invalid format ENOEXEC - - memset (&StartupInfo, 0, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(StartupInfo); - StartupInfo.lpReserved= NULL; - StartupInfo.dwFlags = STARTF_USESHOWWINDOW; - StartupInfo.wShowWindow = SW_SHOWDEFAULT; - StartupInfo.lpReserved2 = NULL; - StartupInfo.cbReserved2 = 0; - -// According to ansi standards the new process should ignore SIGINT and SIGQUIT -// In order to disable ctr-c the process is created with CREATE_NEW_PROCESS_GROUP, -// thus SetConsoleCtrlHandler(NULL,TRUE) is made on behalf of the new process. - - -//SIGCHILD should be blocked aswell - - result = CreateProcessA(szComSpec, - szCmdLine, - NULL, - NULL, - TRUE, - CREATE_NEW_PROCESS_GROUP, - NULL, - NULL, - &StartupInfo, - &ProcessInformation); - free(szCmdLine); - - if (result == FALSE) - { - _dosmaperr(GetLastError()); - return -1; - } - - CloseHandle(ProcessInformation.hThread); - -// system should wait untill the calling process is finished - _cwait(&nStatus,(int)ProcessInformation.hProcess,0); - CloseHandle(ProcessInformation.hProcess); - - return nStatus; -} diff --git a/reactos/lib/crt/process/dll.c b/reactos/lib/crt/process/dll.c deleted file mode 100644 index def42b721dc..00000000000 --- a/reactos/lib/crt/process/dll.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/process/dll.c - * PURPOSE: Dll support routines - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 04/03/99: Created - */ - -#include - -/* - * @implemented - */ -intptr_t _loaddll(char* name) -{ - return (intptr_t) LoadLibraryA(name); -} - -/* - * @implemented - */ -int _unloaddll(intptr_t handle) -{ - return FreeLibrary((HMODULE) handle); -} - -/* - * @implemented - */ -FARPROC _getdllprocaddr(intptr_t hModule, char* lpProcName, intptr_t iOrdinal) -{ - if (lpProcName != NULL) - return GetProcAddress((HMODULE) hModule, lpProcName); - else - return GetProcAddress((HMODULE) hModule, (LPSTR)iOrdinal); - return (NULL); -} diff --git a/reactos/lib/crt/process/process.c b/reactos/lib/crt/process/process.c deleted file mode 100644 index 2ba21df33c4..00000000000 --- a/reactos/lib/crt/process/process.c +++ /dev/null @@ -1,648 +0,0 @@ -#include -#include -#include - -#define NDEBUG -#include - -#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 - - -_TCHAR const* extT[] = - { - _T(""), - _T(".bat"), - _T(".cmd"), - _T(".com"), - _T(".exe") - }; - -const _TCHAR* find_execT(const _TCHAR* path, _TCHAR* rpath) -{ - _TCHAR *rp; - const _TCHAR *rd; - unsigned int i, found = 0; - - DPRINT(MK_STR(find_execT)"('%"sT"', %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]); - - DPRINT("trying '%"sT"'\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]); - - DPRINT("trying '%"sT"'\n", rpath); - - if (_taccess(rpath, F_OK) == 0 && access_dirT(rpath) != 0) - { - found = 1; - break; - } - } - } - } - } - - return found ? rpath : path; -} - -static _TCHAR* -argvtosT(const _TCHAR* const* argv, _TCHAR delim) -{ - int i, len; - _TCHAR *ptr, *str; - - if (argv == NULL) - return NULL; - - for (i = 0, len = 0; argv[i]; i++) - { - len += _tcslen(argv[i]) + 1; - } - - str = ptr = (_TCHAR*) malloc(len + 1); - if (str == NULL) - return NULL; - - for(i = 0; argv[i]; i++) - { - len = _tcslen(argv[i]); - memcpy(ptr, argv[i], len * sizeof(_TCHAR)); - ptr += len; - *ptr++ = delim; - } - *ptr = 0; - - return str; -} - -static _TCHAR* -valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim) -{ - va_list alist2 = alist; - _TCHAR *ptr, *str; - int len; - - if (arg0 == NULL) - return NULL; - - ptr = (_TCHAR*)arg0; - len = 0; - do - { - len += _tcslen(ptr) + 1; - ptr = va_arg(alist, _TCHAR*); - } - while(ptr != NULL); - - str = (_TCHAR*) malloc(len + 1); - if (str == NULL) - return NULL; - - ptr = str; - do - { - len = _tcslen(arg0); - memcpy(ptr, arg0, len * sizeof(_TCHAR)); - ptr += len; - *ptr++ = delim; - arg0 = va_arg(alist2, _TCHAR*); - } - while(arg0 != NULL); - *ptr = 0; - - return str; -} - -static int -do_spawnT(int mode, const _TCHAR* cmdname, const _TCHAR* args, const _TCHAR* envp) -{ - STARTUPINFO StartupInfo = {0}; - PROCESS_INFORMATION ProcessInformation; -// char* fmode; -// HANDLE* hFile; -// int i, last; - BOOL bResult; - DWORD dwExitCode; - DWORD dwError; - - 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 (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 - - for (last = i = 0; i < FDINFO_FD_MAX; 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; - } - - *(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 - - 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); - } - - if (!bResult) - { - dwError = GetLastError(); - DPRINT("%x\n", dwError); - __set_errno(dwError); - return(-1); - } - CloseHandle(ProcessInformation.hThread); - switch(mode) - { - case _P_NOWAIT: - case _P_NOWAITO: - return((int)ProcessInformation.hProcess); - case _P_OVERLAY: - CloseHandle(ProcessInformation.hProcess); - _exit(0); - case _P_WAIT: - WaitForSingleObject(ProcessInformation.hProcess, INFINITE); - GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode); - CloseHandle(ProcessInformation.hProcess); - return( (int)dwExitCode); //CORRECT? - case _P_DETACH: - CloseHandle(ProcessInformation.hProcess); - return( 0); - } - return( (int)ProcessInformation.hProcess); -} - -/* - * @implemented - */ -int _tspawnl(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ...) -{ - va_list argp; - _TCHAR* args; - int ret = -1; - - DPRINT(MK_STR(_tspawnl)"('%"sT"')\n", cmdname); - - va_start(argp, arg0); - args = valisttosT(arg0, argp, ' '); - - if (args) - { - ret = do_spawnT(mode, cmdname, args, NULL); - free(args); - } - return ret; -} - -/* - * @implemented - */ -int _tspawnv(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv) -{ - _TCHAR* args; - int ret = -1; - - DPRINT(MK_STR(_tspawnv)"('%"sT"')\n", cmdname); - - args = argvtosT(argv, ' '); - - if (args) - { - ret = do_spawnT(mode, cmdname, args, NULL); - free(args); - } - return ret; -} - -/* - * @implemented - */ -int _tspawnle(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ... /*, NULL, const char* const* envp*/) -{ - va_list argp; - _TCHAR* args; - _TCHAR* envs; - _TCHAR const * const* ptr; - int ret = -1; - - 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; - -} - -/* - * @implemented - */ -int _tspawnve(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp) -{ - _TCHAR *args; - _TCHAR *envs; - int ret = -1; - - DPRINT(MK_STR(_tspawnve)"('%"sT"')\n", cmdname); - - args = argvtosT(argv, ' '); - envs = argvtosT(envp, 0); - - if (args) - { - ret = do_spawnT(mode, cmdname, args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; -} - -/* - * @implemented - */ -int _tspawnvp(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv) -{ - _TCHAR pathname[FILENAME_MAX]; - - DPRINT(MK_STR(_tspawnvp)"('%"sT"')\n", cmdname); - - return _tspawnv(mode, find_execT(cmdname, pathname), argv); -} - -/* - * @implemented - */ -int _tspawnlp(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL*/) -{ - va_list argp; - _TCHAR* args; - int ret = -1; - _TCHAR pathname[FILENAME_MAX]; - - DPRINT(MK_STR(_tspawnlp)"('%"sT"')\n", cmdname); - - 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 _tspawnlpe(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL, const char* const* envp*/) -{ - va_list argp; - _TCHAR* args; - _TCHAR* envs; - _TCHAR const* const * ptr; - int ret = -1; - _TCHAR pathname[FILENAME_MAX]; - - DPRINT(MK_STR(_tspawnlpe)"('%"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, find_execT(cmdname, pathname), args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; -} - -/* - * @implemented - */ -int _tspawnvpe(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp) -{ - _TCHAR pathname[FILENAME_MAX]; - - DPRINT(MK_STR(_tspawnvpe)"('%"sT"')\n", cmdname); - - return _tspawnve(mode, find_execT(cmdname, pathname), argv, envp); -} - -/* - * @implemented - */ -int _texecl(const _TCHAR* cmdname, const _TCHAR* arg0, ...) -{ - _TCHAR* args; - va_list argp; - int ret = -1; - - DPRINT(MK_STR(_texecl)"('%"sT"')\n", cmdname); - - va_start(argp, arg0); - args = valisttosT(arg0, argp, ' '); - - if (args) - { - ret = do_spawnT(P_OVERLAY, cmdname, args, NULL); - free(args); - } - return ret; -} - -/* - * @implemented - */ -int _texecv(const _TCHAR* cmdname, const _TCHAR* const* argv) -{ - DPRINT(MK_STR(_texecv)"('%"sT"')\n", cmdname); - return _tspawnv(P_OVERLAY, cmdname, argv); -} - -/* - * @implemented - */ -int _texecle(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* const* envp */) -{ - va_list argp; - _TCHAR* args; - _TCHAR* envs; - _TCHAR const* const* ptr; - int ret = -1; - - DPRINT(MK_STR(_texecle)"('%"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(P_OVERLAY, cmdname, args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; -} - -/* - * @implemented - */ -int _texecve(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp) -{ - DPRINT(MK_STR(_texecve)"('%"sT"')\n", cmdname); - return _tspawnve(P_OVERLAY, cmdname, argv, envp); -} - -/* - * @implemented - */ -int _texeclp(const _TCHAR* cmdname, const _TCHAR* arg0, ...) -{ - _TCHAR* args; - va_list argp; - int ret = -1; - _TCHAR pathname[FILENAME_MAX]; - - DPRINT(MK_STR(_texeclp)"('%"sT"')\n", cmdname); - - va_start(argp, arg0); - args = valisttosT(arg0, argp, ' '); - - if (args) - { - ret = do_spawnT(P_OVERLAY, find_execT(cmdname, pathname), args, NULL); - free(args); - } - return ret; -} - -/* - * @implemented - */ -int _texecvp(const _TCHAR* cmdname, const _TCHAR* const* argv) -{ - DPRINT(MK_STR(_texecvp)"('%"sT"')\n", cmdname); - return _tspawnvp(P_OVERLAY, cmdname, argv); -} - -/* - * @implemented - */ -int _texeclpe(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* const* envp */) -{ - va_list argp; - _TCHAR* args; - _TCHAR* envs; - _TCHAR const* const* ptr; - int ret = -1; - _TCHAR pathname[FILENAME_MAX]; - - DPRINT(MK_STR(_texeclpe)"('%"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(P_OVERLAY, find_execT(cmdname, pathname), args, envs); - free(args); - } - if (envs) - { - free(envs); - } - return ret; -} - -/* - * @implemented - */ -int _texecvpe(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* 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 deleted file mode 100644 index b4dd9f585d0..00000000000 --- a/reactos/lib/crt/process/procid.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -/* - * @implemented - */ -int _getpid (void) -{ - return (int)GetCurrentProcessId(); -} - diff --git a/reactos/lib/crt/process/thread.c b/reactos/lib/crt/process/thread.c deleted file mode 100644 index d058d7252e2..00000000000 --- a/reactos/lib/crt/process/thread.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -#if 0 -/* - * @unimplemented - */ -unsigned long _beginthread( - void (__cdecl *start_address)(void*), - unsigned stack_size, - void* arglist) -{ - __set_errno ( ENOSYS ); - return (unsigned long)-1; -} -#endif -/* - * @unimplemented - */ -void _endthread(void) -{ -} - -/* EOF */ diff --git a/reactos/lib/crt/process/threadid.c b/reactos/lib/crt/process/threadid.c deleted file mode 100644 index 50ab6336795..00000000000 --- a/reactos/lib/crt/process/threadid.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -unsigned long __threadid (void) -{ - return GetCurrentThreadId(); -} - -/* - * @implemented - */ -uintptr_t __threadhandle() -{ - return (uintptr_t)GetCurrentThread(); -} diff --git a/reactos/lib/crt/process/threadx.c b/reactos/lib/crt/process/threadx.c deleted file mode 100644 index cf94a02c4b8..00000000000 --- a/reactos/lib/crt/process/threadx.c +++ /dev/null @@ -1,44 +0,0 @@ -#include - -/* - * @unimplemented - */ -unsigned long _beginthreadex( - void* security, - unsigned stack_size, - unsigned (__stdcall *start_address)(void*), - void* arglist, - unsigned initflag, - unsigned* thrdaddr) -{ - HANDLE NewThread; - - /* - * Just call the API function. Any CRT specific processing is done in - * DllMain DLL_THREAD_ATTACH - */ - NewThread = CreateThread ( security, stack_size, - (LPTHREAD_START_ROUTINE)start_address, - arglist, initflag, (PULONG)thrdaddr ); - if (NULL == NewThread) - { - _dosmaperr( GetLastError() ); - } - - return (unsigned long) NewThread; -} - - -/* - * @implemented - */ -void _endthreadex(unsigned retval) -{ - /* - * Just call the API function. Any CRT specific processing is done in - * DllMain DLL_THREAD_DETACH - */ - ExitThread(retval); -} - -/* EOF */ diff --git a/reactos/lib/crt/process/wprocess.c b/reactos/lib/crt/process/wprocess.c deleted file mode 100644 index 8b7a08a4441..00000000000 --- a/reactos/lib/crt/process/wprocess.c +++ /dev/null @@ -1,4 +0,0 @@ -#define _UNICODE -#define UNICODE - -#include "process.c" diff --git a/reactos/lib/crt/search/lfind.c b/reactos/lib/crt/search/lfind.c deleted file mode 100644 index 1a034769a5d..00000000000 --- a/reactos/lib/crt/search/lfind.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -void *_lfind(const void *key, const void *base, size_t *nelp, - size_t width, int (*compar)(const void *, const void *)) -{ - char* char_base = (char*)base; - unsigned int i; - - for (i = 0; i < *nelp; i++) { - if (compar(key, char_base) == 0) - return char_base; - char_base += width; - } - return NULL; -} - diff --git a/reactos/lib/crt/search/lsearch.c b/reactos/lib/crt/search/lsearch.c deleted file mode 100644 index 07ca9b80740..00000000000 --- a/reactos/lib/crt/search/lsearch.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -void *_lsearch(const void *key, void *base, size_t *nelp, size_t width, - int (*compar)(const void *, const void *)) -{ - void *ret_find = _lfind(key,base,nelp,width,compar); - - if (ret_find != NULL) - return ret_find; - - memcpy((void*)((int*)base + (*nelp*width)), key, width); - - (*nelp)++; - return base; -} - diff --git a/reactos/lib/crt/setjmp/i386/setjmp.s b/reactos/lib/crt/setjmp/i386/setjmp.s deleted file mode 100644 index 7cf257cca24..00000000000 --- a/reactos/lib/crt/setjmp/i386/setjmp.s +++ /dev/null @@ -1,111 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * PURPOSE: Implementation of _setjmp/longjmp - * FILE: lib/msvcrt/i386/setjmp.s - * PROGRAMMER: Ge van Geldorp (ge@gse.nl) - * NOTES: Implementation is not complete, see Wine source for a more - * complete implementation - */ - -#define JB_BP 0 -#define JB_BX 1 -#define JB_DI 2 -#define JB_SI 3 -#define JB_SP 4 -#define JB_IP 5 - -#define PCOFF 0 - -#define JMPBUF 4 - -/* - * int - * _setjmp(jmp_buf env); - * - * Parameters: - * [ESP+04h] - jmp_buf env - * Registers: - * None - * Returns: - * 0 - * Notes: - * Sets up the jmp_buf - */ -.globl __setjmp -__setjmp: - xorl %eax, %eax - movl JMPBUF(%esp), %edx - - /* Save registers. */ - movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */ - movl %ebx, (JB_BX*4)(%edx) - movl %edi, (JB_DI*4)(%edx) - movl %esi, (JB_SI*4)(%edx) - leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */ - movl %ecx, (JB_SP*4)(%edx) - movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */ - movl %ecx, (JB_IP*4)(%edx) - ret - -/* - * int - * _setjmp3(jmp_buf env, int nb_args, ...); - * - * Parameters: - * [ESP+04h] - jmp_buf env - * Registers: - * None - * Returns: - * 0 - * Notes: - * Sets up the jmp_buf - */ -.globl __setjmp3 -__setjmp3: - xorl %eax, %eax - movl JMPBUF(%esp), %edx - - /* Save registers. */ - movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */ - movl %ebx, (JB_BX*4)(%edx) - movl %edi, (JB_DI*4)(%edx) - movl %esi, (JB_SI*4)(%edx) - leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */ - movl %ecx, (JB_SP*4)(%edx) - movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */ - movl %ecx, (JB_IP*4)(%edx) - ret - -#define VAL 8 - -/* - * void - * longjmp(jmp_buf env, int value); - * - * Parameters: - * [ESP+04h] - jmp_buf setup by _setjmp - * [ESP+08h] - int value to return - * Registers: - * None - * Returns: - * Doesn't return - * Notes: - * Non-local goto - */ -.globl _longjmp -_longjmp: - movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */ - - movl VAL(%esp), %eax /* Second argument is return value. */ - /* Save the return address now. */ - movl (JB_IP*4)(%ecx), %edx - /* Restore registers. */ - movl (JB_BP*4)(%ecx), %ebp - movl (JB_BX*4)(%ecx), %ebx - movl (JB_DI*4)(%ecx), %edi - movl (JB_SI*4)(%ecx), %esi - movl (JB_SP*4)(%ecx), %esp - /* Jump to saved PC. */ - jmp *%edx diff --git a/reactos/lib/crt/signal/signal.c b/reactos/lib/crt/signal/signal.c deleted file mode 100644 index 07b7dd3dc9d..00000000000 --- a/reactos/lib/crt/signal/signal.c +++ /dev/null @@ -1,144 +0,0 @@ -#include - -#include -#include -#include - -void _default_handler(int signal); - -typedef void (*__p_sig_fn_t)(int); - - -typedef struct _sig_element -{ - int signal; - char *signame; - __p_sig_fn_t handler; -} -sig_element; - - -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 - */ -//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; - unsigned int i; - - switch (sig) - { - case SIGINT: - case SIGILL: - case SIGFPE: - case SIGSEGV: - case SIGTERM: - case SIGBREAK: - case SIGABRT: - break; - - default: - __set_errno(EINVAL); - return SIG_ERR; - } - - // check with IsBadCodePtr - if ( func < (__p_sig_fn_t)4096 && func != SIG_DFL && func != SIG_IGN) - { - __set_errno(EINVAL); - return SIG_ERR; - } - - for(i=0; i < sizeof(signal_list)/sizeof(signal_list[0]); i++) - { - if ( signal_list[i].signal == sig ) - { - temp = signal_list[i].handler; - signal_list[i].handler = func; - return temp; - } - } - - /* should be impossible to get here */ - __set_errno(EINVAL); - return SIG_ERR; -} - - -/* - * @implemented - */ -int -raise(int sig) -{ - __p_sig_fn_t temp = 0; - unsigned int i; - - switch (sig) - { - case SIGINT: - case SIGILL: - case SIGFPE: - case SIGSEGV: - case SIGTERM: - case SIGBREAK: - case SIGABRT: - break; - - default: - //FIXME: set last err? - return -1; - } - - - // if(sig <= 0) - // return -1; - // if(sig > SIGMAX) - // return -1; - - for(i=0;i - -/* - * @unimplemented - */ -void **__pxcptinfoptrs (void) -{ - return NULL; -} diff --git a/reactos/lib/crt/stdio/allocfil.c b/reactos/lib/crt/stdio/allocfil.c deleted file mode 100644 index 48773382884..00000000000 --- a/reactos/lib/crt/stdio/allocfil.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include - -char __validfp (FILE *f) -{ - if ( (unsigned int)f < 256) - return FALSE; - - if( f == NULL || (int)f== -1 ) - return FALSE; - - return TRUE; -} - -/* A FILE* is considered "free" if its flag is zero. */ - -FILE *__alloc_file(void) -{ - __file_rec *fr = __file_rec_list; - __file_rec **last_fr = &__file_rec_list; - FILE *rv=0; - int i; - - /* Try to find an empty slot */ - while (fr) - { - last_fr = &(fr->next); - - /* If one of the existing slots is available, return it */ - for (i=0; icount; i++) - { - if (fr->files[i]->_flag == 0) - { - return fr->files[i]; - } - } - - /* If this one is full, go to the next */ - if (fr->count == __FILE_REC_MAX) - fr = fr->next; - else - /* it isn't full, we can add to it */ - break; - } - if (!fr) - { - /* add another one to the end, make it empty */ - fr = *last_fr = (__file_rec *)malloc(sizeof(__file_rec)); - if (fr == 0) - return 0; - fr->next = 0; - fr->count = 0; - } - /* fr is a pointer to a rec with empty slots in it */ - rv = fr->files[fr->count] = (FILE *)malloc(sizeof(FILE)); - if (rv == 0) - return 0; - memset(rv, 0, sizeof(FILE)); - fr->count ++; - return rv; -} - - -/* - * @implemented - */ -int _fcloseall( void ) -{ - __file_rec *fr = __file_rec_list; - __file_rec **last_fr = &__file_rec_list; - - int total_closed = 0; - int i = 0; - - /* Try to find an empty slot */ - while (fr) - { - last_fr = &(fr->next); - - /* If one of the existing slots is available, return it */ - for (i=0; icount; i++) - if (fr->files[i]->_flag != 0) { - fclose(fr->files[i]); - total_closed++; - } - - /* If this one is full, go to the next */ - if (fr->count == __FILE_REC_MAX) - fr = fr->next; - else - /* it isn't full, we can add to it */ - break; - } - return total_closed; -} diff --git a/reactos/lib/crt/stdio/clearerr.c b/reactos/lib/crt/stdio/clearerr.c deleted file mode 100644 index 63621700e4b..00000000000 --- a/reactos/lib/crt/stdio/clearerr.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#ifdef clearerr -#undef clearerr -void clearerr(FILE *stream); -#endif - -/* - * @implemented - */ -void -clearerr(FILE *f) -{ - if (!__validfp (f)) { - __set_errno (EINVAL); - return; - } - f->_flag &= ~(_IOERR|_IOEOF); -} diff --git a/reactos/lib/crt/stdio/fclose.c b/reactos/lib/crt/stdio/fclose.c deleted file mode 100644 index 85372c42f8f..00000000000 --- a/reactos/lib/crt/stdio/fclose.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include - - -// changed check for writable stream - - -/* - * @implemented - */ -int -fclose(FILE *f) -{ - int r = 0; - - if (f == NULL) { - __set_errno (EINVAL); - return EOF; - } - - - -// flush only if stream was opened for writing - if ( !(f->_flag&_IOSTRG) ) { - if ( OPEN4WRITING(f) ) - r = fflush(f); - - if (_close(_fileno(f)) < 0) - r = EOF; - if (f->_flag&_IOMYBUF) - free(f->_base); - -// Kernel might do this later - if (f->_flag & _IORMONCL && f->_tmpfname) - { - remove(f->_tmpfname); - free(f->_tmpfname); - f->_tmpfname = 0; - } - } - f->_cnt = 0; - f->_base = 0; - f->_ptr = 0; - f->_bufsiz = 0; - f->_flag = 0; - f->_file = -1; - return r; -} diff --git a/reactos/lib/crt/stdio/fdopen.c b/reactos/lib/crt/stdio/fdopen.c deleted file mode 100644 index bb33e3ab8cd..00000000000 --- a/reactos/lib/crt/stdio/fdopen.c +++ /dev/null @@ -1,55 +0,0 @@ -#include - -#include - -/* - * @implemented - */ -FILE* _tfdopen(int handle, -#ifndef _UNICODE - const -#endif - _TCHAR* mode) -{ - FILE* file; - int rw; - - if (handle == 0) - return stdin; - - if (handle == 1) - return stdout; - - if (handle == 2) - return stderr; - - file = __alloc_file(); - if (file == NULL) - return NULL; - file->_file = handle; - - rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+')); - - if (*mode == 'a') - _lseek(handle, 0, SEEK_END); - - file->_cnt = 0; - file->_file = handle; - file->_bufsiz = 0; - -// The mode of the stream must be compatible with the mode of the file descriptor. -// this should be checked. - - if (rw) - file->_flag = _IOREAD | _IOWRT; - else if (*mode == 'r') - file->_flag = _IOREAD; - else - file->_flag = _IOWRT; - - file->_base = file->_ptr = NULL; - - return file; -} - - diff --git a/reactos/lib/crt/stdio/feof.c b/reactos/lib/crt/stdio/feof.c deleted file mode 100644 index 3174b0b9a21..00000000000 --- a/reactos/lib/crt/stdio/feof.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#ifdef feof -#undef feof -int feof(FILE *stream); -#endif - -/* - * @implemented - */ -int feof(FILE *stream) -{ - if (stream == NULL) { - __set_errno (EINVAL); - return EOF; - } - - return stream->_flag & _IOEOF; -} diff --git a/reactos/lib/crt/stdio/ferror.c b/reactos/lib/crt/stdio/ferror.c deleted file mode 100644 index 8b8183a324b..00000000000 --- a/reactos/lib/crt/stdio/ferror.c +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#ifdef ferror -#undef ferror -int ferror(FILE *stream); -#endif - -int *_errno(void); - -/* - * @implemented - */ -int ferror(FILE *stream) -{ - return stream->_flag & _IOERR; -} diff --git a/reactos/lib/crt/stdio/fflush.c b/reactos/lib/crt/stdio/fflush.c deleted file mode 100644 index bba777621f9..00000000000 --- a/reactos/lib/crt/stdio/fflush.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdio/fflush.c - * PURPOSE: Checks for keyboard hits - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -/* - * @implemented - */ -int fflush(FILE *f) -{ - char *base; - int n, rn; - - - - if (f == NULL) - { - int e = *_errno(); - - __set_errno(0); - _fwalk((void (*)(FILE *))fflush); - if (*_errno()) - return EOF; - __set_errno(e); - return 0; - } - - -// nothing to do if stream can not be written to - - if ( !OPEN4WRITING(f) ) { - __set_errno (EINVAL); - return 0; - } - -// discard any unget characters - - f->_flag &= ~_IOUNGETC; - - -// check for buffered dirty block - - if ( (f->_flag&(_IODIRTY|_IONBF)) ==_IODIRTY && f->_base != NULL) - { - - base = f->_base; - - -// if the buffer is read ahead and dirty we will flush it entirely -// else the buffer is appended to the file to the extend it has valid bytes - - if ( (f->_flag & _IOAHEAD) == _IOAHEAD ) - rn = n = f->_ptr - base + f->_cnt; - else - rn = n = f->_ptr - base; - - f->_ptr = base; - - if ((f->_flag & _IOFBF) == _IOFBF) { - if ( (f->_flag & _IOAHEAD) == _IOAHEAD ) - _lseek(_fileno(f),-rn, SEEK_CUR); - } - - f->_flag &= ~_IOAHEAD; - - - f->_cnt = (f->_flag&(_IO_LBF|_IONBF)) ? 0 : f->_bufsiz; - -// how can write return less than rn without being on error ??? - -// possibly commit the flushed data -// better open the file in write through mode - - while (rn > 0) { - n = _write(_fileno(f), base, rn); - if (n <= 0) { - f->_flag |= _IOERR; - return EOF; - } - rn -= n; - base += n; - }; - f->_flag &= ~_IODIRTY; - -// commit flushed data -// _commit(_fileno(f)); - } - if (OPEN4READING(f) && OPEN4WRITING(f) ) - { - f->_cnt = 0; - f->_ptr = f->_base; - } - return 0; -} - -/* - * @implemented - */ -int _flushall( void ) -{ - return fflush(NULL); -} diff --git a/reactos/lib/crt/stdio/fgetc.c b/reactos/lib/crt/stdio/fgetc.c deleted file mode 100644 index b1ad851e079..00000000000 --- a/reactos/lib/crt/stdio/fgetc.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdio/fgetc.c - * PURPOSE: Get a character string from stdin - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Appropriated for Reactos - 25/02/99: Added fgetwc - */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -int fgetc(FILE *f) -{ - return getc(f); -} - -/* - * @implemented - */ -wint_t fgetwc(FILE *f) -{ - return getwc(f); -} diff --git a/reactos/lib/crt/stdio/fgetchar.c b/reactos/lib/crt/stdio/fgetchar.c deleted file mode 100644 index 5908c89316d..00000000000 --- a/reactos/lib/crt/stdio/fgetchar.c +++ /dev/null @@ -1,37 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * fgetchar.c - * - * Copyright (C) 2002 Robert Dickenson - * - * 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 - -int _fgetchar(void) -{ - return getc(stdin); -} - -/* - * @implemented - */ -wint_t _fgetwchar(void) -{ - return getwc(stdin); -} diff --git a/reactos/lib/crt/stdio/fgetpos.c b/reactos/lib/crt/stdio/fgetpos.c deleted file mode 100644 index a40224e1725..00000000000 --- a/reactos/lib/crt/stdio/fgetpos.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -int fgetpos(FILE *stream, fpos_t *pos) -{ - if (stream && pos) - { - *pos = (fpos_t)ftell(stream); - return 0; - } - //__set_errno ( EFAULT ); - return 1; -} diff --git a/reactos/lib/crt/stdio/fgets.c b/reactos/lib/crt/stdio/fgets.c deleted file mode 100644 index c59c11ab04f..00000000000 --- a/reactos/lib/crt/stdio/fgets.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * fgets.c - * - * Copyright (C) 2002 Robert Dickenson - * - * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * 28/12/1998: Appropriated for Reactos - * - * 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 - */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -char* fgets(char* s, int n, FILE* f) -{ - int c = 0; - char* cs; - - cs = s; - while (--n>0 && (c = getc(f)) != EOF) { - *cs++ = c; - if (c == '\n') - break; - } - if (c == EOF && cs == s) - return NULL; - *cs++ = '\0'; - return s; -} diff --git a/reactos/lib/crt/stdio/fgetws.c b/reactos/lib/crt/stdio/fgetws.c deleted file mode 100644 index 7a75a5d3257..00000000000 --- a/reactos/lib/crt/stdio/fgetws.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * fgets.c - * - * Copyright (C) 2002 Robert Dickenson - * - * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * 28/12/1998: Appropriated for Reactos - * - * 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 - */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#ifndef WEOF -#define WEOF (wchar_t)(0xFFFF) -#endif - -wchar_t* fgetws(wchar_t* s, int n, FILE* f) -{ - - int c=0; - wchar_t *cs; - - cs = s; - while (--n>0 && (c = getwc(f)) != WEOF) - { - *cs++ = c; - if (c == L'\n') - break; - } - if (c == WEOF && cs == s) - return NULL; - *cs++ = L'\0'; - return s; -} diff --git a/reactos/lib/crt/stdio/filbuf.c b/reactos/lib/crt/stdio/filbuf.c deleted file mode 100644 index b4f911678a8..00000000000 --- a/reactos/lib/crt/stdio/filbuf.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include - -int _readcnv(int fn, void* buf, size_t siz); - -/* - * @implemented - */ -int _filbuf(FILE* f) -{ - int size; - char c; - - if ( !OPEN4READING(f)) { - __set_errno (EINVAL); - return EOF; - } - if (f->_flag&(_IOSTRG|_IOEOF)) - return EOF; - f->_flag &= ~_IOUNGETC; - - if (f->_base == NULL && (f->_flag & _IONBF) == 0) { - size = 4096; - if ((f->_base = malloc(size+1)) == NULL) { - // error ENOMEM - f->_flag |= _IONBF; - f->_flag &= ~(_IOFBF|_IO_LBF); - } else { - f->_flag |= _IOMYBUF; - f->_bufsiz = size; - } - } - if (f->_flag&_IONBF) - f->_base = &c; - - // flush stdout before reading from stdin - if (f == stdin) { - if (stdout->_flag&_IO_LBF) - fflush(stdout); - if (stderr->_flag&_IO_LBF) - fflush(stderr); - } - - // if we have a dirty stream we flush it - if ((f->_flag &_IODIRTY) == _IODIRTY) - fflush(f); - - - - f->_cnt = _read(_fileno(f), f->_base, f->_flag & _IONBF ? 1 : f->_bufsiz ); - f->_flag |= _IOAHEAD; - - if(__is_text_file(f) && f->_cnt>0) - { - /* truncate text file at Ctrl-Z */ - char *cz=memchr(f->_base, 0x1A, f->_cnt); - if(cz) - { - int newcnt = cz - f->_base; - _lseek(_fileno(f), -(f->_cnt - newcnt), SEEK_CUR); - f->_cnt = newcnt; - } - } - - f->_ptr = f->_base; - - if (f->_flag & _IONBF) - f->_base = NULL; // statically allocated buffer for sprintf - - -//check for error - if (f->_cnt <= 0) { - if (f->_cnt == 0) { - f->_flag |= _IOEOF; - } else - f->_flag |= _IOERR; - f->_cnt = 0; - -// FIXME should set errno - - return EOF; - } - - f->_cnt--; - - return *f->_ptr++ & 0377; -} - -wint_t _filwbuf(FILE *fp) -{ - return (wint_t )_filbuf(fp); -} - -// convert the carriage return line feed pairs -/* -int _readcnv(int fn, void *buf, size_t siz ) -{ - char *bufp = (char *)buf; - int _bufsiz = siz; - int cr = 0; - int n; - - n = _read(fn, buf, siz ); - - while (_bufsiz > 0) { - if (*bufp == '\r') - cr++; - else if ( cr != 0 ) - *bufp = *(bufp + cr); - bufp++; - _bufsiz--; - } - return n + cr; -} - */ diff --git a/reactos/lib/crt/stdio/fileno.c b/reactos/lib/crt/stdio/fileno.c deleted file mode 100644 index 869550601dd..00000000000 --- a/reactos/lib/crt/stdio/fileno.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include - -#undef _fileno - -/* - * @implemented - */ -int _fileno(FILE *f) -{ - return f->_file; -} diff --git a/reactos/lib/crt/stdio/flsbuf.c b/reactos/lib/crt/stdio/flsbuf.c deleted file mode 100644 index 0634ff6be88..00000000000 --- a/reactos/lib/crt/stdio/flsbuf.c +++ /dev/null @@ -1,153 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -int cntcr(char* bufp, int bufsiz); -int convert(char* endp, int bufsiz, int n); -int _writecnv(int fn, void* buf, size_t bufsiz); - - -/* - * @implemented - */ -int _flsbuf(int c, FILE* f) -{ - char* base; - int n, rn; - char c1; - int size; - - if (!OPEN4WRITING(f)) { - __set_errno(EINVAL); - return EOF; - } - - // no file associated with buffer, this is a memory stream - if (_fileno(f) == -1) { - return c; - } - - /* if the buffer is not yet allocated, allocate it */ - if ((base = f->_base) == NULL && (f->_flag & _IONBF) == 0) { - size = 4096; - if ((f->_base = base = malloc(size)) == NULL) { - f->_flag |= _IONBF; - f->_flag &= ~(_IOFBF|_IO_LBF); - } else { - f->_flag |= _IOMYBUF; - f->_cnt = f->_bufsiz = size; - f->_ptr = base; - rn = 0; - if (f == stdout && _isatty(_fileno(stdout))) { - f->_flag |= _IO_LBF; - } - } - } - - if (f->_flag & _IO_LBF) { - /* in line-buffering mode we get here on each character */ - *f->_ptr++ = c; - rn = f->_ptr - base; - if (c == '\n' || rn >= f->_bufsiz) { - /* time for real flush */ - f->_ptr = base; - f->_cnt = 0; - } else { - /* we got here because _cnt is wrong, so fix it */ - /* Negative _cnt causes all output functions to call */ - /* _flsbuf for each character, thus realizing line-buffering */ - f->_cnt = -rn; - return c; - } - } else if (f->_flag & _IONBF) { - c1 = c; - rn = 1; - base = &c1; - f->_cnt = 0; - } else { /* _IOFBF */ - rn = f->_ptr - base; - f->_ptr = base; - if ((f->_flag & _IOAHEAD) == _IOAHEAD) - _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); - if (n <= 0) { - f->_flag |= _IOERR; - return EOF; - } - rn -= n; - base += n; - } - if ((f->_flag & (_IO_LBF|_IONBF)) == 0) { - f->_cnt--; - *f->_ptr++ = c; - f->_flag |= _IODIRTY; - } - return c; -} - -wint_t _flswbuf(wchar_t c, FILE* fp) -{ - int result; - - result = _flsbuf((int)c, fp); - if (result == EOF) - return WEOF; - return (wint_t)result; -} - -int _writecnv(int fn, void* buf, size_t siz) -{ - char* bufp = (char*)buf; - int bufsiz = siz; - char* tmp; - int cr1 = 0; - int cr2 = 0; - int n; - - cr1 = cntcr(bufp, bufsiz); - tmp = malloc(cr1); - memcpy(tmp, bufp + bufsiz - cr1, cr1); - cr2 = cntcr(tmp, cr1); - convert(bufp, bufsiz - cr2, cr1 - cr2); - n = _write(fn, bufp, bufsiz + cr1); - convert(tmp, cr1, cr2); - n += _write(fn, tmp, cr1 + cr2); - free(tmp); - return n; -} - -int convert(char* endp, int bufsiz, int n) -{ - endp = endp + bufsiz + n; - while (bufsiz > 0) { - *endp = *(endp - n); - if (*endp == '\n') { - endp--; - n--; - *endp = '\r'; - } - endp--; - bufsiz--; - } - return n; -} - -int cntcr(char* bufp, int bufsiz) -{ - int cr = 0; - - while (bufsiz > 0) { - if (*bufp == '\n') { - cr++; - } - bufp++; - bufsiz--; - } - return cr; -} diff --git a/reactos/lib/crt/stdio/fopen.c b/reactos/lib/crt/stdio/fopen.c deleted file mode 100644 index e421474791c..00000000000 --- a/reactos/lib/crt/stdio/fopen.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * fopen.c - * - * Copyright (C) 2002 Robert Dickenson - * - * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * 28/12/1998: Appropriated for Reactos - * - * 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 - */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -#include - -//might change fopen(file,mode) -> fsopen(file,mode,_SH_DENYNO); - -FILE* _tfopen(const _TCHAR *file, const _TCHAR *mode) -{ - FILE *f; - int fd, rw, oflags = 0; - - if (file == 0) - return 0; - if (mode == 0) - return 0; - - f = __alloc_file(); - if (f == NULL) - return NULL; - - rw = (_tcschr(mode, '+') == NULL) ? 0 : 1; - if (_tcschr(mode, 'a')) - oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); - if (_tcschr(mode, 'r')) - oflags = rw ? O_RDWR : O_RDONLY; - if (_tcschr(mode, 'w')) - oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); - if (_tcschr(mode, 't')) - oflags |= O_TEXT; - else if (_tcschr(mode, 'b')) - oflags |= O_BINARY; - else - oflags |= (_fmode& (O_TEXT|O_BINARY)); - - fd = _topen(file, oflags, 0); - 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 (_tcschr(mode, 'a')) - _lseek(fd, 0, SEEK_END); - - f->_cnt = 0; - f->_file = fd; - f->_bufsiz = 0; - if (rw) - f->_flag = _IOREAD | _IOWRT; - else if (_tcschr(mode, 'r')) - f->_flag = _IOREAD; - else - f->_flag = _IOWRT; - - if (_tcschr(mode, 't')) - f->_flag |= _IOTEXT; - else if (_tcschr(mode, 'b')) - f->_flag |= _IOBINARY; - else if (_fmode& O_BINARY) - f->_flag |= _IOBINARY; - - f->_base = f->_ptr = NULL; - return f; -} diff --git a/reactos/lib/crt/stdio/fprintf.c b/reactos/lib/crt/stdio/fprintf.c deleted file mode 100644 index 5e0c86ccbf4..00000000000 --- a/reactos/lib/crt/stdio/fprintf.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#include -#include - -/* - * @implemented - */ -int -_ftprintf(register FILE *iop, const _TCHAR *fmt, ...) -{ - int len; - _TCHAR localbuf[BUFSIZ]; - va_list a=0; - - - va_start( a, fmt ); - if (iop->_flag & _IONBF) - { - iop->_flag &= ~_IONBF; - iop->_ptr = iop->_base = (char *)localbuf; - iop->_bufsiz = BUFSIZ; - len = _vftprintf(iop,fmt,a); - fflush(iop); - iop->_flag |= _IONBF; - iop->_base = NULL; - iop->_bufsiz = 0; - iop->_cnt = 0; - } - else - len = _vftprintf(iop, fmt, a); - return ferror(iop) ? -1 : len; -} diff --git a/reactos/lib/crt/stdio/fputc.c b/reactos/lib/crt/stdio/fputc.c deleted file mode 100644 index 43b27ed6e7d..00000000000 --- a/reactos/lib/crt/stdio/fputc.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#include - -/* - * @implemented - */ -int -fputc(int c, FILE *fp) -{ - return putc(c, fp); -} - -/* - * @implemented - */ -wint_t -fputwc(wchar_t c, FILE *fp) -{ - return putwc(c,fp); -} - - diff --git a/reactos/lib/crt/stdio/fputchar.c b/reactos/lib/crt/stdio/fputchar.c deleted file mode 100644 index 533f1a8e3e2..00000000000 --- a/reactos/lib/crt/stdio/fputchar.c +++ /dev/null @@ -1,38 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * fputchar.c - * - * Copyright (C) 2002 Robert Dickenson - * - * 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 - - -int _fputchar(int c) -{ - return putc(c, stdout); -} - -/* - * @implemented - */ -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 deleted file mode 100644 index e336672858c..00000000000 --- a/reactos/lib/crt/stdio/fputs.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * fputs.c - * - * Copyright (C) 2002 Robert Dickenson - * - * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * 28/12/1998: Appropriated for Reactos - * - * 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 - */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include -#include - -int -_fputts(const _TCHAR *s, FILE *f) -{ - int r = 0; - int c; - int unbuffered; - _TCHAR localbuf[BUFSIZ]; - - unbuffered = f->_flag & _IONBF; - if (unbuffered) - { - f->_flag &= ~_IONBF; - f->_ptr = f->_base = (char*)localbuf; - f->_bufsiz = BUFSIZ; - } - - while ((c = *s++)) - r = _puttc(c, f); - - if (unbuffered) - { - fflush(f); - f->_flag |= _IONBF; - f->_base = NULL; - f->_bufsiz = 0; - f->_cnt = 0; - } - - return(r); -} - diff --git a/reactos/lib/crt/stdio/fputws.c b/reactos/lib/crt/stdio/fputws.c deleted file mode 100644 index 06a0a2631f0..00000000000 --- a/reactos/lib/crt/stdio/fputws.c +++ /dev/null @@ -1,5 +0,0 @@ - -#define UNICODE -#define _UNICODE - -#include "fputs.c" diff --git a/reactos/lib/crt/stdio/fread.c b/reactos/lib/crt/stdio/fread.c deleted file mode 100644 index 0bc11ca8ebf..00000000000 --- a/reactos/lib/crt/stdio/fread.c +++ /dev/null @@ -1,88 +0,0 @@ -#include - -/* - * @implemented - */ -size_t fread(void *vptr, size_t size, size_t count, FILE *iop) -{ - unsigned char *ptr = (unsigned char *)vptr; - size_t to_read ,n_read; - int c, copy; - - to_read = size * count; - - if (!OPEN4READING(iop)) - { - __set_errno (EINVAL); - return 0; - } - - if (!__validfp (iop) ) - { - __set_errno (EINVAL); - return 0; - } - if (feof (iop) || ferror (iop)) - return 0; - - if (vptr == NULL || to_read == 0) - return 0; - - if (iop->_base == NULL) - { - int c = _filbuf(iop); - if (c == EOF) - return 0; - *ptr++ = c; - if (--to_read == 0) - return 1; - } - - if (iop->_cnt > 0 && to_read > 0) - { - copy = min((size_t)iop->_cnt, to_read); - memcpy(ptr, iop->_ptr, copy); - ptr += copy; - iop->_ptr += copy; - iop->_cnt -= copy; - to_read -= copy; - if (to_read == 0) - return count; - } - - if (to_read > 0) - { - - if (to_read >= (size_t)iop->_bufsiz) - { - n_read = _read(_fileno(iop), ptr, to_read); - if (n_read < 0) - iop->_flag |= _IOERR; - else if (n_read == 0) - iop->_flag |= _IOEOF; - else - to_read -= n_read; - - // the file buffer is empty and there is no read ahead information anymore. - iop->_flag &= ~_IOAHEAD; - } - else - { - c = _filbuf(iop); - if (c != EOF) - { - *ptr++ = c; - to_read--; - copy = min((size_t)iop->_cnt, to_read); - memcpy(ptr, iop->_ptr, copy); - iop->_ptr += copy; - iop->_cnt -= copy; - to_read -= copy; - } - } - } - // return count - (to_read/size) - /* FIXME is this formual right ?, I copy the formula from djgpp - in our to_read or copy ? */ - return size != 0 ? count - ((to_read + size - 1) / size) : 0; -} diff --git a/reactos/lib/crt/stdio/freopen.c b/reactos/lib/crt/stdio/freopen.c deleted file mode 100644 index 134ca290a75..00000000000 --- a/reactos/lib/crt/stdio/freopen.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -#include - -/* - * @implemented - */ -FILE *_tfreopen(const _TCHAR *file, const _TCHAR *mode, FILE *f) -{ - int fd, rw, oflags=0; - _TCHAR tbchar; - - if (file == 0 || mode == 0 || f == 0) - return 0; - - rw = (mode[1] == '+'); - - fclose(f); - - switch (*mode) { - case 'a': - oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); - break; - case 'r': - oflags = rw ? O_RDWR : O_RDONLY; - break; - case 'w': - oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); - break; - default: - return NULL; - } - if (mode[1] == '+') - tbchar = mode[2]; - else - tbchar = mode[1]; - if (tbchar == 't') - oflags |= O_TEXT; - else if (tbchar == 'b') - oflags |= O_BINARY; - else - oflags |= (_fmode& (O_TEXT|O_BINARY)); - - fd = _topen(file, oflags, 0666); - if (fd < 0) - return NULL; - - if (*mode == 'a') - _lseek(fd, 0, SEEK_END); - - f->_cnt = 0; - f->_file = fd; - f->_bufsiz = 0; - if (rw) - f->_flag = _IOREAD | _IOWRT; - else if (*mode == 'r') - f->_flag = _IOREAD; - else - f->_flag = _IOWRT; - - f->_base = f->_ptr = NULL; - return f; -} - diff --git a/reactos/lib/crt/stdio/fseek.c b/reactos/lib/crt/stdio/fseek.c deleted file mode 100644 index d9204810e2b..00000000000 --- a/reactos/lib/crt/stdio/fseek.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -/* - * @implemented - */ -int fseek(FILE *f, long offset, int ptrname) -{ - long p = -1; /* can't happen? */ - if ( f == NULL ) { - __set_errno (EINVAL); - return -1; - } - - f->_flag &= ~_IOEOF; - if (!OPEN4WRITING(f)) - { - if (f->_base && !(f->_flag & _IONBF)) - { - p = ftell(f); - if (ptrname == SEEK_CUR) - { - offset += p; - ptrname = SEEK_SET; - } - /* check if the target position is in the buffer and - optimize seek by moving inside the buffer */ - if (ptrname == SEEK_SET && (f->_flag & (_IOUNGETC|_IOREAD|_IOWRT )) == 0 - && p-offset <= f->_ptr-f->_base && offset-p <= f->_cnt) - { - f->_ptr+=offset-p; - f->_cnt+=p-offset; - return 0; - } - } - - p = _lseek(_fileno(f), offset, ptrname); - f->_cnt = 0; - f->_ptr = f->_base; - f->_flag &= ~_IOUNGETC; - } - else - { - p = fflush(f); - return _lseek(_fileno(f), offset, ptrname) == -1 || p == EOF ? - -1 : 0; - } - return p==-1 ? -1 : 0; -} diff --git a/reactos/lib/crt/stdio/fsetpos.c b/reactos/lib/crt/stdio/fsetpos.c deleted file mode 100644 index 1d2e3a25104..00000000000 --- a/reactos/lib/crt/stdio/fsetpos.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -int fsetpos(FILE *stream,const fpos_t *pos) -{ - if (stream && pos) - { - fseek(stream, (long)(*pos), SEEK_SET); - return 0; - } - __set_errno(EFAULT); - return -1; -} diff --git a/reactos/lib/crt/stdio/fsopen.c b/reactos/lib/crt/stdio/fsopen.c deleted file mode 100644 index 88c13aa8c6e..00000000000 --- a/reactos/lib/crt/stdio/fsopen.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdio/fsopen.c - * PURPOSE: Checks for keyboard hits - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -#include -#include -#include - - -/* - * @implemented - */ -FILE* _tfsopen(const _TCHAR *file, const _TCHAR *mode, int shflag) -{ - FILE *f; - int fd, rw, oflags = 0; - _TCHAR tbchar; - - int shf; - - if (file == 0) - return 0; - if (mode == 0) - return 0; - - f = __alloc_file(); - if (f == NULL) - return NULL; - - rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+')); - - switch (*mode) - { - case 'a': - oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); - break; - case 'r': - oflags = rw ? O_RDWR : O_RDONLY; - break; - case 'w': - oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); - break; - default: - return (NULL); - } - if (mode[1] == '+') - tbchar = mode[2]; - else - tbchar = mode[1]; - if (tbchar == 't') - oflags |= O_TEXT; - else if (tbchar == 'b') - oflags |= O_BINARY; - else - oflags |= (_fmode& (O_TEXT|O_BINARY)); - - if ( shflag == _SH_DENYNO ) - shf = _S_IREAD | _S_IWRITE; - else if( shflag == _SH_DENYRD ) - shf = _S_IWRITE; - else if( shflag == _SH_DENYRW ) - shf = 0; - else if( shflag == _SH_DENYWR ) - shf = _S_IREAD; - else - shf = _S_IREAD | _S_IWRITE; - - fd = _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); - - f->_cnt = 0; - f->_file = fd; - f->_bufsiz = 0; - if (rw) - f->_flag = _IOREAD | _IOWRT; - else if (*mode == 'r') - f->_flag = _IOREAD; - else - f->_flag = _IOWRT; - - f->_base = f->_ptr = NULL; - return f; -} - diff --git a/reactos/lib/crt/stdio/ftell.c b/reactos/lib/crt/stdio/ftell.c deleted file mode 100644 index aa7b4e939ef..00000000000 --- a/reactos/lib/crt/stdio/ftell.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -/* - * @implemented - */ -long ftell(FILE *f) -{ - long tres; - int adjust=0; - - if (!f) - { - __set_errno(EBADF); - return -1; - } - - if (f->_cnt < 0) - f->_cnt = 0; - else if (f->_flag&(_IOWRT)) - { - if (f->_base && (f->_flag&_IONBF)==0) - adjust = f->_ptr - f->_base; - } - else if (f->_flag&_IOREAD) - { - adjust = - f->_cnt; - } - else - return -1; - - tres = _lseek(_fileno(f), 0L, SEEK_CUR); - if (tres<0) - return tres; - tres += adjust; - - //f->_cnt = f->_bufsiz - tres; - //f->_ptr = f->_base + tres; - - return tres; -} diff --git a/reactos/lib/crt/stdio/fwalk.c b/reactos/lib/crt/stdio/fwalk.c deleted file mode 100644 index fc3a70c2135..00000000000 --- a/reactos/lib/crt/stdio/fwalk.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -// not exported by msvcrt or crtdll -__file_rec *__file_rec_list; - -void _fwalk(void (*func)(FILE *)) -{ - __file_rec *fr; - int i; - - for (fr=__file_rec_list; fr; fr=fr->next) - for (i=0; icount; i++) - if (fr->files[i]->_flag) - func(fr->files[i]); -} diff --git a/reactos/lib/crt/stdio/fwprintf.c b/reactos/lib/crt/stdio/fwprintf.c deleted file mode 100644 index e25b3bcc387..00000000000 --- a/reactos/lib/crt/stdio/fwprintf.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "fprintf.c" diff --git a/reactos/lib/crt/stdio/fwrite.c b/reactos/lib/crt/stdio/fwrite.c deleted file mode 100644 index 917f6738f79..00000000000 --- a/reactos/lib/crt/stdio/fwrite.c +++ /dev/null @@ -1,111 +0,0 @@ -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -size_t fwrite(const void *vptr, size_t size, size_t count, FILE *iop) -{ - size_t to_write, n_written; - unsigned char *ptr = (unsigned char *)vptr; - int copy; - - TRACE("fwrite(%x, %d, %d, %x)", vptr, size, count, iop); - - to_write = size*count; - if (!OPEN4WRITING(iop)) - { - __set_errno (EINVAL); - return(0); - } - - if (iop == NULL) - { - __set_errno (EINVAL); - return(0); - } - - if (ferror (iop)) - return(0); - if (vptr == NULL || to_write == 0) - return(0); - - if (iop->_base == NULL && !(iop->_flag&_IONBF)) - { - if (EOF == _flsbuf(*ptr++, iop)) - return(0); - if (--to_write == 0) - return(1); - } - - if (iop->_flag & _IO_LBF) - { - while (to_write > 0) - { - if (EOF == putc(*ptr++, iop)) - { - iop->_flag |= _IOERR; - break; - } - to_write--; - } - } - else - { - if (iop->_cnt > 0 && to_write > 0) - { - copy = min((size_t)iop->_cnt, to_write); - memcpy(iop->_ptr, ptr, copy); - ptr += copy; - iop->_ptr += copy; - iop->_cnt -= copy; - to_write -= copy; - iop->_flag |= _IODIRTY; - } - - if (to_write > 0) - { - // if the buffer is dirty it will have to be written now - // otherwise the file pointer won't match anymore. - fflush(iop); - if (to_write >= (size_t)iop->_bufsiz) - { - while (to_write > 0) - { - n_written = _write(_fileno(iop), ptr, to_write); - if (n_written <= 0) - { - iop->_flag |= _IOERR; - break; - } - to_write -= n_written; - ptr += n_written; - } - - // check to see if this will work with in combination with ungetc - - // the file buffer is empty and there is no read ahead information anymore. - iop->_flag &= ~_IOAHEAD; - } - else - { - if (EOF != _flsbuf(*ptr++, iop)) - { - if (--to_write > 0) - { - memcpy(iop->_ptr, ptr, to_write); - iop->_ptr += to_write; - iop->_cnt -= to_write; - iop->_flag |= _IODIRTY; - return(count); - } - } - } - } - } - - return(count - (to_write/size)); -} diff --git a/reactos/lib/crt/stdio/getc.c b/reactos/lib/crt/stdio/getc.c deleted file mode 100644 index acf2afca05f..00000000000 --- a/reactos/lib/crt/stdio/getc.c +++ /dev/null @@ -1,130 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * getc.c - * - * Copyright (C) 2002 Robert Dickenson - * - * 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 - -//getc can be a macro -#undef getc -#undef getwc - -#ifndef MB_CUR_MAX -#define MB_CUR_MAX 10 -#endif - -int getc(FILE *fp) -{ - int c = -1; - - // check for invalid stream - if ( !__validfp (fp) ) { - __set_errno(EINVAL); - return EOF; - } - // check for read access on stream - if ( !OPEN4READING(fp) ) { - __set_errno(EINVAL); - return EOF; - } - if(fp->_cnt > 0) { - fp->_cnt--; - c = (int)(*fp->_ptr++ & 0377); - } else { - c = _filbuf(fp); - } - return c; -} - -/* - * @implemented - */ -wint_t getwc(FILE *fp) -{ - wint_t c = -1; - - // check for invalid stream - if (!__validfp(fp)) { - __set_errno(EINVAL); - return WEOF; - } - // check for read access on stream -//#define OPEN4READING(f) ((((f)->_flag & _IOREAD) == _IOREAD ) ) - if (!OPEN4READING(fp)) { - __set_errno(EINVAL); - return WEOF; - } - // might check on multi bytes if text mode - if (fp->_flag & _IOBINARY) { - if (fp->_cnt > 1) { - fp->_cnt -= sizeof(wchar_t); - c = *((wchar_t*)fp->_ptr); - fp->_ptr += sizeof(wchar_t); - } else { - c = _filwbuf(fp); - // need to fix by one values of fp->_ptr and fp->_cnt - fp->_ptr++; - fp->_cnt--; - } - } else { -#if 0 - BOOL get_bytes = 0; - int mb_cnt = 0; - int found_cr = 0; - //int count; - char mbchar[MB_CUR_MAX]; - - do { - if (fp->_cnt > 0) { - fp->_cnt--; - mbchar[mb_cnt] = *fp->_ptr++ & 0377; - } else { - mbchar[mb_cnt] = _filbuf(fp); - } - if (isleadbyte(mbchar[mb_cnt])) { - get_bytes = 1; - } else { - get_bytes = 0; - } - if (_ismbblead(mbchar[mb_cnt])) { - } - ++mb_cnt; - //} - } while (get_bytes); - - // Convert a multibyte character to a corresponding wide character. - mb_cnt = mbtowc(&c, mbchar, mb_cnt); - if (mb_cnt == -1) { - fp->_flag |= _IOERR; - return WEOF; - } -#else - if (fp->_cnt > 0) { - fp->_cnt--; - c = *fp->_ptr++ &0377; - } else { - c = _filbuf(fp); - } -#endif - } - return c; -} - diff --git a/reactos/lib/crt/stdio/getchar.c b/reactos/lib/crt/stdio/getchar.c deleted file mode 100644 index 3fcd0d80f77..00000000000 --- a/reactos/lib/crt/stdio/getchar.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * getchar.c - * - * Copyright (C) 2002 Robert Dickenson - * - * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * 28/12/1998: Appropriated for Reactos - * - * 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 - -#undef getchar -#undef getwchar - -int -getchar(void) -{ - return getc(stdin); -} - -/* - * @implemented - */ -wint_t -getwchar(void) -{ - return getwc(stdin); -} diff --git a/reactos/lib/crt/stdio/gets.c b/reactos/lib/crt/stdio/gets.c deleted file mode 100644 index 53251c74e20..00000000000 --- a/reactos/lib/crt/stdio/gets.c +++ /dev/null @@ -1,144 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * gets.c - * - * Copyright (C) 2002 Robert Dickenson - * - * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * 28/12/1998: Appropriated for Reactos - * - * 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 - */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include - -char* gets(char* s) -{ - int c; - char* cs; - - cs = s; - while ((c = getc(stdin)) != '\n' && c != EOF) - *cs++ = c; - if (c == EOF && cs == s) - return NULL; - *cs++ = '\0'; - return s; -} - -#ifndef WEOF -#define WEOF (wchar_t)(0xFFFF) -#endif - -/* - * Get a line from the stdin stream. - * - * @implemented - */ -wchar_t* _getws(wchar_t* s) -{ - wchar_t c; - wchar_t* cs; - - cs = s; - while ((c = getwc(stdin)) != L'\n' && c != WEOF) - *cs++ = c; - if (c == WEOF && cs == s) - return NULL; - *cs++ = L'\0'; - return s; -} - -#if 0 -/* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include - -link_warning (gets, "the `gets' function is dangerous and should not be used.") - - -/* Read a newline-terminated multibyte string from stdin into S, - removing the trailing newline. Return S or NULL. */ - -char * -gets (s) - char *s; -{ - register char *p = s; - register int c; - FILE *stream = stdin; - int l; - - if (!__validfp (stream) || p == NULL) - { - __set_errno (EINVAL); - return NULL; - } - - if (feof (stream) || ferror (stream)) - return NULL; - - while ((c = getc(stdin)) != EOF) { - if (c == '\n') - break; - if ( isascii(c) ) - *cs++ = c; -#ifdef _MULTIBYTE - else if ( isleadbyte(c) ) { - l = mblen(c); - while(l > 0 ) { - c = getchar(); - if ( isleadbyte(c) || c == EOF ) - return NULL; // encoding error - *cs++ = c; - l--; - } - } -#endif - else - return NULL; // suspicious input - } - - *p = '\0'; - - /* Return null if we had an error, or if we got EOF - before writing any characters. */ - - if (ferror (stream) || (feof (stream) && p == s)) - return NULL; - - return s; -} - -#endif diff --git a/reactos/lib/crt/stdio/getw.c b/reactos/lib/crt/stdio/getw.c deleted file mode 100644 index 2bc42696e17..00000000000 --- a/reactos/lib/crt/stdio/getw.c +++ /dev/null @@ -1,38 +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 - -/* - * Read a word (int) from STREAM. - * - * @implemented - */ -int _getw(FILE *stream) -{ - int w; - - /* Is there a better way? */ - if (fread( &w, sizeof(w), 1, stream) != 1) { - // EOF is a legitimate integer value so users must - // check feof or ferror to verify an EOF return. - return(EOF); - } - return(w); -} - diff --git a/reactos/lib/crt/stdio/perror.c b/reactos/lib/crt/stdio/perror.c deleted file mode 100644 index 14a20e59bec..00000000000 --- a/reactos/lib/crt/stdio/perror.c +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#ifdef perror -#undef perror -void perror(const char *s); -#endif - -/* - * @implemented - */ -void perror(const char *s) -{ - fprintf(stderr, "%s: %s\n", s, _strerror(NULL)); -} - -/* - * @implemented - */ -void _wperror(const wchar_t *s) -{ - fwprintf(stderr, L"%s: %S\n", s, _strerror(NULL)); -} diff --git a/reactos/lib/crt/stdio/popen.c b/reactos/lib/crt/stdio/popen.c deleted file mode 100644 index c8bfdba652b..00000000000 --- a/reactos/lib/crt/stdio/popen.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -FILE *_tpopen (const _TCHAR *cm, const _TCHAR *md) /* program name, pipe mode */ -{ - _TCHAR *szCmdLine=NULL; - _TCHAR *szComSpec=NULL; - _TCHAR *s; - FILE *pf; - HANDLE hReadPipe, hWritePipe; - BOOL result; - STARTUPINFO StartupInfo; - PROCESS_INFORMATION ProcessInformation; - SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; - - TRACE(MK_STR(_tpopen)"('%"sT"', '%"sT"')\n", cm, md); - - if (cm == NULL) - return( NULL ); - - szComSpec = _tgetenv(_T("COMSPEC")); - if (szComSpec == NULL) - { - szComSpec = _T("cmd.exe"); - } - - s = max(_tcsrchr(szComSpec, '\\'), _tcsrchr(szComSpec, '/')); - if (s == NULL) - s = szComSpec; - else - s++; - - szCmdLine = malloc((_tcslen(s) + 4 + _tcslen(cm) + 1) * sizeof(_TCHAR)); - if (szCmdLine == NULL) - { - return NULL; - } - - _tcscpy(szCmdLine, s); - s = _tcsrchr(szCmdLine, '.'); - if (s) - *s = 0; - _tcscat(szCmdLine, _T(" /C ")); - _tcscat(szCmdLine, cm); - - if ( !CreatePipe(&hReadPipe,&hWritePipe,&sa,1024)) - { - free (szCmdLine); - return NULL; - } - - memset(&StartupInfo, 0, sizeof(STARTUPINFO)); - StartupInfo.cb = sizeof(STARTUPINFO); - - if (*md == 'r' ) { - StartupInfo.hStdOutput = hWritePipe; - StartupInfo.dwFlags |= STARTF_USESTDHANDLES; - } - else if ( *md == 'w' ) { - StartupInfo.hStdInput = hReadPipe; - StartupInfo.dwFlags |= STARTF_USESTDHANDLES; - } - - result = CreateProcess(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 == 'r' ) - { - pf = _tfdopen(alloc_fd(hReadPipe, split_oflags(_fmode)) , _T("r")); - CloseHandle(hWritePipe); - } - else - { - pf = _tfdopen( alloc_fd(hWritePipe, split_oflags(_fmode)) , _T("w")); - CloseHandle(hReadPipe); - } - - pf->_tmpfname = ProcessInformation.hProcess; - - return( pf ); -} - -#ifndef _UNICODE - -/* - * @implemented - */ -int _pclose (FILE *pp) -{ - TRACE("_pclose(%x)",pp); - - fclose(pp); - if (!TerminateProcess(pp->_tmpfname ,0)) - return( -1 ); - return( 0 ); -} - -#endif - diff --git a/reactos/lib/crt/stdio/printf.c b/reactos/lib/crt/stdio/printf.c deleted file mode 100644 index f68e40fdcc3..00000000000 --- a/reactos/lib/crt/stdio/printf.c +++ /dev/null @@ -1,36 +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 - -/* - * @implemented - */ -int _tprintf(const _TCHAR* format, ...) -{ - va_list arg; - int done; - - va_start(arg, format); - 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 deleted file mode 100644 index 71c0fd0854b..00000000000 --- a/reactos/lib/crt/stdio/putc.c +++ /dev/null @@ -1,142 +0,0 @@ -/* $Id$ - * - * ReactOS msvcrt library - * - * putc.c - * - * Copyright (C) 2002 Robert Dickenson - * - * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details - * - * 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 - */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include - -// putc can be a macro -#undef putc -#undef putwc - -#ifndef MB_CUR_MAX_CONST -#define MB_CUR_MAX_CONST 10 -#endif - -int putc(int c, FILE* fp) -{ - // valid stream macro should check that fp is dword aligned - if (!__validfp(fp)) { - __set_errno(EINVAL); - return EOF; - } - // check for write access on fp - if (!OPEN4WRITING(fp)) { - __set_errno(EINVAL); - return EOF; - } - fp->_flag |= _IODIRTY; - if (fp->_cnt > 0) { - fp->_cnt--; - *(fp)->_ptr++ = (unsigned char)c; - return (int)(unsigned char)c; - } else { - return _flsbuf((unsigned char)c, fp); - } - return EOF; -} - -//wint_t putwc(wint_t c, FILE* fp) -/* - * @implemented - */ -wint_t putwc(wint_t c, FILE* fp) -{ - // valid stream macro should check that fp is dword aligned - if (!__validfp(fp)) { - __set_errno(EINVAL); - return WEOF; - } - // check for write access on fp - if (!OPEN4WRITING(fp)) { - __set_errno(EINVAL); - return WEOF; - } - // might check on multi bytes if text mode - if (fp->_flag & _IOBINARY) { - //if (1) { - - fp->_flag |= _IODIRTY; - if (fp->_cnt > 0) { - fp->_cnt -= sizeof(wchar_t); - //*((wchar_t*)(fp->_ptr))++ = c; - *((wchar_t*)(fp->_ptr)) = c; - fp->_ptr += sizeof(wchar_t); - return (wint_t)c; - } else { -#if 1 - wint_t result; - result = _flsbuf(c, fp); - if (result == (wint_t)EOF) - return WEOF; - result = _flsbuf((int)(c >> 8), fp); - if (result == (wint_t)EOF) - return WEOF; - return result; -#else - return _flswbuf(c, fp); -#endif - } - - } else { -#if 0 - int i; - int mb_cnt; - char mbchar[MB_CUR_MAX_CONST]; - - // Convert wide character to the corresponding multibyte character. - mb_cnt = wctomb(mbchar, (wchar_t)c); - if (mb_cnt == -1) { - fp->_flag |= _IOERR; - return WEOF; - } - if (mb_cnt > MB_CUR_MAX_CONST) { - // BARF(); - } - for (i = 0; i < mb_cnt; i++) { - fp->_flag |= _IODIRTY; - if (fp->_cnt > 0) { - fp->_cnt--; - *(fp)->_ptr++ = (unsigned char)mbchar[i]; - } else { - if (_flsbuf((unsigned char)mbchar[i], fp) == EOF) { - return WEOF; - } - } - } -#else - fp->_flag |= _IODIRTY; - if (fp->_cnt > 0) { - fp->_cnt--; - *(fp)->_ptr++ = (unsigned char)c; - } else { - if (_flsbuf(c, fp) == EOF) { - return WEOF; - } - } -#endif - return c; - } - return WEOF; -} diff --git a/reactos/lib/crt/stdio/putchar.c b/reactos/lib/crt/stdio/putchar.c deleted file mode 100644 index cc2b43e45d5..00000000000 --- a/reactos/lib/crt/stdio/putchar.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdio/putchar.c - * PURPOSE: Writes a character to stdout - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ -#include - -#include - -#undef putc -#undef putchar -#undef putwc -#undef putwchar - -/* - * @implemented - */ -_TINT _puttchar(_TINT c) -{ - _TINT r = _puttc(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 deleted file mode 100644 index 4171aa006d1..00000000000 --- a/reactos/lib/crt/stdio/puts.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#undef putchar -#undef putwchar - - -/* - * @implemented - */ -int puts(const char *s) -{ - int c; - - while ((c = *s++)) { - putchar(c); - } - return putchar('\n'); -} - -/* - * @implemented - */ -int _putws(const wchar_t *s) -{ - wint_t c; - - while ((c = *s++)) { - putwchar(c); - } - return putwchar(L'\n'); -} diff --git a/reactos/lib/crt/stdio/putw.c b/reactos/lib/crt/stdio/putw.c deleted file mode 100644 index bc2950970df..00000000000 --- a/reactos/lib/crt/stdio/putw.c +++ /dev/null @@ -1,32 +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 - -/* - * Write the word (int) W to STREAM. - * - * @implemented - */ -int _putw(int w,FILE *stream) -{ - /* Is there a better way? */ - if (fwrite( &w, sizeof(w), 1, stream) < 1) - return(EOF); - return(0); -} diff --git a/reactos/lib/crt/stdio/putwchar.c b/reactos/lib/crt/stdio/putwchar.c deleted file mode 100644 index e6f31b8add2..00000000000 --- a/reactos/lib/crt/stdio/putwchar.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "putchar.c" diff --git a/reactos/lib/crt/stdio/remove.c b/reactos/lib/crt/stdio/remove.c deleted file mode 100644 index bf599275c1d..00000000000 --- a/reactos/lib/crt/stdio/remove.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -#define NDEBUG -#include - -/* - * @implemented - */ -int _tremove(const _TCHAR *fn) -{ - int result = 0; - DPRINT(MK_STR(_tremove)"('%"sT"')\n", fn); - if (!DeleteFile(fn)) - result = -1; - DPRINT("%d\n", result); - return result; -} - diff --git a/reactos/lib/crt/stdio/rename.c b/reactos/lib/crt/stdio/rename.c deleted file mode 100644 index 8f4abcae7ea..00000000000 --- a/reactos/lib/crt/stdio/rename.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Created - */ - -#include -#include - -/* - * @implemented - */ -int _trename(const _TCHAR* old_, const _TCHAR* new_) -{ - if (old_ == NULL || new_ == NULL) - return -1; - - if (!MoveFile(old_, new_)) - return -1; - - return 0; -} diff --git a/reactos/lib/crt/stdio/rewind.c b/reactos/lib/crt/stdio/rewind.c deleted file mode 100644 index 2c1facd695a..00000000000 --- a/reactos/lib/crt/stdio/rewind.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -void rewind(FILE *f) -{ - fflush(f); - _lseek(_fileno(f), 0L, SEEK_SET); - f->_cnt = 0; - f->_ptr = f->_base; - f->_flag &= ~(_IOERR|_IOEOF|_IOAHEAD); -} diff --git a/reactos/lib/crt/stdio/rmtmp.c b/reactos/lib/crt/stdio/rmtmp.c deleted file mode 100644 index e9e343c12a7..00000000000 --- a/reactos/lib/crt/stdio/rmtmp.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdio/rmtmp.c - * PURPOSE: remove temporary files in current directory - * PROGRAMMER: Ariadne - * UPDATE HISTORY: - * Created 19/01/99 - * NOTE Not tested. - */ -#include - -// should be replace by a closure of the tmp files -extern __file_rec *__file_rec_list; - -int _rmtmp( void ) -{ -/* -loop files and check for _tmpfname -*/ - __file_rec *fr = __file_rec_list; - __file_rec **last_fr = &__file_rec_list; - - int total_closed = 0; - int i = 0; - char temp_name[260]; - - /* Try to find an empty slot */ - while (fr) - { - last_fr = &(fr->next); - - /* If one of the existing slots is available, return it */ - for (i=0; icount; i++) { - if (fr->files[i]->_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++; - } - } - } - - /* If this one is full, go to the next */ - if (fr->count == __FILE_REC_MAX) - fr = fr->next; - else - /* it isn't full, we can add to it */ - break; - } - return total_closed; -} diff --git a/reactos/lib/crt/stdio/setbuf.c b/reactos/lib/crt/stdio/setbuf.c deleted file mode 100644 index 48b27cb7ad9..00000000000 --- a/reactos/lib/crt/stdio/setbuf.c +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -void setbuf(FILE *f, char *buf) -{ - if (buf) - setvbuf(f, buf, _IOFBF, BUFSIZ); - else - setvbuf(f, 0, _IONBF, BUFSIZ); -} diff --git a/reactos/lib/crt/stdio/setvbuf.c b/reactos/lib/crt/stdio/setvbuf.c deleted file mode 100644 index bcaa10a5c1c..00000000000 --- a/reactos/lib/crt/stdio/setvbuf.c +++ /dev/null @@ -1,64 +0,0 @@ -/* 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 - -/* - * @implemented - */ -int setvbuf(FILE *f, char *buf, int type, size_t len) -{ - int mine=0; - if (!__validfp (f) ) { - __set_errno (EINVAL); - return 0; - } - if ( f->_base != NULL ) - fflush(f); - /* Cannot use _IOLBF as flag value because _IOLBF is equal to _IOSTRG */ - if (type == _IOLBF) - type = _IO_LBF; - - switch (type) - { - case _IOFBF: - case _IO_LBF: - if (len <= 0) { - __set_errno (EINVAL); - return EOF; - } - if (buf == 0) - { - buf = (char *)malloc(len+1); - if (buf == NULL) { - __set_errno (ENOMEM); - return -1; - } - mine = 1; - } - /* FALLTHROUGH */ - case _IONBF: - if (f->_base != NULL && f->_flag & _IOMYBUF) - free(f->_base); - f->_cnt = 0; - - f->_flag &= ~(_IONBF|_IOFBF|_IO_LBF|_IOUNGETC); - f->_flag |= type; - if (type != _IONBF) - { - if (mine) - f->_flag |= _IOMYBUF; - f->_ptr = f->_base = buf; - f->_bufsiz = len; - } - else - { - f->_base = 0; - f->_bufsiz = 0; - } - return 0; - default: - __set_errno (EINVAL); - return EOF; - } -} diff --git a/reactos/lib/crt/stdio/sprintf.c b/reactos/lib/crt/stdio/sprintf.c deleted file mode 100644 index 04c185bebc1..00000000000 --- a/reactos/lib/crt/stdio/sprintf.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -/* Copyright (C) 1991, 1995 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 - -#undef sprintf -#undef wsprintf - -/* - * @implemented - */ -int -crt_sprintf(_TCHAR *str, const _TCHAR *fmt, ...) -{ - va_list arg; - int done; - - va_start (arg, fmt); - 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 */ -int -crt__snprintf (_TCHAR *s, size_t maxlen,const _TCHAR *format, ...) -{ - va_list arg; - int done; - - va_start (arg, format); - done = _vsntprintf(s, maxlen, format, arg); - va_end (arg); - - return done; -} - - diff --git a/reactos/lib/crt/stdio/stdhnd.c b/reactos/lib/crt/stdio/stdhnd.c deleted file mode 100644 index 3df13a18207..00000000000 --- a/reactos/lib/crt/stdio/stdhnd.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include - -FILE _iob[20] = -{ - // stdin -{ - NULL, 0, NULL, - _IOREAD | _IO_LBF , - 0, 0,0, NULL -}, - // stdout -{ - NULL, 0, NULL, - _IOWRT | _IO_LBF |_IOSTRG, - 1,0,0, NULL -}, - // stderr -{ - NULL, 0, NULL, - _IOWRT | _IONBF, - 2,0,0, NULL -} -}; - -/* - * @implemented - */ -FILE *__p__iob(void) -{ - return &_iob[0]; -} diff --git a/reactos/lib/crt/stdio/swprintf.c b/reactos/lib/crt/stdio/swprintf.c deleted file mode 100644 index a92f30e0b1d..00000000000 --- a/reactos/lib/crt/stdio/swprintf.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -/* Copyright (C) 1991, 1995 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. */ - -#define UNICODE -#define _UNICODE -#include -#include -#include - -#undef sprintf -#undef wsprintf - -int -crt_swprintf(_TCHAR *str, const _TCHAR *fmt, ...) -{ - va_list arg; - int done; - - va_start (arg, fmt); - 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 */ -int -crt__snwprintf (_TCHAR *s, size_t maxlen,const _TCHAR *format, ...) -{ - va_list arg; - int done; - - va_start (arg, format); - done = _vsntprintf(s, maxlen, format, arg); - va_end (arg); - - return done; -} diff --git a/reactos/lib/crt/stdio/tempnam.c b/reactos/lib/crt/stdio/tempnam.c deleted file mode 100644 index 075b702f874..00000000000 --- a/reactos/lib/crt/stdio/tempnam.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -/* - * @implemented - */ -_TCHAR* _ttempnam(const _TCHAR* dir,const _TCHAR* prefix) -{ - _TCHAR* TempFileName = malloc(MAX_PATH*sizeof(_TCHAR)); - _TCHAR* d; - - if (dir == NULL) - d = _tgetenv(_T("TMP")); - else - d = (_TCHAR*)dir; - -#ifdef _MSVCRT_LIB_ // TODO: check on difference? - if (GetTempFileName(d, prefix, 1, TempFileName) == 0) { -#else// TODO: FIXME: review which is correct - if (GetTempFileName(d, prefix, 0, TempFileName) == 0) { -#endif /*_MSVCRT_LIB_*/ - - free(TempFileName); - return NULL; - } - - return TempFileName; -} diff --git a/reactos/lib/crt/stdio/tmpfile.c b/reactos/lib/crt/stdio/tmpfile.c deleted file mode 100644 index 0cfdf7b8986..00000000000 --- a/reactos/lib/crt/stdio/tmpfile.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include - -#include - -FILE * __alloc_file(void); - -/* - * @implemented - */ -FILE * -tmpfile(void) -{ - int temp_fd; - FILE *f; - char *temp_name = tmpnam(0); - char *n_t_r = (char *)malloc(L_tmpnam); - - if (!n_t_r) - return 0; - - /* We could have a race condition, whereby another program - (in another virtual machine, or if the temporary file is - in a directory which is shared via a network) opens the - file returned by `tmpnam' between the call above and the - moment when we actually open the file below. This loop - retries the call to `tmpnam' until we actually succeed - to create the file which didn't exist before. */ - do { - // __set_errno ( 0 ); - temp_fd = _open(temp_name, 0, SH_DENYRW); - // if ( *_errno() == ENOENT ) -// break; - } while (temp_fd == -1 && (temp_name = tmpnam(0)) != 0); - - if (temp_name == 0) - return 0; - - /* This should have been fdopen(temp_fd, "wb+"), but `fdopen' - is non-ANSI. So we need to dump some of its guts here. Sigh... */ - f = __alloc_file(); - if (f) - { - f->_file = temp_fd; - f->_cnt = 0; - f->_bufsiz = 0; - f->_flag = _IORMONCL | _IOREAD | _IOWRT; - f->_tmpfname = n_t_r; - strcpy(f->_tmpfname , temp_name); - f->_base = f->_ptr = NULL; - } - else - { - _close(temp_fd); - remove(temp_name); - free(n_t_r); - } - return f; -} diff --git a/reactos/lib/crt/stdio/tmpnam.c b/reactos/lib/crt/stdio/tmpnam.c deleted file mode 100644 index 551ec8c4606..00000000000 --- a/reactos/lib/crt/stdio/tmpnam.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -/* - * @implemented - */ -_TCHAR* _ttmpnam(_TCHAR* s) -{ - _TCHAR PathName[MAX_PATH]; - static _TCHAR static_buf[MAX_PATH]; - - 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 deleted file mode 100644 index ac6c681e170..00000000000 --- a/reactos/lib/crt/stdio/ungetc.c +++ /dev/null @@ -1,35 +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 - - -/* - * @implemented - */ -_TINT _ungettc(_TINT c, FILE *f) -{ - if (!__validfp (f) || !OPEN4READING(f)) { - __set_errno (EINVAL); - return _TEOF; - } - - if (c == _TEOF) - return _TEOF; - - if (f->_ptr == f->_base) - { - if (!f->_cnt == 0) - return _TEOF; - } - - fseek(f, -sizeof(_TCHAR), SEEK_CUR); - - if(*(_TCHAR*)f->_ptr != c) - *((_TCHAR*)(f->_ptr)) = c; - - return c; -} - diff --git a/reactos/lib/crt/stdio/ungetwc.c b/reactos/lib/crt/stdio/ungetwc.c deleted file mode 100644 index fe8f7fd1e9c..00000000000 --- a/reactos/lib/crt/stdio/ungetwc.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "ungetc.c" diff --git a/reactos/lib/crt/stdio/vfprintf.c b/reactos/lib/crt/stdio/vfprintf.c deleted file mode 100644 index bf76e8298c8..00000000000 --- a/reactos/lib/crt/stdio/vfprintf.c +++ /dev/null @@ -1,874 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -extern int __mb_cur_max; -int __vfprintf(FILE*, const char*, va_list); - -/* - * @implemented - */ -int vfprintf(FILE* f, const char* fmt, va_list ap) -{ - int len; - char localbuf[BUFSIZ]; - -#if 0 - __fileno_lock(_fileno(f)); -#endif - if (f->_flag & _IONBF) { - f->_flag &= ~_IONBF; - f->_ptr = f->_base = localbuf; - f->_bufsiz = f->_cnt = BUFSIZ; - len = __vfprintf(f, fmt, ap); - (void)fflush(f); - f->_flag |= _IONBF; - f->_base = NULL; - f->_bufsiz = 0; - f->_cnt = 0; - } else { - len = __vfprintf(f,fmt, ap); - } -#if 0 - __fileno_unlock(_fileno(f)); -#endif - return (ferror(f) ? EOF : len); -} - - -/* - * linux/lib/vsprintf.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - -/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ -/* - * Wirzenius wrote this portably, Torvalds fucked it up :-) - */ - -/* - * Appropiated for the reactos kernel, March 1998 -- David Welch - */ - -#include - -#include -#include -#include -#include - - -#define ZEROPAD 1 /* pad with zero */ -#define SIGN 2 /* unsigned/signed long */ -#define PLUS 4 /* show plus */ -#define SPACE 8 /* space if plus */ -#define LEFT 16 /* left justified */ -#define SPECIAL 32 /* 0x */ -#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ -#define ZEROTRUNC 128 /* truncate zero 's */ - - -static int skip_atoi(const char **s) -{ - int i=0; - - while (isdigit(**s)) - i = i*10 + *((*s)++) - '0'; - return i; -} - - -static int do_div(LONGLONG *n,int base) -{ - int __res = ((ULONGLONG) *n) % (unsigned) base; - *n = ((ULONGLONG) *n) / (unsigned) base; - return __res; -} - - -static int number(FILE * f, LONGLONG num, int base, int size, int precision ,int type) -{ - char c,sign,tmp[66]; - const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; - int i, done = 0; - - if (type & LARGE) - digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - if (type & LEFT) - type &= ~ZEROPAD; - if (base < 2 || base > 36) - return done; - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) { - if (num < 0) { - sign = '-'; - num = -num; - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } - } - if (type & SPECIAL) { - if (base == 16) - size -= 2; - else if (base == 8) - size--; - } - i = 0; - if (num == 0) - tmp[i++]='0'; - else while (num != 0) - tmp[i++] = digits[do_div(&num,base)]; - if (i > precision) - precision = i; - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - { - if (putc(' ',f) == EOF) - return -1; - done++; - } - if (sign) - { - if (putc(sign,f) == EOF) - return -1; - done++; - } - if (type & SPECIAL) { - if (base==8) { - if (putc('0',f) == EOF) - return -1; - done++; - } - else if (base==16) { - if (putc('0', f) == EOF) - return -1; - done++; - if (putc(digits[33],f) == EOF) - return -1; - done++; - } - } - if (!(type & LEFT)) - while (size-- > 0) - { - if (putc(c,f) == EOF) - return -1; - done++; - } - while (i < precision--) - { - if (putc('0', f) == EOF) - return -1; - done++; - } - while (i-- > 0) - { - if (putc(tmp[i],f) == EOF) - return -1; - done++; - } - while (size-- > 0) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - return done; -} - - -static int numberf(FILE * f, double __n, char exp_sign, int size, int precision, int type) -{ - double exponent = 0.0; - double e; - long ie; - - //int x; - char *buf, *tmp; - int i = 0; - int j = 0; - //int k = 0; - - double frac, intr; - double p; - char sign; - char c; - char ro = 0; - int result, done = 0; - - union - { - double* __n; - double_t* n; - } n; - - n.__n = &__n; - - if ( exp_sign == L'g' || exp_sign == L'G' || exp_sign == L'e' || exp_sign == L'E' ) - { - if ( 0 == n.n->mantissal && 0 == n.n->mantissah && 0 == n.n->exponent ) - { - ie = 0; - } - else - { - ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff); - } - - exponent = ie/3.321928; - } - - - if ( exp_sign == 'g' || exp_sign == 'G' ) { - type |= ZEROTRUNC; - if ( exponent < -4 || fabs(exponent) >= precision ) - exp_sign -= 2; // g -> e and G -> E - else - exp_sign = 'f'; - } - - if ( exp_sign == 'e' || exp_sign == 'E' ) { - frac = modf(exponent,&e); - if ( frac > 0.5 ) - e++; - else if ( frac < -0.5 ) - e--; - - result = numberf(f,__n/pow(10.0L,e),'f',size-4, precision, type); - if (result < 0) - return -1; - done += result; - if (putc( exp_sign,f) == EOF) - return -1; - done++; - size--; - ie = (long)e; - type = LEFT | PLUS; - if ( ie < 0 ) - type |= SIGN; - - result = number(f,ie, 10,2, 2,type ); - if (result < 0) - return -1; - done += result; - return done; - } - - if ( exp_sign == 'f' ) { - buf = alloca(4096); - if (type & LEFT) { - type &= ~ZEROPAD; - } - - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) { - if (__n < 0) { - sign = '-'; - __n = fabs(__n); - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } - } - - frac = modf(__n,&intr); - - // # flags forces a . and prevents trucation of trailing zero's - - if ( precision > 0 ) { - //frac = modfl(__n,&intr); - i = precision-1; - while ( i >= 0 ) { - frac*=10.0L; - frac = modf(frac, &p); - buf[i] = (int)p + '0'; - i--; - } - i = precision; - size -= precision; - - ro = 0; - if ( frac > 0.5 ) { - ro = 1; - } - - if ( precision >= 1 || type & SPECIAL) { - buf[i++] = '.'; - size--; - } - } - - if ( intr == 0.0 ) { - buf[i++] = '0'; - size--; - } - else { - while ( intr > 0.0 ) { - p = intr; - intr/=10.0L; - modf(intr, &intr); - - p -= 10.0*intr; - - buf[i++] = (int)p + '0'; - size--; - } - } - - j = 0; - while ( j < i && ro == 1) { - if ( buf[j] >= '0' && buf[j] <= '8' ) { - buf[j]++; - ro = 0; - } - else if ( buf[j] == '9' ) { - buf[j] = '0'; - } - j++; - } - if ( ro == 1 ) - buf[i++] = '1'; - - buf[i] = 0; - - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - { - if (putc(' ',f) == EOF) - return -1; - done++; - } - if (sign) - { - if (putc( sign,f) == EOF) - return -1; - done++; - } - - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - { - if (putc(' ',f) == EOF) - return -1; - done++; - } - if (type & SPECIAL) { - } - - if (!(type & LEFT)) - while (size-- > 0) - { - if (putc(c,f) == EOF) - return -1; - done++; - } - - tmp = buf; - - if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) ) { - j = 0; - while ( j < i && *tmp == L'0' ) { - tmp++; - i--; - } - if ( j < i && *tmp == L'.' ) { - tmp++; - i--; - } - } - - -// else -// while (i < precision--) -// putc('0', f); - while (i-- > 0) - { - if (putc(tmp[i],f) == EOF) - return -1; - done++; - } - while (size-- > 0) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - } - return done; -} - - - - -static int string(FILE *f, const char* s, int len, int field_width, int precision, int flags) -{ - int i, done = 0; - if (s == NULL) - { - s = ""; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && s[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - for (i = 0; i < len; ++i) - { - if (putc(*s++, f) == EOF) - return -1; - done++; - } - while (len < field_width--) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - return done; -} - -static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int precision, int flags) -{ - int i, done = 0; - char * mb; - if (sw == NULL) - { - sw = L""; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && sw[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - mb = malloc(MB_CUR_MAX * sizeof(char)); - if(!mb) - return -1; - for (i = 0; i < len; ++i) - { - int mbcount, j; - mbcount = wctomb(mb, *sw++); - if (mbcount <= 0) - { - break; - } - for (j = 0; j < mbcount; j++) - { - if (putc(mb[j], f) == EOF) - { - free(mb); - return -1; - } - done++; - } - } - while (len < field_width--) - { - if (putc(' ', f) == EOF) - { - free(mb); - return -1; - } - done++; - } - free(mb); - return done; -} - -int __vfprintf(FILE *f, const char *fmt, va_list args) -{ - int len; - ULONGLONG num; - int base; - double _double; - const char *s; - const wchar_t *sw; - int result, done = 0; - - int flags; /* flags to number() */ - - int field_width; /* width of output field */ - int precision; /* min. # of digits for integers; max - number of chars for from string */ - int qualifier = 0; /* 'h', 'l', 'L' or 'I64' for integer fields */ - - for (; *fmt ; ++fmt) { - if (*fmt != '%') { - if (putc(*fmt,f) == EOF) - return -1; - done++; - continue; - } - - /* process flags */ - flags = 0; - repeat: - ++fmt; /* this also skips first '%' */ - switch (*fmt) { - case '-': flags |= LEFT; goto repeat; - case '+': flags |= PLUS; goto repeat; - case ' ': flags |= SPACE; goto repeat; - case '#': flags |= SPECIAL; goto repeat; - case '0': flags |= ZEROPAD; goto repeat; - } - - /* get field width */ - field_width = -1; - if (isdigit(*fmt)) - field_width = skip_atoi(&fmt); - else if (*fmt == '*') { - ++fmt; - /* it's the next argument */ - field_width = va_arg(args, int); - if (field_width < 0) { - field_width = -field_width; - flags |= LEFT; - } - } - - /* get the precision */ - precision = -1; - if (*fmt == '.') { - ++fmt; - if (isdigit(*fmt)) - precision = skip_atoi(&fmt); - else if (*fmt == '*') { - ++fmt; - /* it's the next argument */ - precision = va_arg(args, int); - } - if (precision < 0) - precision = 0; - } - - /* get the conversion qualifier */ - qualifier = 0; - // %Z can be just stand alone or as size_t qualifier - if ( *fmt == 'Z' ) { - qualifier = *fmt; - switch ( *(fmt+1)) { - case 'o': - case 'b': - case 'X': - case 'x': - case 'd': - case 'i': - case 'u': - ++fmt; - break; - default: - break; - } - } else if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') { - qualifier = *fmt; - ++fmt; - } else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') { - qualifier = *fmt; - fmt += 3; - } - - // go fine with ll instead of L - if ( *fmt == 'l' ) { - ++fmt; - qualifier = 'L'; - } - - /* default base */ - base = 10; - - switch (*fmt) { - case 'c': - if (!(flags & LEFT)) - while (--field_width > 0) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - if (qualifier == 'l' || qualifier == 'w') - { - if (putc((unsigned char)(wchar_t) va_arg(args, int), f) == EOF) - return -1; - done++; - } - else - { - if (putc((unsigned char) va_arg(args, int), f) == EOF) - return -1; - done++; - } - while (--field_width > 0) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - continue; - - case 'C': - if (!(flags & LEFT)) - while (--field_width > 0) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - if (qualifier == 'h') - { - if (putc((unsigned char) va_arg(args, int), f) == EOF) - return -1; - done++; - } - else - { - if (putc((unsigned char)(wchar_t) va_arg(args, int), f) == EOF) - return -1; - done++; - } - while (--field_width > 0) - { - if (putc(' ', f) == EOF) - return -1; - done++; - } - continue; - - case 's': - if (qualifier == 'l' || qualifier == 'w') { - /* print unicode string */ - sw = va_arg(args, wchar_t *); - result = stringw(f, sw, -1, field_width, precision, flags); - } else { - /* print ascii string */ - s = va_arg(args, char *); - result = string(f, s, -1, field_width, precision, flags); - } - if (result < 0) - return -1; - done += result; - continue; - - case 'S': - if (qualifier == 'h') { - /* print ascii string */ - s = va_arg(args, char *); - result = string(f, s, -1, field_width, precision, flags); - } else { - /* print unicode string */ - sw = va_arg(args, wchar_t *); - result = stringw(f, sw, -1, field_width, precision, flags); - } - if (result < 0) - return -1; - done += result; - continue; - - case 'Z': - if (qualifier == 'w') { - /* print counted unicode string */ - PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING); - if ((pus == NULL) || (pus->Buffer == NULL)) { - sw = NULL; - len = -1; - } else { - sw = pus->Buffer; - len = pus->Length / sizeof(WCHAR); - } - result = stringw(f, sw, len, field_width, precision, flags); - } else { - /* print counted ascii string */ - PANSI_STRING pas = va_arg(args, PANSI_STRING); - if ((pas == NULL) || (pas->Buffer == NULL)) { - s = NULL; - len = -1; - } else { - s = pas->Buffer; - len = pas->Length; - } - result = string(f, s, -1, field_width, precision, flags); - } - if (result < 0) - return -1; - done += result; - continue; - - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - _double = (double)va_arg(args, double); - - if ( _isnan(_double) ) { - s = "Nan"; - len = 3; - while ( len > 0 ) { - if (putc(*s++,f) == EOF) - return -1; - done++; - len --; - } - } else if ( _isinf(_double) < 0 ) { - s = "-Inf"; - len = 4; - while ( len > 0 ) { - if (putc(*s++,f) == EOF) - return -1; - done++; - len --; - } - } else if ( _isinf(_double) > 0 ) { - s = "+Inf"; - len = 4; - while ( len > 0 ) { - if (putc(*s++,f) == EOF) - return -1; - done++; - len --; - } - } else { - if ( precision == -1 ) - precision = 6; - result = numberf(f,_double,*fmt,field_width,precision,flags); - if (result < 0) - return -1; - done += result; - } - continue; - - case 'p': - if (field_width == -1) { - field_width = 2*sizeof(void *); - flags |= ZEROPAD; - } - result = number(f, - (unsigned long) va_arg(args, void *), 16, - field_width, precision, flags); - if (result < 0) - return -1; - done += result; - continue; - - case 'n': - if (qualifier == 'l') { - long * ip = va_arg(args, long *); - *ip = 0; - } else { - int * ip = va_arg(args, int *); - *ip = 0; - } - continue; - - /* integer number formats - set up the flags and "break" */ - case 'o': - base = 8; - break; - - case 'b': - base = 2; - break; - - case 'X': - flags |= LARGE; - case 'x': - base = 16; - break; - - case 'd': - case 'i': - flags |= SIGN; - case 'u': - break; - - default: - if (*fmt != '%') - { - if (putc('%', f) == EOF) - return -1; - done++; - } - if (*fmt) - { - if (putc(*fmt, f) == EOF) - return -1; - done++; - } - else - --fmt; - continue; - } - - if (qualifier == 'I') - num = va_arg(args, ULONGLONG); - else if (qualifier == 'l') { - if (flags & SIGN) - num = va_arg(args, long); - else - num = va_arg(args, unsigned long); - } - else if (qualifier == 'h') { - if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } - else if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - result = number(f, num, base, field_width, precision, flags); - if (result < 0) - return -1; - done += result; - } - //putc('\0',f); - return done; -} - -/* EOF */ diff --git a/reactos/lib/crt/stdio/vfwprint.c b/reactos/lib/crt/stdio/vfwprint.c deleted file mode 100644 index 03b542a49cd..00000000000 --- a/reactos/lib/crt/stdio/vfwprint.c +++ /dev/null @@ -1,846 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include - -int -__vfwprintf(FILE *fp, const wchar_t *fmt0, va_list argp); - - -/* - * @implemented - */ -int -vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) -{ - int len; - wchar_t localbuf[BUFSIZ]; - -#if 0 - __fileno_lock(_fileno(f)); -#endif - if (f->_flag & _IONBF) { - f->_flag &= ~_IONBF; - f->_ptr = f->_base = (char *)localbuf; - f->_bufsiz = BUFSIZ; - len = __vfwprintf(f,fmt,ap); - (void)fflush(f); - f->_flag |= _IONBF; - f->_base = NULL; - f->_bufsiz = 0; - f->_cnt = 0; - } else - len = __vfwprintf(f,fmt,ap); -#if 0 - __fileno_unlock(_fileno(f)); -#endif - return (ferror(f) ? EOF : len); -} - - - -/* - * linux/lib/vsprintf.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - -/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ -/* - * Wirzenius wrote this portably, Torvalds fucked it up :-) - */ - -/* - * Appropiated for the reactos kernel, March 1998 -- David Welch - */ - -#include -#include - -#define ZEROPAD 1 /* pad with zero */ -#define SIGN 2 /* unsigned/signed long */ -#define PLUS 4 /* show plus */ -#define SPACE 8 /* space if plus */ -#define LEFT 16 /* left justified */ -#define SPECIAL 32 /* 0x */ -#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ -#define ZEROTRUNC 128 /* truncate zero 's */ - - -static int skip_wtoi(const wchar_t **s) -{ - int i=0; - - while (iswdigit(**s)) - i = i*10 + *((*s)++) - L'0'; - return i; -} - - -static int do_div(LONGLONG *n,int base) -{ - int __res = ((ULONGLONG) *n) % (unsigned) base; - *n = ((ULONGLONG) *n) / (unsigned) base; - return __res; -} - - -static int number(FILE * f, LONGLONG num, int base, int size, int precision ,int type) -{ - wchar_t c,sign,tmp[66]; - const wchar_t *digits=L"0123456789abcdefghijklmnopqrstuvwxyz"; - int i, done = 0; - - if (type & LARGE) - digits = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - if (type & LEFT) - type &= ~ZEROPAD; - if (base < 2 || base > 36) - return done; - c = (type & ZEROPAD) ? L'0' : L' '; - sign = 0; - if (type & SIGN) { - if (num < 0) { - sign = L'-'; - num = -num; - size--; - } else if (type & PLUS) { - sign = L'+'; - size--; - } else if (type & SPACE) { - sign = L' '; - size--; - } - } - if (type & SPECIAL) { - if (base == 16) - size -= 2; - else if (base == 8) - size--; - } - i = 0; - if (num == 0) - tmp[i++]=L'0'; - else while (num != 0) - tmp[i++] = digits[do_div(&num,base)]; - if (i > precision) - precision = i; - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - { - if (putwc(L' ',f) == WEOF) - return -1; - done++; - } - - if (sign) - { - if (putwc(sign,f) == WEOF) - return -1; - done++; - } - if (type & SPECIAL) { - if (base==8) { - if (putwc(L'0',f) == WEOF) - return -1; - done++; - } - else if (base==16) { - if (putwc(L'0', f) == WEOF) - return -1; - done++; - if (putwc(digits[33],f) == WEOF) - return -1; - done++; - } - } - if (!(type & LEFT)) - while (size-- > 0) - { - if (putwc(c,f) == WEOF) - return -1; - done++; - } - while (i < precision--) - { - if (putwc(L'0', f) == WEOF) - return -1; - done++; - } - while (i-- > 0) - { - if (putwc(tmp[i],f) == WEOF) - return -1; - done++; - } - while (size-- > 0) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - return done; -} - - -static int numberf(FILE * f, double __n, wchar_t exp_sign, int size, int precision, int type) -{ - double exponent = 0.0; - double e; - long ie; - - //int x; - char *buf, *tmp; - int i = 0; - int j = 0; - //int k = 0; - - double frac, intr; - double p; - wchar_t sign; - wchar_t c; - char ro = 0; - int result, done = 0; - - union - { - double* __n; - double_t* n; - } n; - - n.__n = &__n; - - if ( exp_sign == L'g' || exp_sign == L'G' || exp_sign == L'e' || exp_sign == L'E' ) - { - if ( 0 == n.n->mantissal && 0 == n.n->mantissah && 0 == n.n->exponent ) - { - ie = 0; - } - else - { - ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff); - } - - exponent = ie/3.321928; - } - - - if ( exp_sign == L'g' || exp_sign == L'G' ) { - type |= ZEROTRUNC; - if ( exponent < -4 || fabs(exponent) >= precision ) - exp_sign -= 2; // g -> e and G -> E - else - exp_sign = 'f'; - } - - if ( exp_sign == L'e' || exp_sign == L'E' ) { - frac = modf(exponent,&e); - if ( frac > 0.5 ) - e++; - else if ( frac < -0.5 ) - e--; - - result = numberf(f,__n/pow(10.0L,e),L'f',size-4, precision, type); - if (result < 0) - return -1; - done += result; - if (putwc( exp_sign,f) == WEOF) - return -1; - done++; - size--; - ie = (long)e; - type = LEFT | PLUS; - if ( ie < 0 ) - type |= SIGN; - - result = number(f,ie, 10,2, 2,type ); - if (result < 0) - return -1; - done += result; - return done; - } - - if ( exp_sign == 'f' ) { - buf = alloca(4096); - if (type & LEFT) { - type &= ~ZEROPAD; - } - - c = (type & ZEROPAD) ? L'0' : L' '; - sign = 0; - if (type & SIGN) { - if (__n < 0) { - sign = L'-'; - __n = fabs(__n); - size--; - } else if (type & PLUS) { - sign = L'+'; - size--; - } else if (type & SPACE) { - sign = L' '; - size--; - } - } - - frac = modf(__n,&intr); - - // # flags forces a . and prevents trucation of trailing zero's - - if ( precision > 0 ) { - //frac = modfl(__n,&intr); - i = precision-1; - while ( i >= 0 ) { - frac*=10.0L; - frac = modf(frac, &p); - buf[i] = (int)p + L'0'; - i--; - } - i = precision; - size -= precision; - - ro = 0; - if ( frac > 0.5 ) { - ro = 1; - } - - if ( precision >= 1 || type & SPECIAL) { - buf[i++] = '.'; - size--; - } - } - - if ( intr == 0.0 ) { - buf[i++] = L'0'; - size--; - } - else { - while ( intr > 0.0 ) { - p = intr; - intr/=10.0L; - modf(intr, &intr); - - p -= 10.0*intr; - - buf[i++] = (int)p + L'0'; - size--; - } - } - - j = 0; - while ( j < i && ro == 1 ) { - if ( buf[j] >= L'0' && buf[j] <= L'8' ) { - buf[j]++; - ro = 0; - } - else if ( buf[j] == L'9' ) { - buf[j] = L'0'; - } - j++; - } - if ( ro == 1 ) - buf[i++] = L'1'; - - buf[i] = 0; - - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - { - if (putwc(L' ',f) == WEOF) - return -1; - done++; - } - if (sign) - { - if (putwc( sign,f) == WEOF) - return -1; - done++; - } - - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - { - if (putwc(L' ',f) == WEOF) - return -1; - done++; - } - if (type & SPECIAL) { - } - - if (!(type & LEFT)) - while (size-- > 0) - { - if (putwc(c,f) == WEOF) - return -1; - done++; - } - - tmp = buf; - if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) ) { - j = 0; - while ( j < i && *tmp == L'0' ) { - tmp++; - i--; - } - if ( j < i && *tmp == L'.' ) { - tmp++; - i--; - } - } -// else -// while (i < precision--) -// putwc(L'0', f); - while (i-- > 0) - { - if (putwc(tmp[i],f) == WEOF) - return -1; - done++; - } - while (size-- > 0) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - } - return done; -} - - - -static int string(FILE *f, const char* s, int len, int field_width, int precision, int flags) -{ - int i, done = 0; - if (s == NULL) - { - s = ""; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && s[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - for (i = 0; i < len; ++i) - { - if (putwc(*s++, f) == WEOF) - return -1; - done++; - } - while (len < field_width--) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - return done; -} - -static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int precision, int flags) -{ - int i, done = 0; - if (sw == NULL) - { - sw = L""; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && sw[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - for (i = 0; i < len; ++i) - { - if (putwc(*sw++, f) == WEOF) - return -1; - done++; - } - while (len < field_width--) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - return done; -} - -int __vfwprintf(FILE *f, const wchar_t *fmt, va_list args) -{ - int len = 0; - ULONGLONG num; - int base; - double _double; - const char *s; - const wchar_t* sw; - int result, done = 0; - - int flags; /* flags to number() */ - - int field_width; /* width of output field */ - int precision; /* min. # of digits for integers; max - number of chars for from string */ - int qualifier = 0; /* 'h', 'l', 'L' or 'I64' for integer fields */ - - for (; *fmt ; ++fmt) { - if (*fmt != L'%') { - if (putwc(*fmt,f) == WEOF) - return -1; - done++; - continue; - } - - /* process flags */ - flags = 0; - repeat: - ++fmt; /* this also skips first '%' */ - switch (*fmt) { - case L'-': flags |= LEFT; goto repeat; - case L'+': flags |= PLUS; goto repeat; - case L' ': flags |= SPACE; goto repeat; - case L'#': flags |= SPECIAL; goto repeat; - case L'0': flags |= ZEROPAD; goto repeat; - } - - /* get field width */ - field_width = -1; - if (isxdigit(*fmt)) - field_width = skip_wtoi(&fmt); - else if (*fmt == L'*') { - ++fmt; - /* it's the next argument */ - field_width = va_arg(args, int); - if (field_width < 0) { - field_width = -field_width; - flags |= LEFT; - } - } - - /* get the precision */ - precision = -1; - if (*fmt == L'.') { - ++fmt; - if (iswdigit(*fmt)) - precision = skip_wtoi(&fmt); - else if (*fmt == L'*') { - ++fmt; - /* it's the next argument */ - precision = va_arg(args, int); - } - if (precision < 0) - precision = 0; - } - - /* get the conversion qualifier */ - qualifier=0; - // %Z can be just stand alone or as size_t qualifier - if ( *fmt == 'Z' ) { - qualifier = *fmt; - switch ( *(fmt+1)) { - case L'o': - case L'b': - case L'X': - case L'x': - case L'd': - case L'i': - case L'u': - ++fmt; - break; - default: - break; - } - } else if (*fmt == L'h' || *fmt == L'l' || *fmt == L'L' || *fmt == L'w') { - qualifier = *fmt; - ++fmt; - } else if (*fmt == L'I' && *(fmt+1) == L'6' && *(fmt+2) == L'4') { - qualifier = *fmt; - fmt += 3; - } - - // go fine with ll instead of L - if ( *fmt == L'l' ) { - ++fmt; - qualifier = L'L'; - } - - /* default base */ - base = 10; - - switch (*fmt) { - case L'c': /* finished */ - if (!(flags & LEFT)) - while (--field_width > 0) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - if (qualifier == L'h') - { - if (putwc((wchar_t) va_arg(args, int), f) == WEOF) - return -1; - } - else - { - if (putwc((wchar_t) va_arg(args, int), f) == WEOF) - return -1; - } - done++; - while (--field_width > 0) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - continue; - - case L'C': /* finished */ - if (!(flags & LEFT)) - while (--field_width > 0) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - if (qualifier == L'l' || qualifier == L'w') - { - if (putwc((unsigned char) va_arg(args, int), f) == WEOF) - return -1; - } - else - { - if (putwc((unsigned char) va_arg(args, int), f) == WEOF) - return -1; - } - done++; - while (--field_width > 0) - { - if (putwc(L' ', f) == WEOF) - return -1; - done++; - } - continue; - - case L's': /* finished */ - if (qualifier == L'h') { - /* print ascii string */ - s = va_arg(args, char *); - result = string(f, s, -1, field_width, precision, flags); - } else { - /* print unicode string */ - sw = va_arg(args, wchar_t *); - result = stringw(f, sw, -1, field_width, precision, flags); - } - if (result < 0) - return -1; - done += result; - continue; - - case L'S': - if (qualifier == L'l' || qualifier == L'w') { - /* print unicode string */ - sw = va_arg(args, wchar_t *); - result = stringw(f, sw, -1, field_width, precision, flags); - } else { - /* print ascii string */ - s = va_arg(args, char *); - result = string(f, s, -1, field_width, precision, flags); - } - if (result < 0) - return -1; - done += result; - continue; - - case L'Z': /* finished */ - if (qualifier == L'w') { - /* print counted unicode string */ - PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING); - if ((pus == NULL) || (pus->Buffer)) { - sw = NULL; - len = -1; - } else { - sw = pus->Buffer; - } - result = stringw(f, sw, len, field_width, precision, flags); - } else { - /* print counted ascii string */ - PANSI_STRING pus = va_arg(args, PANSI_STRING); - if ((pus == NULL) || (pus->Buffer)) { - s = NULL; - len = -1; - } else { - s = pus->Buffer; - len = pus->Length; - } - result = string(f, s, len, field_width, precision, flags); - } - if (result < 0) - return -1; - done += result; - continue; - - case L'e': /* finished */ - case L'E': - case L'f': - case L'g': - case L'G': - _double = (double)va_arg(args, double); - - if ( _isnan(_double) ) { - sw = L"Nan"; - len = 3; - while ( len > 0 ) { - if (putwc(*sw++,f) == WEOF) - return -1; - done++; - len --; - } - } else if ( _isinf(_double) < 0 ) { - sw = L"-Inf"; - len = 4; - while ( len > 0 ) { - if (putwc(*sw++,f) == WEOF) - return -1; - done++; - len --; - } - } else if ( _isinf(_double) > 0 ) { - sw = L"+Inf"; - len = 4; - while ( len > 0 ) { - if (putwc(*sw++,f) == WEOF) - return -1; - done++; - len --; - } - } else { - if ( precision == -1 ) - precision = 6; - result = numberf(f,_double,*fmt,field_width,precision,flags); - if (result < 0) - return -1; - done += result; - } - continue; - - case L'p': - if (field_width == -1) { - field_width = 2*sizeof(void *); - flags |= ZEROPAD; - } - result = number(f, - (unsigned long) va_arg(args, void *), 16, - field_width, precision, flags); - if (result < 0) - return -1; - done += result; - continue; - - case L'n': - if (qualifier == L'l') { - long * ip = va_arg(args, long *); - *ip = 0; - } else { - int * ip = va_arg(args, int *); - *ip = 0; - } - continue; - - /* integer number formats - set up the flags and "break" */ - case L'o': - base = 8; - break; - - case L'b': - base = 2; - break; - - case L'X': - flags |= LARGE; - case L'x': - base = 16; - break; - - case L'd': - case L'i': - flags |= SIGN; - case L'u': - break; - - default: - if (*fmt != L'%') - { - if (putwc(L'%', f) == WEOF) - return -1; - done++; - } - if (*fmt) - { - if (putwc(*fmt, f) == WEOF) - return -1; - done++; - } - else - --fmt; - continue; - } - - if (qualifier == L'I') - num = va_arg(args, ULONGLONG); - else if (qualifier == L'l') { - if (flags & SIGN) - num = va_arg(args, long); - else - num = va_arg(args, unsigned long); - } - else if (qualifier == L'h') { - if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } - else if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - result = number(f, num, base, field_width, precision, flags); - if (result < 0) - return -1; - done += result; - } - //putwc(L'\0',f); - return done; -} - -/* EOF */ diff --git a/reactos/lib/crt/stdio/vprintf.c b/reactos/lib/crt/stdio/vprintf.c deleted file mode 100644 index 7f1fe3ce229..00000000000 --- a/reactos/lib/crt/stdio/vprintf.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 1991, 1993, 1995 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 -#undef __OPTIMIZE__ /* Avoid inline `vprintf' function. */ -#include -#include - -#undef vprintf -#undef vwprintf - -//#define _USE_VARARG_ - -#ifndef _USE_VARARG_ - -/* - * @implemented - */ -int _vtprintf(const _TCHAR* format, va_list arg) -{ - int ret; - - ret = _vftprintf(stdout, format, arg); - fflush(stdout); - return ret; -} - -#else - -int _vtprintf(const _TCHAR* format, ...) -{ - va_list arg; - int ret; - - va_start(arg, format); - ret = _vftprintf(stdout, format, arg); - va_end(arg); - - fflush(stdout); - return ret; -} - -#endif diff --git a/reactos/lib/crt/stdio/vsprintf.c b/reactos/lib/crt/stdio/vsprintf.c deleted file mode 100644 index 1a463ca2d44..00000000000 --- a/reactos/lib/crt/stdio/vsprintf.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#include - -/* - * @implemented - */ -int -_vstprintf(_TCHAR *str, const _TCHAR *fmt, va_list ap) -{ - FILE f = {0}; - int len; - - f._flag = _IOWRT|_IOSTRG|_IOBINARY; - f._ptr = (char*)str; - f._cnt = INT_MAX; - f._file = -1; - len = _vftprintf(&f,fmt, ap); - *(_TCHAR*)f._ptr = 0; - return len; -} - - -/* - * @implemented - */ -int -_vsntprintf(_TCHAR *str, size_t maxlen, const _TCHAR *fmt, va_list ap) -{ - FILE f = {0}; - int len; - - f._flag = _IOWRT|_IOSTRG|_IOBINARY; - f._ptr = (char*)str; - f._cnt = maxlen * sizeof(_TCHAR); - f._file = -1; - len = _vftprintf(&f,fmt, ap); - // what if the buffer is full ?? - *(_TCHAR *)f._ptr = 0; - return len; -} diff --git a/reactos/lib/crt/stdio/vswprintf.c b/reactos/lib/crt/stdio/vswprintf.c deleted file mode 100644 index 94da15ff9e7..00000000000 --- a/reactos/lib/crt/stdio/vswprintf.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "vsprintf.c" diff --git a/reactos/lib/crt/stdio/vwprintf.c b/reactos/lib/crt/stdio/vwprintf.c deleted file mode 100644 index c578db04da1..00000000000 --- a/reactos/lib/crt/stdio/vwprintf.c +++ /dev/null @@ -1,5 +0,0 @@ -#define _UNICODE -#define UNICODE - -#include "vprintf.c" - diff --git a/reactos/lib/crt/stdio/wfdopen.c b/reactos/lib/crt/stdio/wfdopen.c deleted file mode 100644 index aa1fcc7bc47..00000000000 --- a/reactos/lib/crt/stdio/wfdopen.c +++ /dev/null @@ -1,7 +0,0 @@ - - -#define _UNICODE -#define UNICODE - -#include "fdopen.c" - diff --git a/reactos/lib/crt/stdio/wfopen.c b/reactos/lib/crt/stdio/wfopen.c deleted file mode 100644 index f0175d84959..00000000000 --- a/reactos/lib/crt/stdio/wfopen.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "fopen.c" diff --git a/reactos/lib/crt/stdio/wfreopen.c b/reactos/lib/crt/stdio/wfreopen.c deleted file mode 100644 index 0453bfb6905..00000000000 --- a/reactos/lib/crt/stdio/wfreopen.c +++ /dev/null @@ -1,6 +0,0 @@ - -#define UNICODE -#define _UNICODE - -#include "freopen.c" - diff --git a/reactos/lib/crt/stdio/wfsopen.c b/reactos/lib/crt/stdio/wfsopen.c deleted file mode 100644 index 8a3266cb4ca..00000000000 --- a/reactos/lib/crt/stdio/wfsopen.c +++ /dev/null @@ -1,5 +0,0 @@ -#define _UNICODE -#define UNICODE - -#include "fsopen.c" - diff --git a/reactos/lib/crt/stdio/wpopen.c b/reactos/lib/crt/stdio/wpopen.c deleted file mode 100644 index 900d1d8bb8f..00000000000 --- a/reactos/lib/crt/stdio/wpopen.c +++ /dev/null @@ -1,5 +0,0 @@ -#define _UNICODE -#define UNICODE - -#include "popen.c" - diff --git a/reactos/lib/crt/stdio/wprintf.c b/reactos/lib/crt/stdio/wprintf.c deleted file mode 100644 index 65419d3339d..00000000000 --- a/reactos/lib/crt/stdio/wprintf.c +++ /dev/null @@ -1,5 +0,0 @@ -#define _UNICODE -#define UNICODE - -#include "printf.c" - diff --git a/reactos/lib/crt/stdio/wremove.c b/reactos/lib/crt/stdio/wremove.c deleted file mode 100644 index ce56997314c..00000000000 --- a/reactos/lib/crt/stdio/wremove.c +++ /dev/null @@ -1,4 +0,0 @@ -#define UNICODE -#define _UNICODE - -#include "remove.c" diff --git a/reactos/lib/crt/stdio/wrename.c b/reactos/lib/crt/stdio/wrename.c deleted file mode 100644 index bb6eda1d144..00000000000 --- a/reactos/lib/crt/stdio/wrename.c +++ /dev/null @@ -1,6 +0,0 @@ - -#define _UNICODE -#define UNICODE - -#include "rename.c" - diff --git a/reactos/lib/crt/stdio/wtempnam.c b/reactos/lib/crt/stdio/wtempnam.c deleted file mode 100644 index ec9e2bd9053..00000000000 --- a/reactos/lib/crt/stdio/wtempnam.c +++ /dev/null @@ -1,6 +0,0 @@ - -#define _UNICODE -#define UNICODE - -#include "tempnam.c" - diff --git a/reactos/lib/crt/stdio/wtmpnam.c b/reactos/lib/crt/stdio/wtmpnam.c deleted file mode 100644 index be2782c301a..00000000000 --- a/reactos/lib/crt/stdio/wtmpnam.c +++ /dev/null @@ -1,5 +0,0 @@ - -#define _UNICODE -#define UNICODE - -#include "tmpnam.c" diff --git a/reactos/lib/crt/stdlib/_exit.c b/reactos/lib/crt/stdlib/_exit.c deleted file mode 100644 index 3a5c2d3e8bb..00000000000 --- a/reactos/lib/crt/stdlib/_exit.c +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include - -struct __atexit *__atexit_ptr = 0; - -/* - * @implemented - */ -void exit(int status) -{ - //int i; - -/* - if (__stdio_cleanup_hook) - __stdio_cleanup_hook(); - for (i=0; i -#include - -char *msg ="Abort\n\r"; - -/* - * @implemented - */ -void abort() -{ - fflush(NULL); - _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 deleted file mode 100644 index 24f6351b574..00000000000 --- a/reactos/lib/crt/stdlib/abs.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -int -abs(int j) -{ - return j<0 ? -j : j; -} diff --git a/reactos/lib/crt/stdlib/atexit.c b/reactos/lib/crt/stdlib/atexit.c deleted file mode 100644 index 0b6a952854b..00000000000 --- a/reactos/lib/crt/stdlib/atexit.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -void _atexit_cleanup(void) -{ - struct __atexit *next, *a = __atexit_ptr; - __atexit_ptr = 0; /* to prevent infinite loops */ - while (a) - { - (a->__function)(); - next = a->__next; - free(a); - a = next; - } -} - -/* - * @implemented - * - * Ported from WINE - * Copyright (C) 2000 Jon Griffiths - */ -_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end) -{ - _onexit_t *tmp; - int len; - - if (!start || !*start || !end || !*end) - return NULL; - - len = (*end - *start); - if (++len <= 0) - return NULL; - - tmp = (_onexit_t *)realloc(*start, len * sizeof(tmp)); - if (!tmp) - return NULL; - - *start = tmp; - *end = tmp + len; - tmp[len - 1] = func; - - return func; -} - -/* - * @implemented - */ -_onexit_t _onexit(_onexit_t a) -{ - struct __atexit *ap; - if (a == 0) - return NULL; - ap = (struct __atexit *)malloc(sizeof(struct __atexit)); - if (!ap) - return NULL; - ap->__next = __atexit_ptr; - ap->__function = (void (*)(void))a; - __atexit_ptr = ap; - return a; -} - -/* - * @implemented - */ -int atexit(void (*a)(void)) -{ - return _onexit((_onexit_t)a) == (_onexit_t)a ? 0 : -1; -} diff --git a/reactos/lib/crt/stdlib/atof.c b/reactos/lib/crt/stdlib/atof.c deleted file mode 100644 index 47296631b96..00000000000 --- a/reactos/lib/crt/stdlib/atof.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -double -atof(const char *ascii) -{ - return strtod(ascii, 0); -} diff --git a/reactos/lib/crt/stdlib/atoi.c b/reactos/lib/crt/stdlib/atoi.c deleted file mode 100644 index 99a6eda4371..00000000000 --- a/reactos/lib/crt/stdlib/atoi.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -int -_ttoi(const _TCHAR *str) -{ - return (int)_tcstol(str, 0, 10); -} diff --git a/reactos/lib/crt/stdlib/atoi64.c b/reactos/lib/crt/stdlib/atoi64.c deleted file mode 100644 index d97d359ee6f..00000000000 --- a/reactos/lib/crt/stdlib/atoi64.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -__int64 -_atoi64(const char *nptr) -{ - char *s = (char *)nptr; - __int64 acc = 0; - int neg = 0; - - while(isspace((int)*s)) - s++; - if (*s == '-') - { - neg = 1; - s++; - } - else if (*s == '+') - s++; - - while (isdigit((int)*s)) - { - acc = 10 * acc + ((int)*s - '0'); - s++; - } - - if (neg) - acc *= -1; - return acc; -} diff --git a/reactos/lib/crt/stdlib/atol.c b/reactos/lib/crt/stdlib/atol.c deleted file mode 100644 index 58e0aa78028..00000000000 --- a/reactos/lib/crt/stdlib/atol.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -/* - * @implemented - */ -long -_ttol(const _TCHAR *str) -{ - return _tcstol(str, 0, 10); -} diff --git a/reactos/lib/crt/stdlib/atold.c b/reactos/lib/crt/stdlib/atold.c deleted file mode 100644 index ce3f33ac434..00000000000 --- a/reactos/lib/crt/stdlib/atold.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -long double -_atold(const char *ascii) -{ - return _strtold(ascii, 0); -} diff --git a/reactos/lib/crt/stdlib/bsearch.c b/reactos/lib/crt/stdlib/bsearch.c deleted file mode 100644 index e1e4f11e586..00000000000 --- a/reactos/lib/crt/stdlib/bsearch.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -void * -bsearch(const void *key, const void *base0, size_t nelem, - size_t size, int (*cmp)(const void *ck, const void *ce)) -{ - char *base = (char *)base0; - int lim, cmpval; - void *p; - - for (lim = nelem; lim != 0; lim >>= 1) - { - p = base + (lim >> 1) * size; - cmpval = (*cmp)(key, p); - if (cmpval == 0) - return p; - if (cmpval > 0) - { /* key > p: move right */ - base = (char *)p + size; - lim--; - } /* else move left */ - } - return 0; -} diff --git a/reactos/lib/crt/stdlib/div.c b/reactos/lib/crt/stdlib/div.c deleted file mode 100644 index 70210d5ce10..00000000000 --- a/reactos/lib/crt/stdlib/div.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -div_t -div(int num, int denom) -{ - div_t r; - - if (num > 0 && denom < 0) { - num = -num; - denom = -denom; - } - r.quot = num / denom; - r.rem = num % denom; - if (num < 0 && denom > 0) - { - if (r.rem > 0) - { - r.quot++; - r.rem -= denom; - } - } - return r; -} diff --git a/reactos/lib/crt/stdlib/doserrmap.h b/reactos/lib/crt/stdlib/doserrmap.h deleted file mode 100644 index 3b1307146f4..00000000000 --- a/reactos/lib/crt/stdlib/doserrmap.h +++ /dev/null @@ -1,82 +0,0 @@ -/* doserrmap.h: auto-generated from winerror.h and errno.h using undoc'd _dosmaperr. */ - -#ifndef doserrmap_h -#define doserrmap_h - -struct { - unsigned long winerr; - int en; -} doserrmap[] = { - { ERROR_FILE_NOT_FOUND, ENOENT }, - { ERROR_PATH_NOT_FOUND, ENOENT }, - { ERROR_TOO_MANY_OPEN_FILES, EMFILE }, - { ERROR_ACCESS_DENIED, EACCES }, - { ERROR_INVALID_HANDLE, EBADF }, - { ERROR_ARENA_TRASHED, ENOMEM }, - { ERROR_NOT_ENOUGH_MEMORY, ENOMEM }, - { ERROR_INVALID_BLOCK, ENOMEM }, - { ERROR_BAD_ENVIRONMENT, E2BIG }, - { ERROR_BAD_FORMAT, ENOEXEC }, - { ERROR_INVALID_DRIVE, ENOENT }, - { ERROR_CURRENT_DIRECTORY, EACCES }, - { ERROR_NOT_SAME_DEVICE, EXDEV }, - { ERROR_NO_MORE_FILES, ENOENT }, - { ERROR_WRITE_PROTECT, EACCES }, - { ERROR_BAD_UNIT, EACCES }, - { ERROR_NOT_READY, EACCES }, - { ERROR_BAD_COMMAND, EACCES }, - { ERROR_CRC, EACCES }, - { ERROR_BAD_LENGTH, EACCES }, - { ERROR_SEEK, EACCES }, - { ERROR_NOT_DOS_DISK, EACCES }, - { ERROR_SECTOR_NOT_FOUND, EACCES }, - { ERROR_OUT_OF_PAPER, EACCES }, - { ERROR_WRITE_FAULT, EACCES }, - { ERROR_READ_FAULT, EACCES }, - { ERROR_GEN_FAILURE, EACCES }, - { ERROR_SHARING_VIOLATION, EACCES }, - { ERROR_LOCK_VIOLATION, EACCES }, - { ERROR_WRONG_DISK, EACCES }, - { ERROR_SHARING_BUFFER_EXCEEDED, EACCES }, - { ERROR_BAD_NETPATH, ENOENT }, - { ERROR_NETWORK_ACCESS_DENIED, EACCES }, - { ERROR_BAD_NET_NAME, ENOENT }, - { ERROR_FILE_EXISTS, EEXIST }, - { ERROR_CANNOT_MAKE, EACCES }, - { ERROR_FAIL_I24, EACCES }, - { ERROR_NO_PROC_SLOTS, EAGAIN }, - { ERROR_DRIVE_LOCKED, EACCES }, - { ERROR_BROKEN_PIPE, EPIPE }, - { ERROR_DISK_FULL, ENOSPC }, - { ERROR_INVALID_TARGET_HANDLE, EBADF }, - { ERROR_WAIT_NO_CHILDREN, ECHILD }, - { ERROR_CHILD_NOT_COMPLETE, ECHILD }, - { ERROR_DIRECT_ACCESS_HANDLE, EBADF }, - { ERROR_SEEK_ON_DEVICE, EACCES }, - { ERROR_DIR_NOT_EMPTY, ENOTEMPTY }, - { ERROR_NOT_LOCKED, EACCES }, - { ERROR_BAD_PATHNAME, ENOENT }, - { ERROR_MAX_THRDS_REACHED, EAGAIN }, - { ERROR_LOCK_FAILED, EACCES }, - { ERROR_ALREADY_EXISTS, EEXIST }, - { ERROR_INVALID_STARTING_CODESEG, ENOEXEC }, - { ERROR_INVALID_STACKSEG, ENOEXEC }, - { ERROR_INVALID_MODULETYPE, ENOEXEC }, - { ERROR_INVALID_EXE_SIGNATURE, ENOEXEC }, - { ERROR_EXE_MARKED_INVALID, ENOEXEC }, - { ERROR_BAD_EXE_FORMAT, ENOEXEC }, - { ERROR_ITERATED_DATA_EXCEEDS_64k, ENOEXEC }, - { ERROR_INVALID_MINALLOCSIZE, ENOEXEC }, - { ERROR_DYNLINK_FROM_INVALID_RING, ENOEXEC }, - { ERROR_IOPL_NOT_ENABLED, ENOEXEC }, - { ERROR_INVALID_SEGDPL, ENOEXEC }, - { ERROR_AUTODATASEG_EXCEEDS_64k, ENOEXEC }, - { ERROR_RING2SEG_MUST_BE_MOVABLE, ENOEXEC }, - { ERROR_RELOC_CHAIN_XEEDS_SEGLIM, ENOEXEC }, - { ERROR_INFLOOP_IN_RELOC_CHAIN, ENOEXEC }, - { ERROR_FILENAME_EXCED_RANGE, ENOENT }, - { ERROR_NESTING_NOT_ALLOWED, EAGAIN }, - { ERROR_NOT_ENOUGH_QUOTA, ENOMEM } -}; - -#endif /* doserrmap_h */ diff --git a/reactos/lib/crt/stdlib/ecvt.c b/reactos/lib/crt/stdlib/ecvt.c deleted file mode 100644 index 0f11ad8c6d4..00000000000 --- a/reactos/lib/crt/stdlib/ecvt.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include - -char *ecvtbuf (double, int, int *, int *, char *); - -/* - * @implemented - */ -char * -_ecvt (double value, int ndigits, int *decpt, int *sign) -{ - static char ecvt_buf[DBL_MAX_10_EXP + 10]; - return ecvtbuf (value, ndigits, decpt, sign, ecvt_buf); -} diff --git a/reactos/lib/crt/stdlib/ecvtbuf.c b/reactos/lib/crt/stdlib/ecvtbuf.c deleted file mode 100644 index a218b92bea7..00000000000 --- a/reactos/lib/crt/stdlib/ecvtbuf.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include -// #include - -void __ecvround (char *, char *, const char *, int *); - -void -__ecvround (char *numbuf, char *last_digit, const char *after_last, int *decpt) -{ - char *p; - int carry = 0; - - /* Do we have at all to round the last digit? */ - if (*after_last > '4') - { - p = last_digit; - carry = 1; - - /* Propagate the rounding through trailing '9' digits. */ - do { - int sum = *p + carry; - carry = sum > '9'; - *p-- = sum - carry * 10; - } while (carry && p >= numbuf); - - /* We have 9999999... which needs to be rounded to 100000.. */ - if (carry && p == numbuf) - { - *p = '1'; - *decpt += 1; - } - } -} - -char * -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; */ - /* two extra for rounding */ - /* 15 extra for alignment */ - char *s = cvtbuf, *d = buf; - - /* Produce two extra digits, so we could round properly. */ - sprintf (cvtbuf, "%-+.*E", ndigits + 2, value); - *decpt = 0; - - /* The sign. */ - if (*s++ == '-') - *sign = 1; - else - *sign = 0; - - /* Special values get special treatment. */ - if (strncmp (s, "Inf", 3) == 0) - { - /* SunOS docs says we have return "Infinity" for NDIGITS >= 8. */ - memcpy (buf, INFINITY, ndigits >= 8 ? 9 : 3); - if (ndigits < 8) - buf[3] = '\0'; - } - else if (strcmp (s, "NaN") == 0) - memcpy (buf, s, 4); - else - { - char *last_digit, *digit_after_last; - - /* Copy (the single) digit before the decimal. */ - while (*s && *s != decimal && d - buf < ndigits) - *d++ = *s++; - - /* If we don't see any exponent, here's our decimal point. */ - *decpt = d - buf; - if (*s) - s++; - - /* Copy the fraction digits. */ - while (*s && *s != 'E' && d - buf < ndigits) - *d++ = *s++; - - /* Remember the last digit copied and the one after it. */ - last_digit = d > buf ? d - 1 : d; - digit_after_last = s; - - /* Get past the E in exponent field. */ - while (*s && *s++ != 'E') - ; - - /* Adjust the decimal point by the exponent value. */ - *decpt += atoi (s); - - /* Pad with zeroes if needed. */ - while (d - buf < ndigits) - *d++ = '0'; - - /* Zero-terminate. */ - *d = '\0'; - - /* Round if necessary. */ - __ecvround (buf, last_digit, digit_after_last, decpt); - } - return buf; -} diff --git a/reactos/lib/crt/stdlib/errno.c b/reactos/lib/crt/stdlib/errno.c deleted file mode 100644 index be38edfc46b..00000000000 --- a/reactos/lib/crt/stdlib/errno.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $Id$ - * - */ -#include -#include "doserrmap.h" - -/* - * @implemented - */ -int* __doserrno(void) -{ - return (int*)(&GetThreadData()->tdoserrno); -} - -/* - * @implemented - */ -int *_errno(void) -{ - return(&GetThreadData()->terrno); -} - - -int __set_doserrno(int error) -{ - PTHREADDATA ThreadData; - - ThreadData = GetThreadData(); - if (ThreadData) - ThreadData->tdoserrno = error; - - return(error); -} - -int __set_errno(int error) -{ - PTHREADDATA ThreadData; - - ThreadData = GetThreadData(); - if (ThreadData) - ThreadData->terrno = error; - - return(error); -} - -/* - * This function sets both doserrno to the passed in OS error code - * and also maps this to an appropriate errno code. The mapping - * has been deduced automagically by running this functions, which - * exists in MSVCRT but is undocumented, on all the error codes in - * winerror.h. - */ -void _dosmaperr(unsigned long oserror) -{ - int pos, base, lim; - - __set_doserrno(oserror); - - /* Use binary chop to find the corresponding errno code */ - for (base=0, lim=sizeof(doserrmap)/sizeof(doserrmap[0]); lim; lim >>= 1) { - pos = base+(lim >> 1); - if (doserrmap[pos].winerr == oserror) { - __set_errno(doserrmap[pos].en); - return; - } else if (doserrmap[pos].winerr < oserror) { - base = pos + 1; - --lim; - } - } - /* EINVAL appears to be the default */ - __set_errno(EINVAL); -} - -/* EOF */ diff --git a/reactos/lib/crt/stdlib/fcvt.c b/reactos/lib/crt/stdlib/fcvt.c deleted file mode 100644 index b4e51a12fe2..00000000000 --- a/reactos/lib/crt/stdlib/fcvt.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include - -char *fcvtbuf (double, int, int *, int *, char *); - -/* - * @implemented - */ -char * -_fcvt (double value, int ndigits, int *decpt, int *sign) -{ - static char fcvt_buf[2 * DBL_MAX_10_EXP + 10]; - return fcvtbuf (value, ndigits, decpt, sign, fcvt_buf); -} diff --git a/reactos/lib/crt/stdlib/fcvtbuf.c b/reactos/lib/crt/stdlib/fcvtbuf.c deleted file mode 100644 index 312fc45abaa..00000000000 --- a/reactos/lib/crt/stdlib/fcvtbuf.c +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include -#include -#include -#include -#include -// #include - -// replace fjgpp fcvtbuf from project http://www.jbox.dk/sanos/source/lib/fcvt.c.html -// with small modification's to match ReactOS arch - -// Floating point to string conversion routines -// -// Copyright (C) 2002 Michael Ringgaard. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. Neither the name of the project nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// - - -//#include -#define CVTBUFSIZE 2 * DBL_MAX_10_EXP + 10 -static char *cvt(double arg, int ndigits, int *decpt, int *sign, char *buf, int eflag) -{ - int r2; - double fi, fj; - char *p, *p1; - - if (ndigits < 0) ndigits = 0; - if (ndigits >= CVTBUFSIZE - 1) ndigits = CVTBUFSIZE - 2; - r2 = 0; - *sign = 0; - p = &buf[0]; - if (arg < 0) - { - *sign = 1; - arg = -arg; - } - arg = modf(arg, &fi); - p1 = &buf[CVTBUFSIZE]; - - if (fi != 0) - { - p1 = &buf[CVTBUFSIZE]; - while (fi != 0) - { - fj = modf(fi / 10, &fi); - *--p1 = (int)((fj + .03) * 10) + '0'; - r2++; - } - while (p1 < &buf[CVTBUFSIZE]) *p++ = *p1++; - } - else if (arg > 0) - { - while ((fj = arg * 10) < 1) - { - arg = fj; - r2--; - } - } - p1 = &buf[ndigits]; - if (eflag == 0) p1 += r2; - *decpt = r2; - if (p1 < &buf[0]) - { - buf[0] = '\0'; - return buf; - } - while (p <= p1 && p < &buf[CVTBUFSIZE]) - { - arg *= 10; - arg = modf(arg, &fj); - *p++ = (int) fj + '0'; - } - if (p1 >= &buf[CVTBUFSIZE]) - { - buf[CVTBUFSIZE - 1] = '\0'; - return buf; - } - p = p1; - *p1 += 5; - while (*p1 > '9') - { - *p1 = '0'; - if (p1 > buf) - ++*--p1; - else - { - *p1 = '1'; - (*decpt)++; - if (eflag == 0) - { - if (p > buf) *p = '0'; - p++; - } - } - } - *p = '\0'; - return buf; -} - -char *fcvtbuf(double arg, int ndigits, int *decpt, int *sign, char *buf) -{ - return cvt(arg, ndigits, decpt, sign, buf, 0); -} diff --git a/reactos/lib/crt/stdlib/fullpath.c b/reactos/lib/crt/stdlib/fullpath.c deleted file mode 100644 index 740ae1d57e5..00000000000 --- a/reactos/lib/crt/stdlib/fullpath.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdlib/fullpath.c - * PURPOSE: Gets the fullpathname - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include -#include - -/* - * @implemented - */ -_TCHAR* _tfullpath(_TCHAR* absPath, const _TCHAR* relPath, size_t maxLength) -{ - _TCHAR* lpFilePart; - DWORD copied; - - if (!absPath) - { - maxLength = MAX_PATH; - absPath = malloc(maxLength); - } - - copied = GetFullPathName(relPath,maxLength,absPath,&lpFilePart); - if (copied == 0 || copied > maxLength) - return NULL; - - return absPath; -} diff --git a/reactos/lib/crt/stdlib/gcvt.c b/reactos/lib/crt/stdlib/gcvt.c deleted file mode 100644 index 644478fafbb..00000000000 --- a/reactos/lib/crt/stdlib/gcvt.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -char * -_gcvt (double value, int ndigits, char *buf) -{ - char *p = buf; - - sprintf (buf, "%-#.*g", ndigits, value); - - /* It seems they expect us to return .XXXX instead of 0.XXXX */ - if (*p == '-') - p++; - if (*p == '0' && p[1] == '.') - memmove (p, p + 1, strlen (p + 1) + 1); - - /* They want Xe-YY, not X.e-YY, and XXXX instead of XXXX. */ - p = strchr (buf, 'e'); - if (!p) - { - p = buf + strlen (buf); - /* They don't want trailing zeroes. */ - while (p[-1] == '0' && p > buf + 2) - *--p = '\0'; - } - if (p > buf && p[-1] == '.') - memmove (p - 1, p, strlen (p) + 1); - return buf; -} diff --git a/reactos/lib/crt/stdlib/getenv.c b/reactos/lib/crt/stdlib/getenv.c deleted file mode 100644 index 52886125f2f..00000000000 --- a/reactos/lib/crt/stdlib/getenv.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -#define NDEBUG -#include - -#undef environ - -/* - * @implemented - */ -char *getenv(const char *name) -{ - char **environ; - unsigned int length = strlen(name); - - for (environ = *__p__environ(); *environ; environ++) - { - char *str = *environ; - char *pos = strchr(str,'='); - if (pos && ((unsigned int)(pos - str) == length) && !_strnicmp(str, name, length)) - return pos + 1; - } - return NULL; -} - -/* - * @implemented - */ -wchar_t *_wgetenv(const wchar_t *name) -{ - wchar_t **environ; - unsigned int length = wcslen(name); - - for (environ = *__p__wenviron(); *environ; environ++) - { - wchar_t *str = *environ; - wchar_t *pos = wcschr(str, L'='); - if (pos && ((unsigned int)(pos - str) == length) && !_wcsnicmp(str, name, length)) - return pos + 1; - } - return NULL; -} diff --git a/reactos/lib/crt/stdlib/itoa.c b/reactos/lib/crt/stdlib/itoa.c deleted file mode 100644 index 3f93f5efe60..00000000000 --- a/reactos/lib/crt/stdlib/itoa.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdlib/itoa.c - * PURPOSE: converts a integer to ascii - * PROGRAMER: - * UPDATE HISTORY: - * 1995: Created - * 1998: Added ltoa by Ariadne - */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -/* - * @implemented - */ -char* _itoa(int value, char* string, int radix) -{ - char tmp[33]; - char* tp = tmp; - int i; - unsigned v; - int sign; - char* sp; - - if (radix > 36 || radix <= 1) - { - __set_errno(EDOM); - return 0; - } - - sign = (radix == 10 && value < 0); - if (sign) - v = -value; - else - v = (unsigned)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } - - if (string == 0) - string = (char*)malloc((tp-tmp)+sign+1); - sp = string; - - if (sign) - *sp++ = '-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; -} - -/* - * @implemented - */ -char* _ltoa(long value, char* string, int radix) -{ - char tmp[33]; - char* tp = tmp; - long i; - unsigned long v; - int sign; - char* sp; - - if (radix > 36 || radix <= 1) - { - __set_errno(EDOM); - return 0; - } - - sign = (radix == 10 && value < 0); - if (sign) - v = -value; - else - v = (unsigned long)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } - - if (string == 0) - string = (char*)malloc((tp-tmp)+sign+1); - sp = string; - - if (sign) - *sp++ = '-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; -} - -/* - * @implemented - * copy it from wine 0.9.0 with small modifcations do check for NULL - */ -char* ultoa(unsigned long value, char* string, int radix) -{ - char buffer[33]; - char *pos; - int digit; - - pos = &buffer[32]; - *pos = '\0'; - - if (string == NULL) - { - return NULL; - } - - do { - digit = value % radix; - value = value / radix; - if (digit < 10) { - *--pos = '0' + digit; - } else { - *--pos = 'a' + digit - 10; - } /* if */ - } while (value != 0L); - - memcpy(string, pos, &buffer[32] - pos + 1); - return string; -} diff --git a/reactos/lib/crt/stdlib/itow.c b/reactos/lib/crt/stdlib/itow.c deleted file mode 100644 index 7db9da3e85a..00000000000 --- a/reactos/lib/crt/stdlib/itow.c +++ /dev/null @@ -1,96 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdlib/itow.c - * PURPOSE: converts a integer to wchar_t - * PROGRAMER: - * UPDATE HISTORY: - * 1995: Created - * 1998: Added ltoa by Ariadne - * 2000: derived from ./itoa.c by ea - */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -/* - * @implemented - * from wine cvs 2006-05-21 - */ -wchar_t* _itow(int value, wchar_t* string, int radix) -{ - return _ltow(value, string, radix); -} - -/* - * @implemented - * from wine cvs 2006-05-21 - */ -wchar_t* _ltow(long value, wchar_t* string, int radix) -{ - unsigned long val; - int negative; - WCHAR buffer[33]; - PWCHAR pos; - WCHAR digit; - - if (value < 0 && radix == 10) { - negative = 1; - val = -value; - } else { - negative = 0; - val = value; - } /* if */ - - pos = &buffer[32]; - *pos = '\0'; - - do { - digit = val % radix; - val = val / radix; - if (digit < 10) { - *--pos = '0' + digit; - } else { - *--pos = 'a' + digit - 10; - } /* if */ - } while (val != 0L); - - if (negative) { - *--pos = '-'; - } /* if */ - - if (str != NULL) { - memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR)); - } /* if */ - return string; -} - -/* - * @implemented - * from wine cvs 2006-05-21 - */ -wchar_t* _ultow(unsigned long value, wchar_t* string, int radix) -{ - WCHAR buffer[33]; - PWCHAR pos; - WCHAR digit; - - pos = &buffer[32]; - *pos = '\0'; - - do { - digit = value % radix; - value = value / radix; - if (digit < 10) { - *--pos = '0' + digit; - } else { - *--pos = 'a' + digit - 10; - } /* if */ - } while (value != 0L); - - if (string != NULL) { - memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR)); - } /* if */ - return string; -} diff --git a/reactos/lib/crt/stdlib/labs.c b/reactos/lib/crt/stdlib/labs.c deleted file mode 100644 index 680f3ee0335..00000000000 --- a/reactos/lib/crt/stdlib/labs.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -long -labs(long j) -{ - return j<0 ? -j : j; -} diff --git a/reactos/lib/crt/stdlib/ldiv.c b/reactos/lib/crt/stdlib/ldiv.c deleted file mode 100644 index d6afed53be4..00000000000 --- a/reactos/lib/crt/stdlib/ldiv.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -ldiv_t -ldiv(long num, long denom) -{ - ldiv_t r; - - if (num > 0 && denom < 0) - { - num = -num; - denom = -denom; - } - r.quot = num / denom; - r.rem = num % denom; - if (num < 0 && denom > 0) - { - if (r.rem > 0) - { - r.quot++; - r.rem -= denom; - } - } - return r; -} diff --git a/reactos/lib/crt/stdlib/makepath.c b/reactos/lib/crt/stdlib/makepath.c deleted file mode 100644 index 9462c81c0a2..00000000000 --- a/reactos/lib/crt/stdlib/makepath.c +++ /dev/null @@ -1,37 +0,0 @@ -/* $Id$ - */ -#include -#include -#include - -/* - * @implemented - */ -void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext) -{ - int dir_len; - - if ((drive != NULL) && (*drive)) { - path[0] = *drive; - path[1] = ':'; - path[2] = 0; - } else { - (*path)=0; - } - - if (dir != NULL) { - strcat(path, dir); - dir_len = strlen(dir); - if (dir_len && *(dir + dir_len - 1) != '\\') - strcat(path, "\\"); - } - - if (fname != NULL) { - strcat(path, fname); - if (ext != NULL && *ext != 0) { - if (*ext != '.') - strcat(path, "."); - strcat(path, ext); - } - } -} diff --git a/reactos/lib/crt/stdlib/malloc.c b/reactos/lib/crt/stdlib/malloc.c deleted file mode 100644 index 4273c5a53c8..00000000000 --- a/reactos/lib/crt/stdlib/malloc.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * msvcrt.dll heap functions - * - * Copyright 2000 Jon Griffiths - * - * 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 - * - * Note: Win32 heap operations are MT safe. We only lock the new - * handler and non atomic heap operations - */ - -#include -#include -#include - - -/* round to 16 bytes + alloc at minimum 16 bytes */ -#define ROUND_SIZE(size) (max(16, ROUND_UP(size, 16))) - -extern HANDLE hHeap; - -/* - * @implemented - */ -void* malloc(size_t _size) -{ - size_t nSize = ROUND_SIZE(_size); - - if (nSize<_size) - return NULL; - - return HeapAlloc(hHeap, 0, nSize); -} - -/* - * @implemented - */ -void free(void* _ptr) -{ - HeapFree(hHeap,0,_ptr); -} - -/* - * @implemented - */ -void* calloc(size_t _nmemb, size_t _size) -{ - size_t nSize = _nmemb * _size; - size_t cSize = ROUND_SIZE(nSize); - - if ( (_nmemb > ((size_t)-1 / _size)) || (cSize - -#if 1 -/* - * @unimplemented - */ -size_t mbstowcs(wchar_t* wcstr, const char* mbstr, size_t count) -{ - size_t size; - int i; - - printf("\nmbstowcs(%p, %p, %d) called.\n\n", wcstr, mbstr, count); - - if (count <= 0 || !mbstr) - return 0; - - if (!*mbstr) - return 0; - - - if (wcstr == NULL) { - // return required size for the converted string - return strlen(mbstr); // TODO: fixme - } - for (size = 0, i = 0; i < count; size++) { - int result; - -////int mbtowc( wchar_t *wchar, const char *mbchar, size_t count ) -//// result = mbtowc(wcstr + size, mbstr + i, count - i); -// result = mbtowc(wcstr + size, mbstr + i, 1); - -///////////////////////////////////////// - if (mbstr[i] == 0) { - result = 0; - } else { - wcstr[size] = mbstr[i]; - result = 1; - } -///////////////////////////////////////// - if (result == -1) { - return -1; - } else if (result == 0) { - wcstr[size] = L'\0'; - break; - } else { - i += result; - } - - } - return size; -} - -#else -#if 1 - -//int mbtowc(wchar_t *dst, const char *str, size_t n) -size_t mbstowcs(wchar_t* wcstr, const char* mbstr, size_t count) -{ - size_t len; - - if (count <= 0 || !mbstr) - return 0; - len = MultiByteToWideChar(CP_ACP, 0, mbstr, count, wcstr, (wcstr == NULL) ? 0 : count); - - if (!len) { - DWORD err = GetLastError(); - switch (err) { - case ERROR_INSUFFICIENT_BUFFER: - break; - case ERROR_INVALID_FLAGS: - break; - case ERROR_INVALID_PARAMETER: - break; - case ERROR_NO_UNICODE_TRANSLATION: - break; - default: - return 1; - } - return -1; - } - /* return the number of bytes from src that have been used */ - if (!*mbstr) - return 0; -// if (count >= 2 && isleadbyte(*mbstr) && mbstr[1]) -// return 2; - return len; -} - -#else - -size_t mbstowcs(wchar_t* wcstr, const char* mbstr, size_t count) -{ - size_t size; - int i; - - if (wcstr == NULL) { - // return required size for the converted string - return strlen(mbstr); // TODO: fixme - } - for (size = 0, i = 0; i < count; size++) { - int result; - -//int mbtowc( wchar_t *wchar, const char *mbchar, size_t count ) -// result = mbtowc(wcstr + size, mbstr + i, count - i); - result = mbtowc(wcstr + size, mbstr + i, 1); - if (result == -1) { - return -1; - } else if (result == 0) { - wcstr[size] = L'\0'; - break; - } else { - i += result; - } - - } - return (size_t)size; -} - -#endif -#endif diff --git a/reactos/lib/crt/stdlib/mbtowc.c b/reactos/lib/crt/stdlib/mbtowc.c deleted file mode 100644 index 83cc5c62239..00000000000 --- a/reactos/lib/crt/stdlib/mbtowc.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -#if 1 - -/* - * @implemented - */ -int mbtowc(wchar_t *dst, const char *str, size_t n) -{ -// printf("\t\t\tmbtowc(%p, %p, %d) called.\n", dst, str, n); - - if (n <= 0 || !str) - return 0; - - *dst = *str; - - if (!*str) - return 0; - return 1; -} - -#else - -int mbtowc(wchar_t *dst, const char *str, size_t n) -{ - if (n <= 0 || !str) - return 0; - if (!MultiByteToWideChar(CP_ACP, 0, str, n, dst, (dst == NULL) ? 0 : 1)) { - DWORD err = GetLastError(); - switch (err) { - case ERROR_INSUFFICIENT_BUFFER: - break; - case ERROR_INVALID_FLAGS: - break; - case ERROR_INVALID_PARAMETER: - break; - case ERROR_NO_UNICODE_TRANSLATION: - break; - default: - return 1; - } - return -1; - } - /* return the number of bytes from src that have been used */ - if (!*str) - return 0; - if (n >= 2 && isleadbyte(*str) && str[1]) - return 2; - return 1; -} - -#endif diff --git a/reactos/lib/crt/stdlib/obsol.c b/reactos/lib/crt/stdlib/obsol.c deleted file mode 100644 index dab036a198b..00000000000 --- a/reactos/lib/crt/stdlib/obsol.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -#undef _cpumode -unsigned char _cpumode = 0; -unsigned char *_cpumode_dll = &_cpumode; - -/* - * @implemented - */ -void _seterrormode(int nMode) -{ - SetErrorMode(nMode); - return; -} - -/* - * @implemented - */ -void _beep(unsigned nFreq, unsigned nDur) -{ - Beep(nFreq,nDur); - return; -} - -/* - * @implemented - */ -void _sleep(unsigned long ulTime) -{ - Sleep(ulTime); - return; -} diff --git a/reactos/lib/crt/stdlib/putenv.c b/reactos/lib/crt/stdlib/putenv.c deleted file mode 100644 index f131605786f..00000000000 --- a/reactos/lib/crt/stdlib/putenv.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ -#include - -#define NDEBUG -#include - -/* misc/environ.c */ -int SetEnv(const wchar_t *option); - -/* - * @implemented - */ -int _putenv(const char* val) -{ - int size, result; - wchar_t *woption; - - size = MultiByteToWideChar(CP_ACP, 0, val, -1, NULL, 0); - woption = malloc(size* sizeof(wchar_t)); - if (woption == NULL) - return -1; - MultiByteToWideChar(CP_ACP, 0, val, -1, woption, size); - result = SetEnv(woption); - free(woption); - return result; -} diff --git a/reactos/lib/crt/stdlib/qsort.c b/reactos/lib/crt/stdlib/qsort.c deleted file mode 100644 index e6c4f449a4c..00000000000 --- a/reactos/lib/crt/stdlib/qsort.c +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include - -/*- - * Copyright (c) 1980, 1983 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* - * qsort.c: - * Our own version of the system qsort routine which is faster by an average - * of 25%, with lows and highs of 10% and 50%. - * The THRESHold below is the insertion sort threshold, and has been adjusted - * for records of size 48 bytes. - * The MTHREShold is where we stop finding a better median. - */ - -#define THRESH 4 /* threshold for insertion */ -#define MTHRESH 6 /* threshold for median */ - -/* - * qst: - * Do a quicksort - * First, find the median element, and put that one in the first place as the - * discriminator. (This "median" is just the median of the first, last and - * middle elements). (Using this median instead of the first element is a big - * win). Then, the usual partitioning/swapping, followed by moving the - * discriminator into the right place. Then, figure out the sizes of the two - * partions, do the smaller one recursively and the larger one via a repeat of - * this code. Stopping when there are less than THRESH elements in a partition - * and cleaning up with an insertion sort (in our caller) is a huge win. - * All data swaps are done in-line, which is space-losing but time-saving. - * (And there are only three places where this is done). - */ - -static void -qst(PTHREADDATA pThreadData, char *base, char *max) -{ - char c, *i, *j, *jj; - int ii; - char *mid, *tmp; - int lo, hi; - - /* - * At the top here, lo is the number of characters of elements in the - * current partition. (Which should be max - base). - * Find the median of the first, last, and middle element and make - * that the middle element. Set j to largest of first and middle. - * If max is larger than that guy, then it's that guy, else compare - * max with loser of first and take larger. Things are set up to - * prefer the middle, then the first in case of ties. - */ - lo = max - base; /* number of elements as chars */ - do { - mid = i = base + pThreadData->qsz * ((lo / pThreadData->qsz) >> 1); - if (lo >= pThreadData->mthresh) - { - j = (pThreadData->qcmp((jj = base), i) > 0 ? jj : i); - if (pThreadData->qcmp(j, (tmp = max - pThreadData->qsz)) > 0) - { - /* switch to first loser */ - j = (j == jj ? i : jj); - if (pThreadData->qcmp(j, tmp) < 0) - j = tmp; - } - if (j != i) - { - ii = pThreadData->qsz; - do { - c = *i; - *i++ = *j; - *j++ = c; - } while (--ii); - } - } - /* - * Semi-standard quicksort partitioning/swapping - */ - for (i = base, j = max - pThreadData->qsz; ; ) - { - while (i < mid && pThreadData->qcmp(i, mid) <= 0) - i += pThreadData->qsz; - while (j > mid) - { - if (pThreadData->qcmp(mid, j) <= 0) - { - j -= pThreadData->qsz; - continue; - } - tmp = i + pThreadData->qsz; /* value of i after swap */ - if (i == mid) - { - /* j <-> mid, new mid is j */ - mid = jj = j; - } - else - { - /* i <-> j */ - jj = j; - j -= pThreadData->qsz; - } - goto swap; - } - if (i == mid) - { - break; - } - else - { - /* i <-> mid, new mid is i */ - jj = mid; - tmp = mid = i; /* value of i after swap */ - j -= pThreadData->qsz; - } - swap: - ii = pThreadData->qsz; - do { - c = *i; - *i++ = *jj; - *jj++ = c; - } while (--ii); - i = tmp; - } - /* - * Look at sizes of the two partitions, do the smaller - * one first by recursion, then do the larger one by - * making sure lo is its size, base and max are update - * correctly, and branching back. But only repeat - * (recursively or by branching) if the partition is - * of at least size THRESH. - */ - i = (j = mid) + pThreadData->qsz; - if ((lo = j - base) <= (hi = max - i)) - { - if (lo >= pThreadData->thresh) - qst(pThreadData, base, j); - base = i; - lo = hi; - } - else - { - if (hi >= pThreadData->thresh) - qst(pThreadData, i, max); - max = j; - } - } while (lo >= pThreadData->thresh); -} - -/* - * qsort: - * First, set up some global parameters for qst to share. Then, quicksort - * with qst(), and then a cleanup insertion sort ourselves. Sound simple? - * It's not... - * - * @implemented - */ -void -qsort(void *base0, size_t n, size_t size, int (*compar)(const void*, const void*)) -{ - PTHREADDATA pThreadData; - char *base = (char *)base0; - char c, *i, *j, *lo, *hi; - char *min, *max; - - if (n <= 1) - return; - - pThreadData = GetThreadData(); - - pThreadData->qsz = size; - pThreadData->qcmp = compar; - pThreadData->thresh = pThreadData->qsz * THRESH; - pThreadData->mthresh = pThreadData->qsz * MTHRESH; - max = base + n * pThreadData->qsz; - if (n >= THRESH) - { - qst(pThreadData, base, max); - hi = base + pThreadData->thresh; - } - else - { - hi = max; - } - /* - * First put smallest element, which must be in the first THRESH, in - * the first position as a sentinel. This is done just by searching - * the first THRESH elements (or the first n if n < THRESH), finding - * the min, and swapping it into the first position. - */ - for (j = lo = base; (lo += pThreadData->qsz) < hi; ) - if (pThreadData->qcmp(j, lo) > 0) - j = lo; - if (j != base) - { - /* swap j into place */ - for (i = base, hi = base + pThreadData->qsz; i < hi; ) - { - c = *j; - *j++ = *i; - *i++ = c; - } - } - /* - * With our sentinel in place, we now run the following hyper-fast - * insertion sort. For each remaining element, min, from [1] to [n-1], - * set hi to the index of the element AFTER which this one goes. - * Then, do the standard insertion sort shift on a character at a time - * basis for each element in the frob. - */ - for (min = base; (hi = min += pThreadData->qsz) < max; ) - { - while (pThreadData->qcmp(hi -= pThreadData->qsz, min) > 0) - /* void */; - if ((hi += pThreadData->qsz) != min) { - for (lo = min + pThreadData->qsz; --lo >= min; ) - { - c = *lo; - for (i = j = lo; (j -= pThreadData->qsz) >= hi; i = j) - *i = *j; - *i = c; - } - } - } -} diff --git a/reactos/lib/crt/stdlib/rand.c b/reactos/lib/crt/stdlib/rand.c deleted file mode 100644 index f788ecf72ab..00000000000 --- a/reactos/lib/crt/stdlib/rand.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#include - -/* - * @implemented - */ -int -rand(void) -{ - PTHREADDATA ThreadData = GetThreadData(); - - ThreadData->tnext = ThreadData->tnext * 0x5deece66dLL + 2531011; - return (int)((ThreadData->tnext >> 16) & RAND_MAX); -} - -/* - * @implemented - */ -void -srand(unsigned int seed) -{ - PTHREADDATA ThreadData = GetThreadData(); - - ThreadData->tnext = (ULONGLONG)seed; -} diff --git a/reactos/lib/crt/stdlib/rot.c b/reactos/lib/crt/stdlib/rot.c deleted file mode 100644 index c1fbc73260c..00000000000 --- a/reactos/lib/crt/stdlib/rot.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdlib/rot.c - * PURPOSE: Performs a bitwise rotation - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 03/04/99: Created - */ - -#include - -/* - * @implemented - */ -unsigned int _rotl( unsigned int value, int shift ) -{ - int max_bits = sizeof(unsigned int)<<3; - if ( shift < 0 ) - return _rotr(value,-shift); - - if ( shift > max_bits ) - shift = shift % max_bits; - return (value << shift) | (value >> (max_bits-shift)); -} - -/* - * @implemented - */ -unsigned int _rotr( unsigned int value, int shift ) -{ - int max_bits = sizeof(unsigned int)<<3; - if ( shift < 0 ) - return _rotl(value,-shift); - - if ( shift > max_bits<<3 ) - shift = shift % max_bits; - return (value >> shift) | (value << (max_bits-shift)); -} - - -/* - * @implemented - */ -unsigned long _lrotl( unsigned long value, int shift ) -{ - int max_bits = sizeof(unsigned long)<<3; - if ( shift < 0 ) - return _lrotr(value,-shift); - - if ( shift > max_bits ) - shift = shift % max_bits; - return (value << shift) | (value >> (max_bits-shift)); -} - -/* - * @implemented - */ -unsigned long _lrotr( unsigned long value, int shift ) -{ - int max_bits = sizeof(unsigned long)<<3; - if ( shift < 0 ) - return _lrotl(value,-shift); - - if ( shift > max_bits ) - shift = shift % max_bits; - return (value >> shift) | (value << (max_bits-shift)); -} diff --git a/reactos/lib/crt/stdlib/senv.c b/reactos/lib/crt/stdlib/senv.c deleted file mode 100644 index c3379d39fb2..00000000000 --- a/reactos/lib/crt/stdlib/senv.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include -#include -#include -#include - -#define NDEBUG -#include - - -/* - * @implemented - */ -void _tsearchenv(const _TCHAR* file,const _TCHAR* var,_TCHAR* path) -{ - _TCHAR* env = _tgetenv(var); - _TCHAR* x; - _TCHAR* y; - _TCHAR* FilePart; - - DPRINT(MK_STR(_tsearchenv)"()\n"); - - x = _tcschr(env,'='); - if ( x != NULL ) { - *x = 0; - x++; - } - y = _tcschr(env,';'); - while ( y != NULL ) { - *y = 0; - if ( SearchPath(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) { - return; - } - x = y+1; - y = _tcschr(env,';'); - } - return; -} diff --git a/reactos/lib/crt/stdlib/splitp.c b/reactos/lib/crt/stdlib/splitp.c deleted file mode 100644 index 29c4e369cc6..00000000000 --- a/reactos/lib/crt/stdlib/splitp.c +++ /dev/null @@ -1,68 +0,0 @@ -#include - -/* - * @implemented - */ -void _tsplitpath(const _TCHAR* path, _TCHAR* drive, _TCHAR* dir, _TCHAR* fname, _TCHAR* ext) -{ - _TCHAR* tmp_drive = NULL; - _TCHAR* tmp_dir = NULL; - _TCHAR* tmp_ext = NULL; - - tmp_drive = (_TCHAR*)_tcschr(path,':'); - if (drive) - { - if (tmp_drive) - { - _tcsncpy(drive,tmp_drive-1,2); - *(drive+2) = 0; - } - else - { - *drive = 0; - } - } - if (!tmp_drive) - { - tmp_drive = (_TCHAR*)path - 1; - } - - tmp_dir = (_TCHAR*)_tcsrchr(path,'\\'); - if (dir) - { - if (tmp_dir) - { - _tcsncpy(dir,tmp_drive+1,tmp_dir-tmp_drive); - *(dir+(tmp_dir-tmp_drive)) = 0; - } - else - { - *dir =0; - } - } - - /* If the dot is before the last dir separator, it's part - * of a directory name, not the start of the extension */ - if (!tmp_ext || tmp_ext < tmp_dir) - { - tmp_ext = (_TCHAR*)path+_tcslen(path); - } - if (ext) - { - _tcscpy(ext,tmp_ext); - } - - if (fname) - { - if (tmp_dir) - { - _tcsncpy(fname,tmp_dir+1,tmp_ext-tmp_dir-1); - *(fname+(tmp_ext-tmp_dir-1)) = 0; - } - else - { - _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 deleted file mode 100644 index 3d40f56fcd3..00000000000 --- a/reactos/lib/crt/stdlib/strtod.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include - -/* - * @implemented - */ -double -strtod(const char *s, char **sret) -{ - long double r; /* result */ - int e; /* exponent */ - long double d; /* scale */ - int sign; /* +- 1.0 */ - int esign; - int i; - int flags=0; - - r = 0.0; - sign = 1; - e = 0; - esign = 1; - - if (s == NULL) - return r; - - - while ((*s == ' ') || (*s == '\t')) - s++; - - if (*s == '+') - s++; - else if (*s == '-') - { - sign = -1; - s++; - } - - while ((*s >= '0') && (*s <= '9')) - { - flags |= 1; - r *= 10.0; - r += *s - '0'; - s++; - } - - if (*s == '.') - { - d = 0.1L; - s++; - while ((*s >= '0') && (*s <= '9')) - { - flags |= 2; - r += d * (*s - '0'); - s++; - d *= 0.1L; - } - } - - if (flags == 0) - { - if (sret) - *sret = (char *)s; - return 0; - } - - if ((*s == 'e') || (*s == 'E')) - { - s++; - if (*s == '+') - s++; - else if (*s == '-') - { - s++; - esign = -1; - } - if ((*s < '0') || (*s > '9')) - { - if (sret) - *sret = (char *)s; - return r; - } - - while ((*s >= '0') && (*s <= '9')) - { - e *= 10; - e += *s - '0'; - s++; - } - } - - if (esign < 0) - for (i = 1; i <= e; i++) - r *= 0.1L; - else - for (i = 1; i <= e; i++) - r *= 10.0; - - if (sret) - *sret = (char *)s; - return r * sign; -} diff --git a/reactos/lib/crt/stdlib/strtol.c b/reactos/lib/crt/stdlib/strtol.c deleted file mode 100644 index 982acdebf1b..00000000000 --- a/reactos/lib/crt/stdlib/strtol.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -long -strtol(const char *nptr, char **endptr, int base) -{ - const char *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - 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; - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for longs is - * [-2147483648..2147483647] and the input base is 10, - * cutoff will be set to 214748364 and cutlim to either - * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated - * a value > 214748364, or equal but the next digit is > 7 (or 8), - * the number is too big, and we will return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; - cutlim = cutoff % (unsigned long)base; - cutoff /= (unsigned long)base; - 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 ? LONG_MIN : LONG_MAX; - __set_errno(ERANGE); - } - else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (char *)s - 1 : (char *)nptr; - return acc; -} diff --git a/reactos/lib/crt/stdlib/strtold.c b/reactos/lib/crt/stdlib/strtold.c deleted file mode 100644 index 062dcfbbc3b..00000000000 --- a/reactos/lib/crt/stdlib/strtold.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -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(const char *s, char **sret) -{ - 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; -} diff --git a/reactos/lib/crt/stdlib/strtoul.c b/reactos/lib/crt/stdlib/strtoul.c deleted file mode 100644 index 2e530f53b6d..00000000000 --- a/reactos/lib/crt/stdlib/strtoul.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -/* - * Convert a string to an unsigned long integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - * - * @implemented - */ -unsigned long -strtoul(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; - cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; - cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; - 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 = ULONG_MAX; - __set_errno(ERANGE); - } - else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (char *)s - 1 : (char *)nptr; - return acc; -} diff --git a/reactos/lib/crt/stdlib/strtoull.c b/reactos/lib/crt/stdlib/strtoull.c deleted file mode 100644 index d02328af92a..00000000000 --- a/reactos/lib/crt/stdlib/strtoull.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#if defined (_MSC_VER) -#define UINT64_MAX 0xffffffffffffffff -#endif - -/* - * Convert a string to an unsigned long integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ -UINT64 -strtoull(const char *nptr, char **endptr, int base) -{ - const char *s = nptr; - UINT64 acc; - int c; - UINT64 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; - cutoff = UINT64_MAX / base; - cutlim = (int)(UINT64_MAX % base); - 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 = UINT64_MAX; - __set_errno ( ERANGE ); - } - else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (char *)s - 1 : (char *)nptr; - return acc; -} diff --git a/reactos/lib/crt/stdlib/swab.c b/reactos/lib/crt/stdlib/swab.c deleted file mode 100644 index 85a06e8ebd5..00000000000 --- a/reactos/lib/crt/stdlib/swab.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - * - * copy this swab from wine cvs 2006-05-24 - */ -void _swab (const char * src, char * dst, size_t sizeToCopy - ) - -{ - if (sizeToCopy > 1) - { - sizeToCopy = (unsigned)sizeToCopy >> 1; - - while (sizeToCopy--) { - char s0 = src[0]; - char s1 = src[1]; - *dst++ = s1; - *dst++ = s0; - src = src + 2; - } - } -} diff --git a/reactos/lib/crt/stdlib/wcstod.c b/reactos/lib/crt/stdlib/wcstod.c deleted file mode 100644 index 89029c1a5c1..00000000000 --- a/reactos/lib/crt/stdlib/wcstod.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - - -/* - * @implemented - */ -double wcstod(const wchar_t *s, wchar_t **sret) -{ - long double r; /* result */ - int e; /* exponent */ - long double d; /* scale */ - int sign; /* +- 1.0 */ - int esign; - int i; - int flags=0; - - r = 0.0; - sign = 1; - e = 0; - esign = 1; - - while ((*s == L' ') || (*s == L'\t')) - s++; - - if (*s == L'+') - s++; - else if (*s == L'-') - { - sign = -1; - s++; - } - - while ((*s >= L'0') && (*s <= L'9')) - { - flags |= 1; - r *= 10.0; - r += *s - L'0'; - s++; - } - - if (*s == L'.') - { - d = 0.1L; - s++; - while ((*s >= L'0') && (*s <= L'9')) - { - flags |= 2; - r += d * (*s - L'0'); - s++; - d *= 0.1L; - } - } - - if (flags == 0) - { - if (sret) - *sret = (wchar_t *)s; - return 0; - } - - if ((*s == L'e') || (*s == L'E')) - { - s++; - if (*s == L'+') - s++; - else if (*s == L'-') - { - s++; - esign = -1; - } - if ((*s < L'0') || (*s > L'9')) - { - if (sret) - *sret = (wchar_t *)s; - return r; - } - - while ((*s >= L'0') && (*s <= L'9')) - { - e *= 10; - e += *s - L'0'; - s++; - } - } - - if (esign < 0) - for (i = 1; i <= e; i++) - r *= 0.1L; - else - for (i = 1; i <= e; i++) - r *= 10.0; - - if (sret) - *sret = (wchar_t *)s; - return r * sign; -} diff --git a/reactos/lib/crt/stdlib/wcstol.c b/reactos/lib/crt/stdlib/wcstol.c deleted file mode 100644 index be1a0616952..00000000000 --- a/reactos/lib/crt/stdlib/wcstol.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -long wcstol(const wchar_t *cp,wchar_t **endp,int base) -{ - long result = 0,value; - int sign = 1; - - if ( *cp == L'-' ) { - sign = -1; - cp++; - } - - if (!base) { - base = 10; - if (*cp == L'0') { - base = 8; - cp++; - if ((*cp == L'x') && iswxdigit(cp[1])) { - cp++; - base = 16; - } - } - } - while (iswxdigit(*cp) && (value = iswdigit(*cp) ? *cp-L'0' : (iswlower(*cp) - ? towupper(*cp) : *cp)-L'A'+10) < base) { - result = result*base + value; - cp++; - } - if (endp) - *endp = (wchar_t *)cp; - return result * sign; -} diff --git a/reactos/lib/crt/stdlib/wcstom.c b/reactos/lib/crt/stdlib/wcstom.c deleted file mode 100644 index 0c74f97c15e..00000000000 --- a/reactos/lib/crt/stdlib/wcstom.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -/* - * @unimplemented - */ -size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size) -{ - return 0; -} - -/* - * @unimplemented - */ -int wctomb (char* mbDest, wchar_t wc) -{ - return 0; -} - - - diff --git a/reactos/lib/crt/stdlib/wcstomb.c b/reactos/lib/crt/stdlib/wcstomb.c deleted file mode 100644 index b00299919e6..00000000000 --- a/reactos/lib/crt/stdlib/wcstomb.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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 - -#ifndef EILSEQ -#define EILSEQ EINVAL -#endif - -static const wchar_t encoding_mask[] = -{ - (wchar_t)~0x7ff, (wchar_t)~0xffff, (wchar_t)~0x1fffff, (wchar_t)~0x3ffffff -}; - -static const unsigned char encoding_byte[] = -{ - 0xc0, 0xe0, 0xf0, 0xf8, 0xfc -}; - -/* The state is for this UTF8 encoding not used. */ -//static mbstate_t internal; - - -//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ - -size_t -__wcrtomb (char *s, wchar_t wc); - -/* - * Convert WCHAR into its multibyte character representation, - * putting this in S and returning its length. - * - * Attention: this function should NEVER be intentionally used. - * The interface is completely stupid. The state is shared between - * all conversion functions. You should use instead the restartable - * version `wcrtomb'. - * - * @implemented - */ -int -wctomb (char *s, wchar_t wchar) -{ - /* If S is NULL the function has to return null or not null - depending on the encoding having a state depending encoding or - not. This is nonsense because any multibyte encoding has a - state. The ISO C amendment 1 corrects this while introducing the - restartable functions. We simply say here all encodings have a - state. */ - if (s == NULL) - return 1; - - return __wcrtomb (s, wchar); -} - - -size_t -__wcrtomb (char *s, wchar_t wc) -{ - char fake[1]; - size_t written = 0; - - - - if (s == NULL) - { - s = fake; - wc = L'\0'; - } - - if (wc < 0x80) - { - /* It's a one byte sequence. */ - if (s != NULL) - *s = (char) wc; - return 1; - } - - for (written = 2; written < 6; ++written) - if ((wc & encoding_mask[written - 2]) == 0) - break; - - if (s != NULL) - { - size_t cnt = written; - s[0] = encoding_byte[cnt - 2]; - - --cnt; - do - { - s[cnt] = 0x80 | (wc & 0x3f); - wc >>= 6; - } - while (--cnt > 0); - s[0] |= wc; - } - - return written; -} diff --git a/reactos/lib/crt/stdlib/wcstombs.c b/reactos/lib/crt/stdlib/wcstombs.c deleted file mode 100644 index 1a404e830d1..00000000000 --- a/reactos/lib/crt/stdlib/wcstombs.c +++ /dev/null @@ -1,157 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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 - -#ifndef EILSEQ -#define EILSEQ EINVAL -#endif - - -static const wchar_t encoding_mask[] = -{ - (~0x7ff&WCHAR_MAX), (~0xffff&WCHAR_MAX), (~0x1fffff&WCHAR_MAX), (~0x3ffffff&WCHAR_MAX) -}; - -static const unsigned char encoding_byte[] = -{ - 0xc0, 0xe0, 0xf0, 0xf8, 0xfc -}; - -/* We don't need the state really because we don't have shift states - to maintain between calls to this function. */ - -static mbstate_t mbstate_internal; - - -mbstate_t __no_r_state; /* Now defined in wcstombs.c. */ -//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ - -size_t -__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps); - -/* - * Convert the `wchar_t' string in PWCS to a multibyte character string - * in S, writing no more than N characters. Return the number of bytes - * written, or (size_t) -1 if an invalid `wchar_t' was found. - * - * Attention: this function should NEVER be intentionally used. - * The interface is completely stupid. The state is shared between - * all conversion functions. You should use instead the restartable - * version `wcsrtombs'. - * - * @implemented - */ -size_t -wcstombs (char *s, const wchar_t *pwcs, size_t n) -{ - mbstate_t save_shift = __no_r_state; - size_t written; - - written = __wcsrtombs (s, &pwcs, n, &__no_r_state); - - /* Restore the old shift state. */ - __no_r_state = save_shift; - - /* Return how many we wrote (or maybe an error). */ - return written; -} - -size_t -__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps) -{ - size_t written = 0; - const wchar_t *run = *src; - - if (ps == NULL) - ps = &mbstate_internal; - - if (dst == NULL) - /* The LEN parameter has to be ignored if we don't actually write - anything. */ - len = ~0; - - while (written < len) - { - wchar_t wc = *run++; - -#if 0 - if (wc < 0 || wc > WCHAR_MAX) - { - /* This is no correct ISO 10646 character. */ - __set_errno (EILSEQ); - return (size_t) -1; - } -#endif - - if (wc == L'\0') - { - /* Found the end. */ - if (dst != NULL) - *dst = '\0'; - *src = NULL; - return written; - } - else if (wc < 0x80) - { - /* It's an one byte sequence. */ - if (dst != NULL) - *dst++ = (char) wc; - ++written; - } - else - { - size_t step; - - for (step = 2; step < 6; ++step) - if ((wc & encoding_mask[step - 2]) == 0) - break; - - if (written + step >= len) - /* Too long. */ - break; - - if (dst != NULL) - { - size_t cnt = step; - - dst[0] = encoding_byte[cnt - 2]; - - --cnt; - do - { - dst[cnt] = 0x80 | (wc & 0x3f); - wc >>= 6; - } - while (--cnt > 0); - dst[0] |= wc; - - dst += step; - } - - written += step; - } - } - - /* Store position of first unprocessed word. */ - *src = run; - - return written; -} -//weak_alias (__wcsrtombs, wcsrtombs) diff --git a/reactos/lib/crt/stdlib/wcstoul.c b/reactos/lib/crt/stdlib/wcstoul.c deleted file mode 100644 index b017eb92d51..00000000000 --- a/reactos/lib/crt/stdlib/wcstoul.c +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * Convert a unicode string to an unsigned long integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - * - * @implemented - */ -unsigned long -wcstoul(const wchar_t *nptr, wchar_t **endptr, int base) -{ - const wchar_t *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 (iswspace(c)); - if (c == L'-') - { - neg = 1; - c = *s++; - } - else if (c == L'+') - c = *s++; - if ((base == 0 || base == 16) && - c == L'0' && (*s == L'x' || *s == L'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == L'0' ? 8 : 10; - cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; - cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) - { - if (iswdigit(c)) - c -= L'0'; - else if (iswalpha(c)) - c -= iswupper(c) ? L'A' - 10 : L'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 = ULONG_MAX; - __set_errno(ERANGE); - } - else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr; - return acc; -} - -#if 0 -unsigned long wcstoul(const wchar_t *cp,wchar_t **endp,int base) -{ - unsigned long result = 0,value; - - if (!base) { - base = 10; - if (*cp == L'0') { - base = 8; - cp++; - if ((*cp == L'x') && iswxdigit(cp[1])) { - cp++; - base = 16; - } - } - } - while (iswxdigit(*cp) && (value = iswdigit(*cp) ? *cp-L'0' : (iswlower(*cp) - ? towupper(*cp) : *cp)-L'A'+10) < base) { - result = result*base + value; - cp++; - } - if (endp) - *endp = (wchar_t *)cp; - return result; -} -#endif diff --git a/reactos/lib/crt/stdlib/wctomb.c b/reactos/lib/crt/stdlib/wctomb.c deleted file mode 100644 index ed17f498fbf..00000000000 --- a/reactos/lib/crt/stdlib/wctomb.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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 - -int -STDCALL -WideCharToMultiByte( - UINT CodePage, - DWORD dwFlags, - LPCWSTR lpWideCharStr, - int cchWideChar, - LPSTR lpMultiByteStr, - int cchMultiByte, - LPCSTR lpDefaultChar, - LPBOOL lpUsedDefaultChar); - - -/* - * @unimplemented - */ -int wctomb(char* dst, wchar_t ch) -{ -#if 0 - return WideCharToMultiByte(CP_ACP, 0, &ch, 1, dst, 6, NULL, NULL); -#else - if (dst == NULL) { - return 1; - } else if (0 != (ch & 0xff00)) { - return -1; - } - *dst = ch; - return 1; -#endif -} - - -#if 0 - -#ifndef EILSEQ -#define EILSEQ EINVAL -#endif - -static const wchar_t encoding_mask[] = -{ - /* This reflects the sources *nix origin where type wchar_t - was 32 bits wide. Since our type wchar_t is only 16 bits - wide all this module will need to be reviewed. - Simplest option may well be to forward this modules work - on to the kernel which already has support for this. - */ - ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff - //~0x0000-07ff, ~0x0000-ffff, ~0x001f-ffff, ~0x03ff-ffff -}; - -static const unsigned char encoding_byte[] = -{ - 0xc0, 0xe0, 0xf0, 0xf8, 0xfc -}; - -/* The state is for this UTF8 encoding not used. */ -//static mbstate_t internal; -//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ - -size_t __wcrtomb(char *s, wchar_t wc); - -/* Convert WCHAR into its multibyte character representation, - putting this in S and returning its length. - - Attention: this function should NEVER be intentionally used. - The interface is completely stupid. The state is shared between - all conversion functions. You should use instead the restartable - version `wcrtomb'. */ - -int wctomb(char *s, wchar_t wchar) -{ - /* If S is NULL the function has to return null or not null - depending on the encoding having a state depending encoding or - not. This is nonsense because any multibyte encoding has a - state. The ISO C amendment 1 corrects this while introducing the - restartable functions. We simply say here all encodings have a - state. */ - if (s == NULL) { - return 1; - } - return __wcrtomb(s, wchar); -} - -size_t __wcrtomb(char *s, wchar_t wc) -{ - char fake[1]; - size_t written = 0; - - if (s == NULL) { - s = fake; - wc = L'\0'; - } - /* Store the UTF8 representation of WC. */ - //if (wc < 0 || wc > 0x7fffffff) { - if (wc < 0 || wc > 0x7fff) { - /* This is no correct ISO 10646 character. */ - __set_errno (EILSEQ); - return (size_t) -1; - } - if (wc < 0x80) { - /* It's a one byte sequence. */ - if (s != NULL) { - *s = (char)wc; - } - return 1; - } - for (written = 2; written < 6; ++written) { - if ((wc & encoding_mask[written - 2]) == 0) { - break; - } - } - if (s != NULL) { - size_t cnt = written; - s[0] = encoding_byte[cnt - 2]; - --cnt; - do { - s[cnt] = 0x80 | (wc & 0x3f); - wc >>= 6; - } while (--cnt > 0); - s[0] |= wc; - } - return written; -} - -#endif diff --git a/reactos/lib/crt/stdlib/wfulpath.c b/reactos/lib/crt/stdlib/wfulpath.c deleted file mode 100644 index 43d6d788172..00000000000 --- a/reactos/lib/crt/stdlib/wfulpath.c +++ /dev/null @@ -1,5 +0,0 @@ - -#define _UNICODE -#define UNICODE - -#include "fullpath.c" diff --git a/reactos/lib/crt/stdlib/witoa.c b/reactos/lib/crt/stdlib/witoa.c deleted file mode 100644 index c1533a9388f..00000000000 --- a/reactos/lib/crt/stdlib/witoa.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdlib/itoa.c - * PURPOSE: converts a integer to ascii - * PROGRAMER: - * UPDATE HISTORY: - * 1995: Created - * 1998: Added ltoa by Ariadne - * 2006 : replace all api in this file to wine cvs 2006-05-21 - */ -/* */ -#include - -/* - * @implemented - * copy _i64toa from wine cvs 2006 month 05 day 21 - */ -char* _i64toa(__int64 value, char* string, int radix) -{ - ULONGLONG val; - int negative; - char buffer[65]; - char *pos; - int digit; - - if (value < 0 && radix == 10) { - negative = 1; - val = -value; - } else { - negative = 0; - val = value; - } /* if */ - - pos = &buffer[64]; - *pos = '\0'; - - do { - digit = val % radix; - val = val / radix; - if (digit < 10) { - *--pos = '0' + digit; - } else { - *--pos = 'a' + digit - 10; - } /* if */ - } while (val != 0L); - - if (negative) { - *--pos = '-'; - } /* if */ - - memcpy(string, pos, &buffer[64] - pos + 1); - return string; -} - - -/* - * @implemented - */ -char* _ui64toa(unsigned __int64 value, char* string, int radix) -{ - char buffer[65]; - char *pos; - int digit; - - pos = &buffer[64]; - *pos = '\0'; - - do { - digit = value % radix; - value = value / radix; - if (digit < 10) { - *--pos = '0' + digit; - } else { - *--pos = 'a' + digit - 10; - } /* if */ - } while (value != 0L); - - memcpy(string, pos, &buffer[64] - pos + 1); - return string; -} diff --git a/reactos/lib/crt/stdlib/witow.c b/reactos/lib/crt/stdlib/witow.c deleted file mode 100644 index b9b38483fa4..00000000000 --- a/reactos/lib/crt/stdlib/witow.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/stdlib/itow.c - * PURPOSE: converts a integer to wchar_t - * PROGRAMER: - * UPDATE HISTORY: - * 1995: Created - * 1998: Added ltoa by Ariadne - * 2000: derived from ./itoa.c by ea - */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include - -/* - * @implemented - */ -wchar_t* _i64tow(__int64 value, wchar_t* string, int radix) -{ - wchar_t tmp[65]; - wchar_t* tp = tmp; - int i; - unsigned v; - int sign; - wchar_t* sp; - - if (radix > 36 || radix <= 1) { - __set_errno(EDOM); - return 0; - } - - sign = (radix == 10 && value < 0); - if (sign) - v = -value; - else - v = (unsigned)value; - while (v || tp == tmp) { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+L'0'; - else - *tp++ = i + L'a' - 10; - } - - if (string == 0) - string = (wchar_t*)malloc(((tp-tmp)+sign+1)*sizeof(wchar_t)); - sp = string; - - if (sign) - *sp++ = L'-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; -} - -/* - * @implemented - */ -wchar_t* _ui64tow(unsigned __int64 value, wchar_t* string, int radix) -{ - wchar_t tmp[65]; - wchar_t* tp = tmp; - long i; - unsigned long v = value; - wchar_t* sp; - - if (radix > 36 || radix <= 1) { - __set_errno(EDOM); - return 0; - } - - while (v || tp == tmp) { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+L'0'; - else - *tp++ = i + L'a' - 10; - } - - if (string == 0) - string = (wchar_t*)malloc(((tp-tmp)+1)*sizeof(wchar_t)); - sp = string; - - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; -} diff --git a/reactos/lib/crt/stdlib/wmakpath.c b/reactos/lib/crt/stdlib/wmakpath.c deleted file mode 100644 index 8222a860d6d..00000000000 --- a/reactos/lib/crt/stdlib/wmakpath.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: gdalsnes - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -/* $Id$ - */ -#include - -/* - * @implemented - */ -void _wmakepath(wchar_t* path, const wchar_t* drive, const wchar_t* dir, const wchar_t* fname, const wchar_t* ext) -{ - int dir_len; - - if ((drive != NULL) && (*drive)) { - path[0] = *drive; - path[1] = L':'; - path[2] = 0; - } else { - (*path) = 0; - } - - if (dir != NULL) { - wcscat(path, dir); - dir_len = wcslen(dir); - if (dir_len && *(dir + dir_len - 1) != L'\\') - wcscat(path, L"\\"); - } - - if (fname != NULL) { - wcscat(path, fname); - if (ext != NULL && *ext != 0) { - if (*ext != L'.') - wcscat(path, L"."); - wcscat(path, ext); - } - } -} diff --git a/reactos/lib/crt/stdlib/wputenv.c b/reactos/lib/crt/stdlib/wputenv.c deleted file mode 100644 index a811b99454c..00000000000 --- a/reactos/lib/crt/stdlib/wputenv.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#define NDEBUG -#include - -/* misc/environ.c */ -int SetEnv(const wchar_t *option); - -/* - * @implemented - */ -int _wputenv(const wchar_t* val) -{ - return SetEnv(val); -} diff --git a/reactos/lib/crt/stdlib/wsenv.c b/reactos/lib/crt/stdlib/wsenv.c deleted file mode 100644 index 4e23231f854..00000000000 --- a/reactos/lib/crt/stdlib/wsenv.c +++ /dev/null @@ -1,5 +0,0 @@ - -#define _UNICODE -#define UNICODE - -#include "senv.c" diff --git a/reactos/lib/crt/stdlib/wsplitp.c b/reactos/lib/crt/stdlib/wsplitp.c deleted file mode 100644 index 4655be577bd..00000000000 --- a/reactos/lib/crt/stdlib/wsplitp.c +++ /dev/null @@ -1,7 +0,0 @@ - -#define _UNICODE -#define UNICODE - -#include - -#include "splitp.c" diff --git a/reactos/lib/crt/stdlib/wtoi.c b/reactos/lib/crt/stdlib/wtoi.c deleted file mode 100644 index 1a171024087..00000000000 --- a/reactos/lib/crt/stdlib/wtoi.c +++ /dev/null @@ -1,6 +0,0 @@ - -#define _UNICODE -#define UNICODE - -#include "atoi.c" - diff --git a/reactos/lib/crt/stdlib/wtoi64.c b/reactos/lib/crt/stdlib/wtoi64.c deleted file mode 100644 index f842292759d..00000000000 --- a/reactos/lib/crt/stdlib/wtoi64.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -__int64 _wtoi64(const wchar_t* nptr) -{ - wchar_t* s = (wchar_t*)nptr; - __int64 acc = 0; - int neg = 0; - - while (iswspace((int)*s)) - s++; - if (*s == '-') { - neg = 1; - s++; - } - else if (*s == '+') - s++; - - while (iswdigit((int)*s)) { - acc = 10 * acc + ((int)*s - '0'); - s++; - } - - if (neg) - acc *= -1; - return acc; -} diff --git a/reactos/lib/crt/stdlib/wtol.c b/reactos/lib/crt/stdlib/wtol.c deleted file mode 100644 index 1d56c7d7076..00000000000 --- a/reactos/lib/crt/stdlib/wtol.c +++ /dev/null @@ -1,6 +0,0 @@ - -#define _UNICODE -#define UNICODE - -#include "atol.c" - diff --git a/reactos/lib/crt/string/lasttok.c b/reactos/lib/crt/string/lasttok.c deleted file mode 100644 index a5836bc1b39..00000000000 --- a/reactos/lib/crt/string/lasttok.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ -#include - -#include -#include - -/* - * This is an MSVCRT internal function to return the lasttoken - * bit of data used by strtok. The reason for it's existence is - * so that CRTDLL can use the strtok source code in the same - * file. - */ -char** _lasttoken() -{ - PTHREADDATA ptd = GetThreadData(); - assert(ptd); - return &(ptd->lasttoken); -} diff --git a/reactos/lib/crt/string/memicmp.c b/reactos/lib/crt/string/memicmp.c deleted file mode 100644 index 100a162c579..00000000000 --- a/reactos/lib/crt/string/memicmp.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -int -_memicmp(const void *s1, const void *s2, size_t n) -{ - if (n != 0) - { - const unsigned char *p1 = s1, *p2 = s2; - - do { - if (toupper(*p1) != toupper(*p2)) - return (*p1 - *p2); - p1++; - p2++; - } while (--n != 0); - } - return 0; -} diff --git a/reactos/lib/crt/string/strcoll.c b/reactos/lib/crt/string/strcoll.c deleted file mode 100644 index d9ed3b60dab..00000000000 --- a/reactos/lib/crt/string/strcoll.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* Compare S1 and S2, returning less than, equal to or - greater than zero if the collated form of S1 is lexicographically - less than, equal to or greater than the collated form of S2. */ - -#if 1 -/* - * @unimplemented - */ -int strcoll(const char* s1, const char* s2) -{ - return strcmp(s1, s2); -} - -/* - * @unimplemented - */ -int _stricoll(const char* s1, const char* s2) -{ - return _stricmp(s1, s2); -} - -#else -int strcoll (const char* s1,const char* s2) -{ - int ret; - ret = CompareStringA(LOCALE_USER_DEFAULT,0,s1,strlen(s1),s2,strlen(s2)); - if (ret == 0) - return 0; - else - return ret - 2; - return 0; -} -#endif diff --git a/reactos/lib/crt/string/strdup.c b/reactos/lib/crt/string/strdup.c deleted file mode 100644 index a1e04ddccaf..00000000000 --- a/reactos/lib/crt/string/strdup.c +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -char *_strdup(const char *_s) -{ - char *rv; - if (_s == 0) - return 0; - rv = (char *)malloc(strlen(_s) + 1); - if (rv == 0) - return 0; - strcpy(rv, _s); - return rv; -} diff --git a/reactos/lib/crt/string/strerror.c b/reactos/lib/crt/string/strerror.c deleted file mode 100644 index 170acf41e9b..00000000000 --- a/reactos/lib/crt/string/strerror.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include - -char __syserr00[] = "No Error"; -char __syserr01[] = "Operation not permitted (EPERM)"; -char __syserr02[] = "No such file or directory (ENOENT)"; -char __syserr03[] = "No such process (ESRCH)"; -char __syserr04[] = "Interrupted system call (EINTR)"; -char __syserr05[] = "Input or output error (EIO)"; -char __syserr06[] = "No such device or address (ENXIO)"; -char __syserr07[] = "Argument list too long (E2BIG)"; -char __syserr08[] = "Unable to execute file (ENOEXEC)"; -char __syserr09[] = "Bad file descriptor (EBADF)"; -char __syserr10[] = "No child processes (ECHILD)"; -char __syserr11[] = "Resource temporarily unavailable (EAGAIN)"; -char __syserr12[] = "Not enough memory (ENOMEM)"; -char __syserr13[] = "Permission denied (EACCES)"; -char __syserr14[] = "Bad address (EFAULT)"; -char __syserr15[] = "Unknown Error: 15"; -char __syserr16[] = "Resource busy (EBUSY)"; -char __syserr17[] = "File exists (EEXIST)"; -char __syserr18[] = "Improper link (EXDEV)"; -char __syserr19[] = "No such device (ENODEV)"; -char __syserr20[] = "Not a directory (ENOTDIR)"; -char __syserr21[] = "Is a directory (EISDIR)"; -char __syserr22[] = "Invalid argument (EINVAL)"; -char __syserr23[] = "Too many open files in system (ENFILE)"; -char __syserr24[] = "Too many open files (EMFILE)"; -char __syserr25[] = "Inappropriate I/O control operation (ENOTTY)"; -char __syserr26[] = "Unknown error: 26"; -char __syserr27[] = "File too large (EFBIG)"; -char __syserr28[] = "No space left on drive (ENOSPC)"; -char __syserr29[] = "Invalid seek (ESPIPE)"; -char __syserr30[] = "Read-only file system (EROFS)"; -char __syserr31[] = "Too many links (EMLINK)"; -char __syserr32[] = "Broken pipe (EPIPE)"; -char __syserr33[] = "Input to function out of range (EDOM)"; -char __syserr34[] = "Output of function out of range (ERANGE)"; -char __syserr35[] = "Unknown error: 35"; -char __syserr36[] = "Resource deadlock avoided (EDEADLK)"; -char __syserr37[] = "Unknown error: 37"; -char __syserr38[] = "File name too long (ENAMETOOLONG)"; -char __syserr39[] = "No locks available (ENOLCK)"; -char __syserr40[] = "Function not implemented (ENOSYS)"; -char __syserr41[] = "Directory not empty (ENOTEMPTY)"; -char __syserr42[] = "Illegal byte sequence (EILSEQ)"; - - - - -char *_sys_errlist[] = { -__syserr00, __syserr01, __syserr02, __syserr03, __syserr04, -__syserr05, __syserr06, __syserr07, __syserr08, __syserr09, -__syserr10, __syserr11, __syserr12, __syserr13, __syserr14, -__syserr15, __syserr16, __syserr17, __syserr18, __syserr19, -__syserr20, __syserr21, __syserr22, __syserr23, __syserr24, -__syserr25, __syserr26, __syserr27, __syserr28, __syserr29, -__syserr30, __syserr31, __syserr32, __syserr33, __syserr34, -__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]);//&__sys_nerr; - -/* - * @implemented - */ -char *strerror(int errnum) -{ - static char ebuf[40]; /* 64-bit number + slop */ - char *cp; - int v=1000000, lz=0; - - if (errnum >= 0 && errnum < _sys_nerr) - return((char *)_sys_errlist[errnum]); - - strcpy(ebuf, "Unknown error: "); - cp = ebuf + 15; - if (errnum < 0) - { - *cp++ = '-'; - errnum = -errnum; - } - while (v) - { - int d = errnum / v; - if (d || lz || (v == 1)) - { - *cp++ = d+'0'; - lz = 1; - } - errnum %= v; - v /= 10; - } - - return ebuf; -} - - -/* - * @implemented - */ -char *_strerror(const char *s) -{ - if ( s == NULL ) - return strerror(*_errno()); - - return strerror(atoi(s)); -} diff --git a/reactos/lib/crt/string/stricmp.c b/reactos/lib/crt/string/stricmp.c deleted file mode 100644 index 13b6ad426df..00000000000 --- a/reactos/lib/crt/string/stricmp.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -int -_stricmp(const char *s1, const char *s2) -{ - while (toupper(*s1) == toupper(*s2)) - { - if (*s1 == 0) - return 0; - s1++; - s2++; - } - return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2)); -} - -/* - * @implemented - */ -int -_strcmpi(const char *s1, const char *s2) -{ - return _stricmp(s1,s2); -} diff --git a/reactos/lib/crt/string/strlwr.c b/reactos/lib/crt/string/strlwr.c deleted file mode 100644 index 95487969cd2..00000000000 --- a/reactos/lib/crt/string/strlwr.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * The C RunTime DLL - * - * Implements C run-time functionality as known from UNIX. - * - * Copyright 1996,1998 Marcus Meissner - * Copyright 1996 Jukka Iivonen - * Copyright 1997 Uwe Bonnes - */ - -#include - -/* - * @implemented - */ -char * _strlwr(char *x) -{ - char *y=x; - - while (*y) { - *y=tolower(*y); - y++; - } - return x; -} diff --git a/reactos/lib/crt/string/strncoll.c b/reactos/lib/crt/string/strncoll.c deleted file mode 100644 index 4aa2aedc84e..00000000000 --- a/reactos/lib/crt/string/strncoll.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -/* Compare S1 and S2, returning less than, equal to or - greater than zero if the collated form of S1 is lexicographically - less than, equal to or greater than the collated form of S2. */ - - -/* - * @unimplemented - */ -int _strncoll(const char* s1, const char* s2, size_t c) -{ - return strncmp(s1, s2, c); -} - -/* - * @unimplemented - */ -int _strnicoll(const char* s1, const char* s2, size_t c) -{ - return _strnicmp(s1, s2, c); -} diff --git a/reactos/lib/crt/string/strnicmp.c b/reactos/lib/crt/string/strnicmp.c deleted file mode 100644 index d5f3897afe8..00000000000 --- a/reactos/lib/crt/string/strnicmp.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -int _strnicmp(const char *s1, const char *s2, size_t n) -{ - - if (n == 0) - return 0; - do { - if (toupper(*s1) != toupper(*s2++)) - return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)--s2); - if (*s1++ == 0) - break; - } while (--n != 0); - return 0; -} diff --git a/reactos/lib/crt/string/strrev.c b/reactos/lib/crt/string/strrev.c deleted file mode 100644 index c855f595930..00000000000 --- a/reactos/lib/crt/string/strrev.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -char * _strrev(char *s) -{ - char a, *b, *e; - b=e=s; - while (*e) - e++; - e--; /* start at last char, not NULL char */ - while ( b < e ) - { - a=*b; - *b=*e; - *e=a; - b++; - e--; - } - return s; /* return ptr to beginning of string */ -} diff --git a/reactos/lib/crt/string/strset.c b/reactos/lib/crt/string/strset.c deleted file mode 100644 index 5a1cbec0bee..00000000000 --- a/reactos/lib/crt/string/strset.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -char* _strnset (char* szToFill, int szFill, size_t sizeMaxFill) -{ - char *t = szToFill; - size_t i = 0; - while( *szToFill != 0 && i < sizeMaxFill) - { - *szToFill = szFill; - szToFill++; - i++; - - } - return t; -} - -/* - * @implemented - */ -char* _strset (char* szToFill, int szFill) -{ - char *t = szToFill; - while( *szToFill != 0 ) - { - *szToFill = szFill; - szToFill++; - - } - return t; -} diff --git a/reactos/lib/crt/string/strstr.c b/reactos/lib/crt/string/strstr.c deleted file mode 100644 index c21934b2f9c..00000000000 --- a/reactos/lib/crt/string/strstr.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - - -/* - * @implemented - */ -char *strstr(const char *s, const char *find) -{ - char c, sc; - size_t len; - - if ((c = *find++) != 0) - { - len = strlen(find); - do { - do { - if ((sc = *s++) == 0) - return 0; - } while (sc != c); - } while (strncmp(s, find, len) != 0); - s--; - } - return (char *)s; -} diff --git a/reactos/lib/crt/string/strtok.c b/reactos/lib/crt/string/strtok.c deleted file mode 100644 index aef45f706ea..00000000000 --- a/reactos/lib/crt/string/strtok.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -#include -#include - -char** _lasttoken(); /* lasttok.c */ - -/* - * @implemented - */ -char* strtok(char* s, const char* delim) -{ - const char *spanp; - int c, sc; - char *tok; -#if 1 - char ** lasttoken = _lasttoken(); -#else - PTHREADDATA ThreadData = GetThreadData(); - char ** lasttoken = &ThreadData->lasttoken; -#endif - - if (s == NULL && (s = *lasttoken) == NULL) - return (NULL); - - /* - * Skip (span) leading delimiters (s += strspn(s, delim), sort of). - */ - cont: - c = *s++; - for (spanp = delim; (sc = *spanp++) != 0;) { - if (c == sc) - goto cont; - } - - if (c == 0) { /* no non-delimiter characters */ - *lasttoken = NULL; - return (NULL); - } - tok = s - 1; - - /* - * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). - * Note that delim must have one NUL; we stop if we see that, too. - */ - for (;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *lasttoken = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ -} diff --git a/reactos/lib/crt/string/strupr.c b/reactos/lib/crt/string/strupr.c deleted file mode 100644 index 5f0cdccfc31..00000000000 --- a/reactos/lib/crt/string/strupr.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * The C RunTime DLL - * - * Implements C run-time functionality as known from UNIX. - * - * Copyright 1996,1998 Marcus Meissner - * Copyright 1996 Jukka Iivonen - * Copyright 1997 Uwe Bonnes - */ - -#include - -/* - * @implemented - */ -char *_strupr(char *x) -{ - char *y=x; - - while (*y) { - *y=toupper(*y); - y++; - } - return x; -} diff --git a/reactos/lib/crt/string/strxfrm.c b/reactos/lib/crt/string/strxfrm.c deleted file mode 100644 index dc7361bdcec..00000000000 --- a/reactos/lib/crt/string/strxfrm.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -#if 1 -/* - * @implemented - */ -size_t strxfrm( char *dest, const char *src, size_t n ) -{ - strncpy(dest, src, n); - return (strlen(dest)); -} -#else -size_t strxfrm( char *dest, const char *src, size_t n ) -{ - int ret = LCMapStringA(LOCALE_USER_DEFAULT,LCMAP_LOWERCASE, - src, strlen(src), dest, strlen(dest)); - - if ( ret == 0 ) - return -1; - return ret; - -} -#endif diff --git a/reactos/lib/crt/sys_stat/fstat.c b/reactos/lib/crt/sys_stat/fstat.c deleted file mode 100644 index c402d3fa9e1..00000000000 --- a/reactos/lib/crt/sys_stat/fstat.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/sys/fstat.c - * PURPOSE: Gather file information - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include -#include - -/* - * @implemented - */ -int _fstat(int fd, struct _stat* statbuf) -{ - BY_HANDLE_FILE_INFORMATION FileInformation; - DWORD dwFileType; - void* handle; - - if (!statbuf) { - __set_errno(EINVAL); - return -1; - } - - if ((void*)-1 == (handle = (void*)_get_osfhandle(fd))) - { - __set_errno(EBADF); - return -1; - } - - fflush(NULL); - - memset (statbuf, 0, sizeof(struct stat)); - - dwFileType = GetFileType(handle); - - if (dwFileType == FILE_TYPE_DISK) - { - if (!GetFileInformationByHandle(handle,&FileInformation)) - { - __set_errno(EBADF); - return -1; - } - statbuf->st_ctime = FileTimeToUnixTime(&FileInformation.ftCreationTime,NULL); - statbuf->st_atime = FileTimeToUnixTime(&FileInformation.ftLastAccessTime,NULL); - statbuf->st_mtime = FileTimeToUnixTime(&FileInformation.ftLastWriteTime,NULL); - - statbuf->st_dev = fd; - statbuf->st_size = FileInformation.nFileSizeLow; - statbuf->st_mode = S_IREAD; - if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - statbuf->st_mode |= S_IFDIR; - else - statbuf->st_mode |= S_IFREG; - if (!(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) - statbuf->st_mode |= S_IWRITE; - } - else if (dwFileType == FILE_TYPE_CHAR) - { - statbuf->st_dev = fd; - statbuf->st_mode = S_IFCHR; - } - else if (dwFileType == FILE_TYPE_PIPE) - { - statbuf->st_dev = fd; - statbuf->st_mode = -1; //S_IFIFO; - } - else - { - // dwFileType is FILE_TYPE_UNKNOWN or has a bad value - __set_errno(EBADF); - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/sys_stat/fstati64.c b/reactos/lib/crt/sys_stat/fstati64.c deleted file mode 100644 index d5040708f58..00000000000 --- a/reactos/lib/crt/sys_stat/fstati64.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/sys/fstat.c - * PURPOSE: Gather file information - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include -#include - -/* - * @implemented - */ -int _fstati64(int fd, struct _stati64* statbuf) -{ - BY_HANDLE_FILE_INFORMATION FileInformation; - DWORD dwFileType; - void *handle; - - if (!statbuf) - { - __set_errno(EINVAL); - return -1; - } - - if ((void*)-1 == (handle = (void*)_get_osfhandle(fd))) - { - __set_errno(EBADF); - return -1; - } - - fflush(NULL); - - memset(statbuf, 0, sizeof(struct _stati64)); - - dwFileType = GetFileType(handle); - - if (dwFileType == FILE_TYPE_DISK) - { - if (!GetFileInformationByHandle(handle,&FileInformation)) - { - __set_errno(EBADF); - return -1; - } - statbuf->st_ctime = FileTimeToUnixTime(&FileInformation.ftCreationTime,NULL); - statbuf->st_atime = FileTimeToUnixTime(&FileInformation.ftLastAccessTime,NULL); - statbuf->st_mtime = FileTimeToUnixTime(&FileInformation.ftLastWriteTime,NULL); - - statbuf->st_dev = fd; - statbuf->st_size = (((__int64)FileInformation.nFileSizeHigh) << 32) + - FileInformation.nFileSizeLow; - statbuf->st_mode = S_IREAD; - if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - statbuf->st_mode |= S_IFDIR; - else - statbuf->st_mode |= S_IFREG; - if (!(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) statbuf->st_mode |= S_IWRITE; - } - else if (dwFileType == FILE_TYPE_CHAR) - { - statbuf->st_dev = fd; - statbuf->st_mode = S_IFCHR; - } - else if (dwFileType == FILE_TYPE_PIPE) - { - statbuf->st_dev = fd; - statbuf->st_mode = S_IFIFO; - } - else - { - // dwFileType is FILE_TYPE_UNKNOWN or has a bad value - __set_errno(EBADF); - return -1; - } - return 0; -} diff --git a/reactos/lib/crt/sys_stat/futime.c b/reactos/lib/crt/sys_stat/futime.c deleted file mode 100644 index f9125eb16b9..00000000000 --- a/reactos/lib/crt/sys_stat/futime.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include -#include - -/* - * @implemented - */ -int _futime (int nHandle, struct _utimbuf *pTimes) -{ - FILETIME LastAccessTime; - FILETIME LastWriteTime; - - // check for stdin / stdout handles ?? - if (nHandle == -1) { - __set_errno(EBADF); - return -1; - } - - if (pTimes == NULL) { - pTimes = _alloca(sizeof(struct _utimbuf)); - time(&pTimes->actime); - time(&pTimes->modtime); - } - - if (pTimes->actime < pTimes->modtime) { - __set_errno(EINVAL); - return -1; - } - - UnixTimeToFileTime(pTimes->actime,&LastAccessTime,0); - UnixTimeToFileTime(pTimes->modtime,&LastWriteTime,0); - if (!SetFileTime((HANDLE)_get_osfhandle(nHandle),NULL, &LastAccessTime, &LastWriteTime)) { - __set_errno(EBADF); - return -1; - } - - return 0; -} diff --git a/reactos/lib/crt/sys_stat/stat.c b/reactos/lib/crt/sys_stat/stat.c deleted file mode 100644 index 99963833993..00000000000 --- a/reactos/lib/crt/sys_stat/stat.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include -#include - -/* - * @implemented - */ -int _stat(const char* path, struct _stat* buffer) -{ - WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; - char* ext; - - if (!buffer) - { - __set_errno(EINVAL); - return -1; - } - - if (strchr(path, '*') || strchr(path, '?')) - { - __set_errno(ENOENT); - return -1; - } - - if (!GetFileAttributesExA(path, GetFileExInfoStandard, &fileAttributeData)) - { - __set_errno(ENOENT); - return -1; - } - - memset (buffer, 0, sizeof(struct stat)); - - buffer->st_ctime = FileTimeToUnixTime(&fileAttributeData.ftCreationTime,NULL); - buffer->st_atime = FileTimeToUnixTime(&fileAttributeData.ftLastAccessTime,NULL); - buffer->st_mtime = FileTimeToUnixTime(&fileAttributeData.ftLastWriteTime,NULL); - -// statbuf->st_dev = fd; - buffer->st_size = fileAttributeData.nFileSizeLow; - buffer->st_mode = S_IREAD; - if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - buffer->st_mode |= S_IFDIR; - else - { - buffer->st_mode |= S_IFREG; - ext = strrchr(path, '.'); - if (ext && (!_stricmp(ext, ".exe") || - !_stricmp(ext, ".com") || - !_stricmp(ext, ".bat") || - !_stricmp(ext, ".cmd"))) - buffer->st_mode |= S_IEXEC; - } - if (!(fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) - buffer->st_mode |= S_IWRITE; - - return 0; -} - -/* - * @implemented - */ -int _stati64 (const char *path, struct _stati64 *buffer) -{ - WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; - char* ext; - - if (!buffer) - { - __set_errno(EINVAL); - return -1; - } - - if(strchr(path, '*') || strchr(path, '?')) - { - __set_errno(ENOENT); - return -1; - } - - if (!GetFileAttributesExA(path, GetFileExInfoStandard, &fileAttributeData)) - { - __set_errno(ENOENT); - return -1; - } - - memset (buffer, 0, sizeof(struct _stati64)); - - buffer->st_ctime = FileTimeToUnixTime(&fileAttributeData.ftCreationTime,NULL); - buffer->st_atime = FileTimeToUnixTime(&fileAttributeData.ftLastAccessTime,NULL); - buffer->st_mtime = FileTimeToUnixTime(&fileAttributeData.ftLastWriteTime,NULL); - -// statbuf->st_dev = fd; - buffer->st_size = ((((__int64)fileAttributeData.nFileSizeHigh) << 16) << 16) + - fileAttributeData.nFileSizeLow; - buffer->st_mode = S_IREAD; - if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - buffer->st_mode |= S_IFDIR; - else - { - buffer->st_mode |= S_IFREG; - ext = strrchr(path, '.'); - if (ext && (!_stricmp(ext, ".exe") || - !_stricmp(ext, ".com") || - !_stricmp(ext, ".bat") || - !_stricmp(ext, ".cmd"))) - buffer->st_mode |= S_IEXEC; - } - if (!(fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) - buffer->st_mode |= S_IWRITE; - - return 0; -} - diff --git a/reactos/lib/crt/sys_stat/systime.c b/reactos/lib/crt/sys_stat/systime.c deleted file mode 100644 index 834607bb0b0..00000000000 --- a/reactos/lib/crt/sys_stat/systime.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -int month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31}; - -/* - * @unimplemented - */ -unsigned int _getsystime(struct tm* tp) -{ - SYSTEMTIME Time; - int i; - - GetLocalTime(&Time); - - tp->tm_year = Time.wYear - 1900; - tp->tm_mon = Time.wMonth - 1; - tp->tm_wday = Time.wDayOfWeek; - tp->tm_mday = Time.wDay; - tp->tm_hour = Time.wHour; - tp->tm_min = Time.wMinute; - tp->tm_sec = Time.wSecond; - - tp->tm_isdst = -1; - - //FIXME GetTimeZoneInformation currently not in kernel32 - - //TimeZoneId = GetTimeZoneInformation(&TimeZoneInformation ); - //if ( TimeZoneId == TIME_ZONE_ID_DAYLIGHT ) { - // tp->tm_isdst = 1; - //} - //else - // tp->tm_isdst = 0; - - if (tp->tm_year % 4 == 0) { - if (tp->tm_year % 100 != 0) - tp->tm_yday = 1; - else if ((tp->tm_year-100) % 1000 == 0) - tp->tm_yday = 1; - } - - for (i = 0; i <= tp->tm_mon; i++) - tp->tm_yday += month[i]; - - return Time.wMilliseconds; -} - - -/* - * @implemented - */ -unsigned int _setsystime(struct tm* tp, unsigned int ms) -{ - SYSTEMTIME Time; - - Time.wYear = tp->tm_year + 1900; - Time.wMonth = tp->tm_mon + 1; - Time.wDayOfWeek = tp->tm_wday; - Time.wDay = tp->tm_mday; - Time.wHour = tp->tm_hour; - Time.wMinute = tp->tm_min; - Time.wSecond = tp->tm_sec; - Time.wMilliseconds = ms; - - if (!SetLocalTime(&Time)) - return -1; - - return 0; -} diff --git a/reactos/lib/crt/sys_stat/wstat.c b/reactos/lib/crt/sys_stat/wstat.c deleted file mode 100644 index 12484f2584c..00000000000 --- a/reactos/lib/crt/sys_stat/wstat.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include -#include - -/* - * @implemented - */ -int _wstat (const wchar_t *path, struct _stat *buffer) -{ - WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; - wchar_t *ext; - - if (!buffer) - { - __set_errno(EINVAL); - return -1; - } - - if(wcschr(path, L'*') || wcschr(path, L'?')) - { - __set_errno(ENOENT); - return -1; - } - - if (!GetFileAttributesExW(path, GetFileExInfoStandard, &fileAttributeData)) - { - __set_errno(ENOENT); - return -1; - } - - memset (buffer, 0, sizeof(struct stat)); - - buffer->st_ctime = FileTimeToUnixTime(&fileAttributeData.ftCreationTime,NULL); - buffer->st_atime = FileTimeToUnixTime(&fileAttributeData.ftLastAccessTime,NULL); - buffer->st_mtime = FileTimeToUnixTime(&fileAttributeData.ftLastWriteTime,NULL); - -// statbuf->st_dev = fd; - buffer->st_size = fileAttributeData.nFileSizeLow; - buffer->st_mode = S_IREAD; - if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - buffer->st_mode |= S_IFDIR; - else - { - buffer->st_mode |= S_IFREG; - ext = wcsrchr(path, L'.'); - if (ext && (!_wcsicmp(ext, L".exe") || - !_wcsicmp(ext, L".com") || - !_wcsicmp(ext, L".bat") || - !_wcsicmp(ext, L".cmd"))) - buffer->st_mode |= S_IEXEC; - } - if (!(fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) - buffer->st_mode |= S_IWRITE; - - return 0; -} - -/* - * @implemented - */ -int _wstati64 (const wchar_t *path, struct _stati64 *buffer) -{ - WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; - wchar_t *ext; - - if (!buffer) - { - __set_errno(EINVAL); - return -1; - } - - if(wcschr(path, L'*') || wcschr(path, L'?')) - { - __set_errno(ENOENT); - return -1; - } - - if (!GetFileAttributesExW(path, GetFileExInfoStandard, &fileAttributeData)) - { - __set_errno(ENOENT); - return -1; - } - - memset (buffer, 0, sizeof(struct _stati64)); - - buffer->st_ctime = FileTimeToUnixTime(&fileAttributeData.ftCreationTime,NULL); - buffer->st_atime = FileTimeToUnixTime(&fileAttributeData.ftLastAccessTime,NULL); - buffer->st_mtime = FileTimeToUnixTime(&fileAttributeData.ftLastWriteTime,NULL); - -// statbuf->st_dev = fd; - buffer->st_size = ((((__int64)fileAttributeData.nFileSizeHigh) << 16) << 16) + - fileAttributeData.nFileSizeLow; - buffer->st_mode = S_IREAD; - if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - buffer->st_mode |= S_IFDIR; - else - { - buffer->st_mode |= S_IFREG; - ext = wcsrchr(path, L'.'); - if (ext && (!_wcsicmp(ext, L".exe") || - !_wcsicmp(ext, L".com") || - !_wcsicmp(ext, L".bat") || - !_wcsicmp(ext, L".cmd"))) - buffer->st_mode |= S_IEXEC; - } - if (!(fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) - buffer->st_mode |= S_IWRITE; - - return 0; -} diff --git a/reactos/lib/crt/time/clock.c b/reactos/lib/crt/time/clock.c deleted file mode 100644 index 37ec011fbef..00000000000 --- a/reactos/lib/crt/time/clock.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/time/clock.c - * PURPOSE: Get elapsed time - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include - -/* - * @implemented - */ -clock_t clock ( void ) -{ - FILETIME CreationTime; - FILETIME ExitTime; - FILETIME KernelTime; - FILETIME UserTime; - DWORD Remainder; - - if (!GetProcessTimes(GetCurrentProcess(),&CreationTime,&ExitTime,&KernelTime,&UserTime)) - return -1; - - return FileTimeToUnixTime(&KernelTime,&Remainder) + FileTimeToUnixTime(&UserTime,&Remainder); -} diff --git a/reactos/lib/crt/time/ctime.c b/reactos/lib/crt/time/ctime.c deleted file mode 100644 index 5a0df49b3e7..00000000000 --- a/reactos/lib/crt/time/ctime.c +++ /dev/null @@ -1,1438 +0,0 @@ - -// fix djdir - -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* This file has been modified by DJ Delorie. These modifications are -** Copyright (C) 1995 DJ Delorie, 24 Kirsten Ave, Rochester NH, -** 03867-2954, USA. -*/ - -/* - * Copyright (c) 1987, 1989 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Arthur David Olson of the National Cancer Institute. - * - * Redistribution and use in source and binary forms are permitted provided - * that: (1) source distributions retain this entire copyright notice and - * comment, and (2) distributions including binaries display the following - * acknowledgement: ``This product includes software developed by the - * University of California, Berkeley and its contributors'' in the - * documentation or other materials provided with the distribution and in - * all advertising materials mentioning features or use of this software. - * Neither the name of the University nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* -** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). -** POSIX-style TZ environment variable handling from Guy Harris -** (guy@auspex.com). -*/ - -#include - -#include "tzfile.h" -#include "posixrul.h" - -#ifdef __cplusplus -#define CPP_CONST const -#else -#define CPP_CONST -#endif - -#define P(s) s -#define alloc_size_t size_t -#define qsort_size_t size_t -#define fread_size_t size_t -#define fwrite_size_t size_t - -#define ACCESS_MODE O_RDONLY|O_BINARY -#define OPEN_MODE O_RDONLY|O_BINARY - -/* -** Someone might make incorrect use of a time zone abbreviation: -** 1. They might reference tzname[0] before calling tzset (explicitly -** or implicitly). -** 2. They might reference tzname[1] before calling tzset (explicitly -** or implicitly). -** 3. They might reference tzname[1] after setting to a time zone -** in which Daylight Saving Time is never observed. -** 4. They might reference tzname[0] after setting to a time zone -** in which Standard Time is never observed. -** 5. They might reference tm.TM_ZONE after calling offtime. -** What's best to do in the above cases is open to debate; -** for now, we just set things up so that in any of the five cases -** WILDABBR is used. Another possibility: initialize tzname[0] to the -** string "tzname[0] used before set", and similarly for the other cases. -** And another: initialize tzname[0] to "ERA", with an explanation in the -** manual page of what this "time zone abbreviation" means (doing this so -** that tzname[0] has the "normal" length of three characters). -*/ - -void _set_daylight_export(int); -void _set_timezone_export(int); - - -/* buffers must hold 64 characters! */ -static char TZ_NAME[64] = "PST"; -static char TZ_DST_NAME[64] = "PDT"; - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif /* !defined TRUE */ - -static const char GMT[] = "GMT"; - -struct ttinfo { /* time type information */ - long tt_gmtoff; /* GMT offset in seconds */ - int tt_isdst; /* used to set tm_isdst */ - int tt_abbrind; /* abbreviation list index */ - int tt_ttisstd; /* TRUE if transition is std time */ -}; - -struct lsinfo { /* leap second information */ - time_t ls_trans; /* transition time */ - long ls_corr; /* correction to apply */ -}; - -struct state { - int leapcnt; - int timecnt; - int typecnt; - int charcnt; - time_t ats[TZ_MAX_TIMES]; - unsigned char types[TZ_MAX_TIMES]; - struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[(TZ_MAX_CHARS + 1 > sizeof GMT) ? TZ_MAX_CHARS + 1 : sizeof GMT]; - struct lsinfo lsis[TZ_MAX_LEAPS]; -}; - -struct rule { - int r_type; /* type of rule--see below */ - int r_day; /* day number of rule */ - int r_week; /* week number of rule */ - int r_mon; /* month number of rule */ - long r_time; /* transition time of rule */ -}; - -#define JULIAN_DAY 0 /* Jn - Julian day */ -#define DAY_OF_YEAR 1 /* n - day of year */ -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ - -/* -** Prototypes for static functions. -*/ -#if 0 -static long detzcode P((const char * codep)); -static const char * getzname P((const char * strp)); -static const char * getnum P((const char * strp, int * nump, int min, int max)); -static const char * getsecs P((const char * strp, long * secsp)); -static const char * getoffset P((const char * strp, long * offsetp)); -static const char * getrule P((const char * strp, struct rule * rulep)); -static void gmtload P((struct state * sp)); -static void gmtsub P((const time_t * timep, long offset, struct tm * tmp)); -static void localsub P((const time_t * timep, long offset, struct tm * tmp)); -static void normalize P((int * tensptr, int * unitsptr, int base)); -static void settzname P((void)); -static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset)); -static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset, int * okayp)); -static void timesub P((const time_t * timep, long offset, const struct state * sp, struct tm * tmp)); -static int tmcomp P((const struct tm * atmp, const struct tm * btmp)); -static time_t transtime P((time_t janfirst, int year, const struct rule * rulep, long offset)); -static int tzload P((const char * name, struct state * sp)); -static int tzparse P((const char * name, struct state * sp, int lastditch)); -static void tzsetwall(void); - -#else - -static const char * getnum(const char * strp, int * CPP_CONST nump, const int min, const int max); -static void timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp); -static time_t transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset); -static void tzsetwall(void); - -#endif - -#ifdef ALL_STATE -static struct state *lclptr; -static struct state *gmtptr; -#endif /* defined ALL_STATE */ - -#ifndef ALL_STATE -static struct state lclmem; -static struct state gmtmem; -#define lclptr (&lclmem) -#define gmtptr (&gmtmem) -#endif /* State Farm */ - -static int lcl_is_set; -static int gmt_is_set; - -char * _tzname[2] = { - TZ_NAME, - TZ_DST_NAME, -}; - -static long -detzcode(const char * CPP_CONST codep) -{ - long result; - int i; - - result = 0; - for (i = 0; i < 4; ++i) - result = (result << 8) | (codep[i] & 0xff); - return result; -} - -static void -settzname(void) -{ - const struct state * CPP_CONST sp = lclptr; - int i; - - _tzname[0] = TZ_NAME; - _tzname[1] = TZ_DST_NAME; -#ifdef ALL_STATE - if (sp == NULL) - { - _tzname[0] = _tzname[1] = GMT; - return; - } -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) - { - register const struct ttinfo * CPP_CONST ttisp = &sp->ttis[i]; - - _tzname[ttisp->tt_isdst] = - (char *)&sp->chars[ttisp->tt_abbrind]; -#if 0 - if (ttisp->tt_isdst) { - //_daylight = 1; - _set_daylight_export(1); - } - if (i == 0 || !ttisp->tt_isdst) { - //_timezone_dll = -(ttisp->tt_gmtoff); - _set_timezone_export(-(ttisp->tt_gmtoff)); - } - if (i == 0 || ttisp->tt_isdst) { - _altzone = -(ttisp->tt_gmtoff); - } -#endif - } - /* - ** And to get the latest zone names into tzname. . . - */ - for (i = 0; i < sp->timecnt; ++i) - { - const struct ttinfo * CPP_CONST ttisp = &sp->ttis[sp->types[i]]; - - _tzname[ttisp->tt_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; - } -} - -static char* tzdir(void) -{ - static char dir[80]={0}, *cp; - if (dir[0] == 0) - { - if ((cp = getenv("TZDIR"))) - { - strcpy(dir, cp); - } - else if ((cp = getenv("DJDIR"))) - { - strcpy(dir, cp); - strcat(dir, "/zoneinfo"); - } - else - strcpy(dir, "./"); - } - return dir; -} - -static int tzload(const char* name, struct state* CPP_CONST sp) -{ - const char * p; - int i; - int fid; - char fullname[FILENAME_MAX + 1]; - const struct tzhead * tzhp; - char buf[sizeof *sp + sizeof *tzhp]; - int ttisstdcnt; - - if (name == NULL && (name = TZDEFAULT) == NULL) - return -1; - - if (name[0] == ':') - ++name; - if (name[0] != '/') - { - if ((p = tzdir()) == NULL) - return -1; - if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) - return -1; - strcpy(fullname, p); - strcat(fullname, "/"); - strcat(fullname, name); - name = fullname; - } - - if ((fid = _open(name, OPEN_MODE)) == -1) - { - const char *base = strrchr(name, '/'); - if (base) - base++; - else - base = name; - if (strcmp(base, "posixrules")) - return -1; - - /* We've got a built-in copy of posixrules just in case */ - memcpy(buf, _posixrules_data, sizeof(_posixrules_data)); - i = sizeof(_posixrules_data); - } - else - { - i = _read(fid, buf, sizeof buf); - if (_close(fid) != 0 || i < (int)sizeof *tzhp) - return -1; - } - - tzhp = (struct tzhead *) buf; - ttisstdcnt = (int) detzcode(tzhp->tzh_ttisstdcnt); - sp->leapcnt = (int) detzcode(tzhp->tzh_leapcnt); - sp->timecnt = (int) detzcode(tzhp->tzh_timecnt); - sp->typecnt = (int) detzcode(tzhp->tzh_typecnt); - sp->charcnt = (int) detzcode(tzhp->tzh_charcnt); - if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || - sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || - sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || - sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || - (ttisstdcnt != sp->typecnt && ttisstdcnt != 0)) - return -1; - if (i < (int)sizeof *tzhp + - sp->timecnt * (4 + (int)sizeof (char)) + - sp->typecnt * (4 + 2 * (int)sizeof (char)) + - sp->charcnt * (int)sizeof (char) + - sp->leapcnt * 2 * 4 + - ttisstdcnt * (int)sizeof (char)) - return -1; - p = buf + sizeof *tzhp; - for (i = 0; i < sp->timecnt; ++i) - { - sp->ats[i] = detzcode(p); - p += 4; - } - for (i = 0; i < sp->timecnt; ++i) - { - sp->types[i] = (unsigned char) *p++; - if (sp->types[i] >= sp->typecnt) - return -1; - } - for (i = 0; i < sp->typecnt; ++i) - { - struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - ttisp->tt_gmtoff = detzcode(p); - p += 4; - ttisp->tt_isdst = (unsigned char) *p++; - if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) - return -1; - ttisp->tt_abbrind = (unsigned char) *p++; - if (ttisp->tt_abbrind < 0 || - ttisp->tt_abbrind > sp->charcnt) - return -1; - } - for (i = 0; i < sp->charcnt; ++i) - sp->chars[i] = *p++; - sp->chars[i] = '\0'; /* ensure '\0' at end */ - for (i = 0; i < sp->leapcnt; ++i) - { - struct lsinfo * lsisp; - - lsisp = &sp->lsis[i]; - lsisp->ls_trans = detzcode(p); - p += 4; - lsisp->ls_corr = detzcode(p); - p += 4; - } - for (i = 0; i < sp->typecnt; ++i) - { - struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - if (ttisstdcnt == 0) - ttisp->tt_ttisstd = FALSE; - else - { - ttisp->tt_ttisstd = *p++; - if (ttisp->tt_ttisstd != TRUE && - ttisp->tt_ttisstd != FALSE) - return -1; - } - } - return 0; -} - -static const int mon_lengths[2][MONSPERYEAR] = { -{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, -{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -static const int year_lengths[2] = { -DAYSPERNYEAR, DAYSPERLYEAR -}; - -/* -** Given a pointer into a time zone string, scan until a character that is not -** a valid character in a zone name is found. Return a pointer to that -** character. -*/ - -static const char* -getzname(const char* strp) -{ - char c; - - while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' && - c != '+') - ++strp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number from that string. -** Check that the number is within a specified range; if it is not, return -** NULL. -** Otherwise, return a pointer to the first character not part of the number. -*/ - -static const char* -getnum(const char* strp, int* CPP_CONST nump, const int min, const int max) -{ - char c; - int num; - - if (strp == NULL || !isdigit(*strp)) - return NULL; - num = 0; - while ((c = *strp) != '\0' && isdigit(c)) - { - num = num * 10 + (c - '0'); - if (num > max) - return NULL; - ++strp; - } - if (num < min) - return NULL; - *nump = num; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number of seconds, -** in hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the number -** of seconds. -*/ - -static const char * -getsecs(const char *strp, long * CPP_CONST secsp) -{ - int num; - - strp = getnum(strp, &num, 0, HOURSPERDAY); - if (strp == NULL) - return NULL; - *secsp = num * SECSPERHOUR; - if (*strp == ':') - { - ++strp; - strp = getnum(strp, &num, 0, MINSPERHOUR - 1); - if (strp == NULL) - return NULL; - *secsp += num * SECSPERMIN; - if (*strp == ':') - { - ++strp; - strp = getnum(strp, &num, 0, SECSPERMIN - 1); - if (strp == NULL) - return NULL; - *secsp += num; - } - } - return strp; -} - -/* -** Given a pointer into a time zone string, extract an offset, in -** [+-]hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the time. -*/ - -static const char * -getoffset(const char *strp, long * CPP_CONST offsetp) -{ - int neg; - - if (*strp == '-') - { - neg = 1; - ++strp; - } - else if (isdigit(*strp) || *strp++ == '+') - neg = 0; - else - return NULL; /* illegal offset */ - strp = getsecs(strp, offsetp); - if (strp == NULL) - return NULL; /* illegal time */ - if (neg) - *offsetp = -*offsetp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a rule in the form -** date[/time]. See POSIX section 8 for the format of "date" and "time". -** If a valid rule is not found, return NULL. -** Otherwise, return a pointer to the first character not part of the rule. -*/ - -static const char * -getrule(const char *strp, struct rule * CPP_CONST rulep) -{ - if (*strp == 'J') - { - /* - ** Julian day. - */ - rulep->r_type = JULIAN_DAY; - ++strp; - strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); - } - else if (*strp == 'M') - { - /* - ** Month, week, day. - */ - rulep->r_type = MONTH_NTH_DAY_OF_WEEK; - ++strp; - strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_week, 1, 5); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); - } - else if (isdigit(*strp)) - { - /* - ** Day of year. - */ - rulep->r_type = DAY_OF_YEAR; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); - } - else - return NULL; /* invalid format */ - if (strp == NULL) - return NULL; - if (*strp == '/') - { - /* - ** Time specified. - */ - ++strp; - strp = getsecs(strp, &rulep->r_time); - } - else - rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ - return strp; -} - -/* -** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the -** year, a rule, and the offset from GMT at the time that rule takes effect, -** calculate the Epoch-relative time that rule takes effect. -*/ - -static time_t -transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset) -{ - int leapyear; - time_t value=0; - int i; - int d, m1, yy0, yy1, yy2, dow; - - leapyear = isleap(year); - switch (rulep->r_type) - { - - case JULIAN_DAY: - /* - ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap - ** years. - ** In non-leap years, or if the day number is 59 or less, just - ** add SECSPERDAY times the day number-1 to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + (rulep->r_day - 1) * SECSPERDAY; - if (leapyear && rulep->r_day >= 60) - value += SECSPERDAY; - break; - - case DAY_OF_YEAR: - /* - ** n - day of year. - ** Just add SECSPERDAY times the day number to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + rulep->r_day * SECSPERDAY; - break; - - case MONTH_NTH_DAY_OF_WEEK: - /* - ** Mm.n.d - nth "dth day" of month m. - */ - value = janfirst; - for (i = 0; i < rulep->r_mon - 1; ++i) - value += mon_lengths[leapyear][i] * SECSPERDAY; - - /* - ** Use Zeller's Congruence to get day-of-week of first day of - ** month. - */ - m1 = (rulep->r_mon + 9) % 12 + 1; - yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; - yy1 = yy0 / 100; - yy2 = yy0 % 100; - dow = ((26 * m1 - 2) / 10 + - 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; - if (dow < 0) - dow += DAYSPERWEEK; - - /* - ** "dow" is the day-of-week of the first day of the month. Get - ** the day-of-month (zero-origin) of the first "dow" day of the - ** month. - */ - d = rulep->r_day - dow; - if (d < 0) - d += DAYSPERWEEK; - for (i = 1; i < rulep->r_week; ++i) - { - if (d + DAYSPERWEEK >= - mon_lengths[leapyear][rulep->r_mon - 1]) - break; - d += DAYSPERWEEK; - } - - /* - ** "d" is the day-of-month (zero-origin) of the day we want. - */ - value += d * SECSPERDAY; - break; - } - - /* - ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in - ** question. To get the Epoch-relative time of the specified local - ** time on that day, add the transition time and the current offset - ** from GMT. - */ - return value + rulep->r_time + offset; -} - -/* -** Given a POSIX section 8-style TZ string, fill in the rule tables as -** appropriate. -*/ - -static int -tzparse(const char *name, struct state * CPP_CONST sp, const int lastditch) -{ - const char * stdname; - const char * dstname=0; - int stdlen; - int dstlen; - long stdoffset; - long dstoffset; - time_t * atp; - unsigned char * typep; - char * cp; - int load_result; - - stdname = name; - if (lastditch) - { - stdlen = strlen(name); /* length of standard zone name */ - name += stdlen; - if (stdlen >= (int)sizeof sp->chars) - stdlen = (int)(sizeof sp->chars) - 1; - } - else - { - name = getzname(name); - stdlen = name - stdname; - if (stdlen < 3) - return -1; - } - if (*name == '\0') - return -1; - else - { - name = getoffset(name, &stdoffset); - if (name == NULL) - return -1; - } - load_result = tzload(TZDEFRULES, sp); - if (load_result != 0) - sp->leapcnt = 0; /* so, we're off a little */ - if (*name != '\0') - { - dstname = name; - name = getzname(name); - dstlen = name - dstname; /* length of DST zone name */ - if (dstlen < 3) - return -1; - if (*name != '\0' && *name != ',' && *name != ';') - { - name = getoffset(name, &dstoffset); - if (name == NULL) - return -1; - } - else - dstoffset = stdoffset - SECSPERHOUR; - if (*name == ',' || *name == ';') - { - struct rule start; - struct rule end; - int year; - time_t janfirst; - time_t starttime; - time_t endtime; - - ++name; - if ((name = getrule(name, &start)) == NULL) - return -1; - if (*name++ != ',') - return -1; - if ((name = getrule(name, &end)) == NULL) - return -1; - if (*name != '\0') - return -1; - sp->typecnt = 2; /* standard time and DST */ - /* - ** Two transitions per year, from EPOCH_YEAR to 2037. - */ - sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); - if (sp->timecnt > TZ_MAX_TIMES) - return -1; - sp->ttis[0].tt_gmtoff = -dstoffset; - sp->ttis[0].tt_isdst = 1; - sp->ttis[0].tt_abbrind = stdlen + 1; - sp->ttis[1].tt_gmtoff = -stdoffset; - sp->ttis[1].tt_isdst = 0; - sp->ttis[1].tt_abbrind = 0; - atp = sp->ats; - typep = sp->types; - janfirst = 0; - for (year = EPOCH_YEAR; year <= 2037; ++year) - { - starttime = transtime(janfirst, year, &start, - stdoffset); - endtime = transtime(janfirst, year, &end, - dstoffset); - if (starttime > endtime) - { - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - } - else - { - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - } - janfirst += - year_lengths[isleap(year)] * SECSPERDAY; - } - } - else - { - int sawstd; - int sawdst; - long stdfix; - long dstfix; - long oldfix; - int isdst; - int i; - - if (*name != '\0') - return -1; - if (load_result != 0) - return -1; - /* - ** Compute the difference between the real and - ** prototype standard and summer time offsets - ** from GMT, and put the real standard and summer - ** time offsets into the rules in place of the - ** prototype offsets. - */ - sawstd = FALSE; - sawdst = FALSE; - stdfix = 0; - dstfix = 0; - for (i = 0; i < sp->typecnt; ++i) - { - if (sp->ttis[i].tt_isdst) - { - oldfix = dstfix; - dstfix = - sp->ttis[i].tt_gmtoff + dstoffset; - if (sawdst && (oldfix != dstfix)) - return -1; - sp->ttis[i].tt_gmtoff = -dstoffset; - sp->ttis[i].tt_abbrind = stdlen + 1; - sawdst = TRUE; - } - else - { - oldfix = stdfix; - stdfix = - sp->ttis[i].tt_gmtoff + stdoffset; - if (sawstd && (oldfix != stdfix)) - return -1; - sp->ttis[i].tt_gmtoff = -stdoffset; - sp->ttis[i].tt_abbrind = 0; - sawstd = TRUE; - } - } - /* - ** Make sure we have both standard and summer time. - */ - if (!sawdst || !sawstd) - return -1; - /* - ** Now correct the transition times by shifting - ** them by the difference between the real and - ** prototype offsets. Note that this difference - ** can be different in standard and summer time; - ** the prototype probably has a 1-hour difference - ** between standard and summer time, but a different - ** difference can be specified in TZ. - */ - isdst = FALSE; /* we start in standard time */ - for (i = 0; i < sp->timecnt; ++i) - { - const struct ttinfo * ttisp; - - /* - ** If summer time is in effect, and the - ** transition time was not specified as - ** standard time, add the summer time - ** offset to the transition time; - ** otherwise, add the standard time offset - ** to the transition time. - */ - ttisp = &sp->ttis[sp->types[i]]; - sp->ats[i] += - (isdst && !ttisp->tt_ttisstd) ? - dstfix : stdfix; - isdst = ttisp->tt_isdst; - } - } - } - else - { - dstlen = 0; - sp->typecnt = 1; /* only standard time */ - sp->timecnt = 0; - sp->ttis[0].tt_gmtoff = -stdoffset; - sp->ttis[0].tt_isdst = 0; - sp->ttis[0].tt_abbrind = 0; - } - sp->charcnt = stdlen + 1; - if (dstlen != 0) - sp->charcnt += dstlen + 1; - if (sp->charcnt > (int)sizeof sp->chars) - return -1; - cp = sp->chars; - (void) strncpy(cp, stdname, stdlen); - cp += stdlen; - *cp++ = '\0'; - if (dstlen != 0) - { - (void) strncpy(cp, dstname, dstlen); - *(cp + dstlen) = '\0'; - } - return 0; -} - -static void -gmtload(struct state * CPP_CONST sp) -{ - if (tzload(GMT, sp) != 0) - (void) tzparse(GMT, sp, TRUE); -} - -/* - * @implemented - */ -void -_tzset(void) -{ - const char * name; - - name = getenv("TZ"); - if (name == NULL) - { - tzsetwall(); - return; - } - lcl_is_set = TRUE; -#ifdef ALL_STATE - if (lclptr == NULL) - { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) - { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ - if (*name == '\0') - { - /* - ** User wants it fast rather than right. - */ - lclptr->leapcnt = 0; /* so, we're off a little */ - lclptr->timecnt = 0; - lclptr->ttis[0].tt_gmtoff = 0; - lclptr->ttis[0].tt_abbrind = 0; - (void) strcpy(lclptr->chars, GMT); - } - else if (tzload(name, lclptr) != 0) - if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) - gmtload(lclptr); - settzname(); -} - -void -tzsetwall(void) -{ - lcl_is_set = TRUE; -#ifdef ALL_STATE - if (lclptr == NULL) - { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) - { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ - if (tzload((char *) NULL, lclptr) != 0) - gmtload(lclptr); - settzname(); -} - -/* -** The easy way to behave "as if no library function calls" localtime -** is to not call it--so we drop its guts into "localsub", which can be -** freely called. (And no, the PANS doesn't require the above behavior-- -** but it *is* desirable.) -** -** The unused offset argument is for the benefit of mktime variants. -*/ - -/*ARGSUSED*/ -static void -localsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp) -{ - const struct state * sp; - const struct ttinfo * ttisp; - int i; - const time_t t = *timep; - - if (!lcl_is_set) - _tzset(); - sp = lclptr; -#ifdef ALL_STATE - if (sp == NULL) - { - gmtsub(timep, offset, tmp); - return; - } -#endif /* defined ALL_STATE */ - if (sp->timecnt == 0 || t < sp->ats[0]) - { - i = 0; - while (sp->ttis[i].tt_isdst) - if (++i >= sp->typecnt) - { - i = 0; - break; - } - } - else - { - for (i = 1; i < sp->timecnt; ++i) - if (t < sp->ats[i]) - break; - i = sp->types[i - 1]; - } - ttisp = &sp->ttis[i]; - /* - ** To get (wrong) behavior that's compatible with System V Release 2.0 - ** you'd replace the statement below with - ** t += ttisp->tt_gmtoff; - ** timesub(&t, 0L, sp, tmp); - */ - 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 -} - -/* - * @implemented - */ -struct tm * -localtime(const time_t * CPP_CONST timep) -{ - static struct tm tm; - - localsub(timep, 0L, &tm); - return &tm; -} - -/* -** gmtsub is to gmtime as localsub is to localtime. -*/ - -static void -gmtsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp) -{ - if (!gmt_is_set) - { - gmt_is_set = TRUE; -#ifdef ALL_STATE - gmtptr = (struct state *) malloc(sizeof *gmtptr); - if (gmtptr != NULL) -#endif /* defined ALL_STATE */ - gmtload(gmtptr); - } - timesub(timep, offset, gmtptr, tmp); - /* - ** Could get fancy here and deliver something such as - ** "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 - { -#ifdef ALL_STATE - if (gmtptr == NULL) - tmp->TM_ZONE = GMT; - else - tmp->TM_ZONE = gmtptr->chars; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - tmp->tm_zone = gmtptr->chars; -#endif /* State Farm */ - } -#endif /* if 0 */ -} - -/* - * @implemented - */ -struct tm * -gmtime(const time_t * CPP_CONST timep) -{ - static struct tm tm; - - gmtsub(timep, 0L, &tm); - return &tm; -} - -static void -timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp) -{ - const struct lsinfo * lp; - long days; - long rem; - int y; - int yleap; - const int * ip; - long corr; - int hit; - int i; - - corr = 0; - hit = FALSE; -#ifdef ALL_STATE - i = (sp == NULL) ? 0 : sp->leapcnt; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - i = sp->leapcnt; -#endif /* State Farm */ - while (--i >= 0) - { - lp = &sp->lsis[i]; - if (*timep >= lp->ls_trans) - { - if (*timep == lp->ls_trans) - hit = ((i == 0 && lp->ls_corr > 0) || - lp->ls_corr > sp->lsis[i - 1].ls_corr); - corr = lp->ls_corr; - break; - } - } - days = *timep / SECSPERDAY; - rem = *timep % SECSPERDAY; -#ifdef mc68k - if (*timep == 0x80000000) - { - /* - ** A 3B1 muffs the division on the most negative number. - */ - days = -24855; - rem = -11648; - } -#endif /* mc68k */ - rem += (offset - corr); - while (rem < 0) - { - rem += SECSPERDAY; - --days; - } - while (rem >= SECSPERDAY) - { - rem -= SECSPERDAY; - ++days; - } - tmp->tm_hour = (int) (rem / SECSPERHOUR); - rem = rem % SECSPERHOUR; - tmp->tm_min = (int) (rem / SECSPERMIN); - tmp->tm_sec = (int) (rem % SECSPERMIN); - if (hit) - /* - ** A positive leap second requires a special - ** representation. This uses "... ??:59:60". - */ - ++(tmp->tm_sec); - tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); - if (tmp->tm_wday < 0) - tmp->tm_wday += DAYSPERWEEK; - y = EPOCH_YEAR; - if (days >= 0) - for ( ; ; ) - { - yleap = isleap(y); - if (days < (long) year_lengths[yleap]) - break; - ++y; - days = days - (long) year_lengths[yleap]; - } - else - do { - --y; - yleap = isleap(y); - days = days + (long) year_lengths[yleap]; - } while (days < 0); - tmp->tm_year = y - TM_YEAR_BASE; - tmp->tm_yday = (int) days; - ip = mon_lengths[yleap]; - for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) - 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 -} - -/* -** A la X3J11 -*/ - -/* - * @implemented - */ -char * -asctime(const struct tm *timeptr) -{ - static const char wday_name[DAYSPERWEEK][3] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; - static const char mon_name[MONSPERYEAR][3] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - static char result[26]; - - (void) sprintf(result, "%.3s %.3s%3d %02d:%02d:%02d %d\n", - wday_name[timeptr->tm_wday], - mon_name[timeptr->tm_mon], - timeptr->tm_mday, timeptr->tm_hour, - timeptr->tm_min, timeptr->tm_sec, - TM_YEAR_BASE + timeptr->tm_year); - return result; -} - -/* - * @implemented - */ -char * -ctime(const time_t * CPP_CONST timep) -{ - return asctime(localtime(timep)); -} - -/* -** Adapted from code provided by Robert Elz, who writes: -** The "best" way to do mktime I think is based on an idea of Bob -** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now). -** It does a binary search of the time_t space. Since time_t's are -** just 32 bits, its a max of 32 iterations (even at 64 bits it -** would still be very reasonable). -*/ - -#ifndef WRONG -#define WRONG (-1) -#endif /* !defined WRONG */ - -static void -normalize(int * CPP_CONST tensptr, int * CPP_CONST unitsptr, const int base) -{ - if (*unitsptr >= base) - { - *tensptr += *unitsptr / base; - *unitsptr %= base; - } - else if (*unitsptr < 0) - { - --*tensptr; - *unitsptr += base; - if (*unitsptr < 0) - { - *tensptr -= 1 + (-*unitsptr) / base; - *unitsptr = base - (-*unitsptr) % base; - } - } -} - -static int -tmcomp(const struct tm * CPP_CONST atmp, const struct tm * CPP_CONST btmp) -{ - int result; - - if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && - (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && - (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && - (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && - (result = (atmp->tm_min - btmp->tm_min)) == 0) - result = atmp->tm_sec - btmp->tm_sec; - return result; -} - -static time_t -time2(struct tm *tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset, int * CPP_CONST okayp) -{ - const struct state * sp; - int dir; - int bits; - int i, j ; - int saved_seconds; - time_t newt; - time_t t; - struct tm yourtm, mytm; - - *okayp = FALSE; - yourtm = *tmp; - if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0) - normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN); - normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR); - normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY); - normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR); - while (yourtm.tm_mday <= 0) - { - --yourtm.tm_year; - yourtm.tm_mday += - year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)]; - } - for ( ; ; ) - { - i = mon_lengths[isleap(yourtm.tm_year + - TM_YEAR_BASE)][yourtm.tm_mon]; - if (yourtm.tm_mday <= i) - break; - yourtm.tm_mday -= i; - if (++yourtm.tm_mon >= MONSPERYEAR) - { - yourtm.tm_mon = 0; - ++yourtm.tm_year; - } - } - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = 0; - /* - ** Calculate the number of magnitude bits in a time_t - ** (this works regardless of whether time_t is - ** signed or unsigned, though lint complains if unsigned). - */ - for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) - ; - /* - ** If time_t is signed, then 0 is the median value, - ** if time_t is unsigned, then 1 << bits is median. - */ -#ifdef _MSVCRT_LIB_ - t = (time_t) ((1 << bits) - 1); -#else // TODO: FIXME: review which is correct - t = (time_t) 1 << bits; -#endif /*_MSVCRT_LIB_*/ - - for ( ; ; ) - { - (*funcp)(&t, offset, &mytm); - dir = tmcomp(&mytm, &yourtm); - if (dir != 0) - { - if (bits-- < 0) - return WRONG; - if (bits < 0) - --t; - else if (dir > 0) - t -= (time_t) 1 << bits; - else t += (time_t) 1 << bits; - continue; - } - if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) - break; - /* - ** Right time, wrong type. - ** Hunt for right time, right type. - ** It's okay to guess wrong since the guess - ** gets checked. - */ - sp = (const struct state *) - ((funcp == localsub) ? lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) - { - if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) - continue; - for (j = 0; j < sp->typecnt; ++j) - { - if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) - continue; - newt = t + sp->ttis[j].tt_gmtoff - - sp->ttis[i].tt_gmtoff; - (*funcp)(&newt, offset, &mytm); - if (tmcomp(&mytm, &yourtm) != 0) - continue; - if (mytm.tm_isdst != yourtm.tm_isdst) - continue; - /* - ** We have a match. - */ - t = newt; - goto label; - } - } - return WRONG; - } - label: - t += saved_seconds; - (*funcp)(&t, offset, tmp); - *okayp = TRUE; - return t; -} - -static time_t -time1(struct tm * CPP_CONST tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset) -{ - time_t t; - const struct state * sp; - int samei, otheri; - int okay; - - if (tmp->tm_isdst > 1) - tmp->tm_isdst = 1; - t = time2(tmp, funcp, offset, &okay); - if (okay || tmp->tm_isdst < 0) - return t; - /* - ** We're supposed to assume that somebody took a time of one type - ** and did some math on it that yielded a "struct tm" that's bad. - ** We try to divine the type they started from and adjust to the - ** type they need. - */ - sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (samei = 0; samei < sp->typecnt; ++samei) - { - if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) - continue; - for (otheri = 0; otheri < sp->typecnt; ++otheri) - { - if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) - continue; - tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - t = time2(tmp, funcp, offset, &okay); - if (okay) - return t; - tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - } - } - return WRONG; -} - -/* - * @implemented - */ -time_t -mktime(struct tm * tmp) -{ - return time1(tmp, localsub, 0L); -} diff --git a/reactos/lib/crt/time/difftime.c b/reactos/lib/crt/time/difftime.c deleted file mode 100644 index bd3b2215fa6..00000000000 --- a/reactos/lib/crt/time/difftime.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -double -difftime(time_t time1, time_t time0) -{ - return time1-time0; -} diff --git a/reactos/lib/crt/time/ftime.c b/reactos/lib/crt/time/ftime.c deleted file mode 100644 index 8df9729d53a..00000000000 --- a/reactos/lib/crt/time/ftime.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/time/ftime.c - * PURPOSE: Deprecated BSD library call - * PROGRAMER: Art Yerkes - * UPDATE HISTORY: - * 07/15/03 -- Created - */ - -#include -#include - -/* ftime (3) -- Obsolete BSD library function included in the SUS for copat. - * Also present in msvcrt.dll as _ftime - * See: http://www.opengroup.org/onlinepubs/007904957/functions/ftime.html */ -/* - * @implemented - */ -void _ftime( struct _timeb *tm ) -{ - int ret = 0; - SYSTEMTIME syst; - - GetSystemTime( &syst ); - - if( ret == 0 ) { - time( &tm->time ); - tm->millitm = syst.wMilliseconds; -// 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/posixrul.h b/reactos/lib/crt/time/posixrul.h deleted file mode 100644 index 48c5ceeab0d..00000000000 --- a/reactos/lib/crt/time/posixrul.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* generated with bin2h from DJGPP/zoneinfo/posixrules */ - -unsigned char _posixrules_data[] = { -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0, -0,1,16,0,0,0,2,0,0,0,8,0,151,254,240,1,135,225,224,2,119,224,240,3,112,254,96,4,96,253,112,5,80, -224,96,6,64,223,112,7,48,194,96,7,141,25,112,9,16,164,96,9,173,148,240,10,240,134,96,11,224,133,112,12,217,162, -224,13,192,103,112,14,185,132,224,15,169,131,240,16,153,102,224,17,137,101,240,18,121,72,224,19,105,71,240,20,89,42,224, -21,73,41,240,22,57,12,224,23,41,11,240,24,34,41,96,25,8,237,240,26,2,11,96,26,242,10,112,27,225,237,96,28, -209,236,112,29,193,207,96,30,177,206,112,31,161,177,96,32,118,0,240,33,129,147,96,34,85,226,240,35,106,175,224,36,53, -196,240,37,74,145,224,38,21,166,240,39,42,115,224,39,254,195,112,41,10,85,224,41,222,165,112,42,234,55,224,43,190,135, -112,44,211,84,96,45,158,105,112,46,179,54,96,47,126,75,112,48,147,24,96,49,103,103,240,50,114,250,96,51,71,73,240, -52,82,220,96,53,39,43,240,54,50,190,96,55,7,13,240,56,27,218,224,56,230,239,240,57,251,188,224,58,198,209,240,59, -219,158,224,60,175,238,112,61,187,128,224,62,143,208,112,63,155,98,224,64,111,178,112,65,132,127,96,66,79,148,112,67,100, -97,96,68,47,118,112,69,68,67,96,70,15,88,112,71,36,37,96,71,248,116,240,73,4,7,96,73,216,86,240,74,227,233, -96,75,184,56,240,76,205,5,224,77,152,26,240,78,172,231,224,79,119,252,240,80,140,201,224,81,97,25,112,82,108,171,224, -83,64,251,112,84,76,141,224,85,32,221,112,86,44,111,224,87,0,191,112,88,21,140,96,88,224,161,112,89,245,110,96,90, -192,131,112,91,213,80,96,92,169,159,240,93,181,50,96,94,137,129,240,95,149,20,96,96,105,99,240,97,126,48,224,98,73, -69,240,99,94,18,224,100,41,39,240,101,61,244,224,102,18,68,112,103,29,214,224,103,242,38,112,104,253,184,224,105,210,8, -112,106,221,154,224,107,177,234,112,108,198,183,96,109,145,204,112,110,166,153,96,111,113,174,112,112,134,123,96,113,90,202,240, -114,102,93,96,115,58,172,240,116,70,63,96,117,26,142,240,118,47,91,224,118,250,112,240,120,15,61,224,120,218,82,240,121, -239,31,224,122,186,52,240,123,207,1,224,124,163,81,112,125,174,227,224,126,131,51,112,127,142,197,224,128,99,21,112,129,119, -226,96,130,66,247,112,131,87,196,96,132,34,217,112,133,55,166,96,134,11,245,240,135,23,136,96,135,235,215,240,136,247,106, -96,137,203,185,240,138,215,76,96,139,171,155,240,140,192,104,224,141,139,125,240,142,160,74,224,143,107,95,240,144,128,44,224, -145,84,124,112,146,96,14,224,147,52,94,112,148,63,240,224,149,20,64,112,150,41,13,96,150,244,34,112,152,8,239,96,152, -212,4,112,153,232,209,96,154,189,32,240,155,200,179,96,156,157,2,240,157,168,149,96,158,124,228,240,159,136,119,96,160,92, -198,240,161,113,147,224,162,60,168,240,163,81,117,224,164,28,138,240,165,49,87,224,166,5,167,112,167,17,57,224,167,229,137, -112,168,241,27,224,169,197,107,112,170,218,56,96,171,165,77,112,172,186,26,96,173,133,47,112,174,153,252,96,175,101,17,112, -176,121,222,96,177,78,45,240,178,89,192,96,179,46,15,240,180,57,162,96,181,13,241,240,182,34,190,224,182,237,211,240,184, -2,160,224,184,205,181,240,185,226,130,224,186,182,210,112,187,194,100,224,188,150,180,112,189,162,70,224,190,118,150,112,191,130, -40,224,192,86,120,112,193,107,69,96,194,54,90,112,195,75,39,96,196,22,60,112,197,43,9,96,197,255,88,240,199,10,235, -96,199,223,58,240,200,234,205,96,201,191,28,240,202,211,233,224,203,158,254,240,204,179,203,224,205,126,224,240,206,147,173,224, -207,103,253,112,208,115,143,224,209,71,223,112,210,83,113,224,211,39,193,112,212,51,83,224,213,7,163,112,214,28,112,96,214, -231,133,112,215,252,82,96,216,199,103,112,217,220,52,96,218,176,131,240,219,188,22,96,220,144,101,240,221,155,248,96,222,112, -71,240,223,133,20,224,224,80,41,240,225,100,246,224,226,48,11,240,227,68,216,224,228,15,237,240,229,36,186,224,229,249,10, -112,231,4,156,224,231,216,236,112,232,228,126,224,233,184,206,112,234,205,155,96,235,152,176,112,236,173,125,96,237,120,146,112, -238,141,95,96,239,97,174,240,240,109,65,96,241,65,144,240,242,77,35,96,243,33,114,240,244,45,5,96,245,1,84,240,246, -22,33,224,246,225,54,240,247,246,3,224,248,193,24,240,249,213,229,224,250,160,250,240,251,181,199,224,252,138,23,112,253,149, -169,224,254,105,249,112,255,117,139,224,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, -1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, -1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, -1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, -1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,255,255,199,192,1,0,255,255,185,176,0,4,69,68,84, -0,69,83,84,0,0,0 -}; diff --git a/reactos/lib/crt/time/strdate.c b/reactos/lib/crt/time/strdate.c deleted file mode 100644 index fc03ad9ec05..00000000000 --- a/reactos/lib/crt/time/strdate.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/time/strtime.c - * PURPOSE: Fills a buffer with a formatted date representation - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ -#include - -/* - * @implemented - */ -char* _strdate(char* datestr) -{ - time_t t; - struct tm* d; - char* dt = (char*)datestr; - - if (datestr == NULL) { - __set_errno(EINVAL); - return NULL; - } - t = time(NULL); - d = localtime(&t); - sprintf(dt,"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year); - return dt; -} diff --git a/reactos/lib/crt/time/strftime.c b/reactos/lib/crt/time/strftime.c deleted file mode 100644 index c45ad2c52f8..00000000000 --- a/reactos/lib/crt/time/strftime.c +++ /dev/null @@ -1,260 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include - -#define TM_YEAR_BASE 1900 - -static const char *afmt[] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", -}; -static const char *Afmt[] = { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", - "Saturday", -}; -static const char *bfmt[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", - "Oct", "Nov", "Dec", -}; -static const char *Bfmt[] = { - "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December", -}; - -static size_t gsize; -static char *pt; - - -static int _add(const char* str) -{ - for (;; ++pt, --gsize) - { - if (!gsize) - return 0; - if (!(*pt = *str++)) - return 1; - } -} - -static int _conv(int n, int digits, char pad) -{ - static char buf[10]; - char *p; - - for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) - *p-- = n % 10 + '0'; - while (p > buf && digits-- > 0) - *p-- = pad; - return _add(++p); -} - -static size_t _fmt(const char* format, const struct tm* t) -{ - for (; *format; ++format) - { - if (*format == '%') { - if (*(format+1) == '#' ) {format++;} - - switch(*++format) { - case '\0': - --format; - break; - case 'A': - if (t->tm_wday < 0 || t->tm_wday > 6) - return 0; - if (!_add(Afmt[t->tm_wday])) - return 0; - continue; - case 'a': - if (t->tm_wday < 0 || t->tm_wday > 6) - return 0; - if (!_add(afmt[t->tm_wday])) - return 0; - continue; - case 'B': - if (t->tm_mon < 0 || t->tm_mon > 11) - return 0; - if (!_add(Bfmt[t->tm_mon])) - return 0; - continue; - case 'b': - case 'h': - if (t->tm_mon < 0 || t->tm_mon > 11) - return 0; - if (!_add(bfmt[t->tm_mon])) - return 0; - continue; - case 'C': - if (!_fmt("%a %b %e %H:%M:%S %Y", t)) - return 0; - continue; - case 'c': - if (!_fmt("%m/%d/%y %H:%M:%S", t)) - return 0; - continue; - case 'e': - if (!_conv(t->tm_mday, 2, ' ')) - return 0; - continue; - case 'D': - if (!_fmt("%m/%d/%y", t)) - return 0; - continue; - case 'd': - if (!_conv(t->tm_mday, 2, '0')) - return 0; - continue; - case 'H': - if (!_conv(t->tm_hour, 2, '0')) - return 0; - continue; - case 'I': - if (!_conv(t->tm_hour % 12 ? t->tm_hour % 12 : 12, 2, '0')) - return 0; - continue; - case 'j': - if (!_conv(t->tm_yday + 1, 3, '0')) - return 0; - continue; - case 'k': - if (!_conv(t->tm_hour, 2, ' ')) - return 0; - continue; - case 'l': - if (!_conv(t->tm_hour % 12 ? t->tm_hour % 12 : 12, 2, ' ')) - return 0; - continue; - case 'M': - if (!_conv(t->tm_min, 2, '0')) - return 0; - continue; - case 'm': - if (!_conv(t->tm_mon + 1, 2, '0')) - return 0; - continue; - case 'n': - if (!_add("\n")) - return 0; - continue; - case 'p': - if (!_add(t->tm_hour >= 12 ? "PM" : "AM")) - return 0; - continue; - case 'R': - if (!_fmt("%H:%M", t)) - return 0; - continue; - case 'r': - if (!_fmt("%I:%M:%S %p", t)) - return 0; - continue; - case 'S': - if (!_conv(t->tm_sec, 2, '0')) - return 0; - continue; - case 'T': - case 'X': - if (!_fmt("%H:%M:%S", t)) - return 0; - continue; - case 't': - if (!_add("\t")) - return 0; - continue; - case 'U': - if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7, 2, '0')) - return 0; - continue; - case 'W': - if (!_conv((t->tm_yday + 7 - (t->tm_wday ? (t->tm_wday - 1) : 6)) / 7, 2, '0')) - return 0; - continue; - case 'w': - if (!_conv(t->tm_wday, 1, '0')) - return 0; - continue; - case 'x': - if (!_fmt("%m/%d/%y", t)) - return 0; - continue; - case 'y': - if (!_conv((t->tm_year + TM_YEAR_BASE) % 100, 2, '0')) - return 0; - continue; - case 'Y': - if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0')) - 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 '%': - /* - * X311J/88-090 (4.12.3.5): if conversion char is - * undefined, behavior is undefined. Print out the - * character itself as printf(3) does. - */ - default: - break; - } - } - if (!gsize--) - return 0; - *pt++ = *format; - } - return gsize; -} - -/* - * @implemented - */ -size_t -strftime(char *s, size_t maxsize, const char *format, const struct tm *t) -{ - pt = s; - if ((gsize = maxsize) < 1) - return 0; - if (_fmt(format, t)) - { - *pt = '\0'; - return maxsize - gsize; - } - return 0; -} - -/* - * @implemented - */ -size_t wcsftime(wchar_t* s, size_t maxsize, const wchar_t* format, const struct tm* t) -{ - char *x; - char *f; - size_t i,j; - x = malloc(maxsize); - j = wcslen(format); - f = malloc(j+1); - for(i=0;i - -/* - * @implemented - */ -char* _strtime(char* buf) -{ - time_t t; - struct tm *d; - char* dt = (char*)buf; - - if ( buf == NULL ) { - __set_errno(EINVAL); - return NULL; - } - t = time(NULL); - d = localtime(&t); - sprintf(dt,"%d:%d:%d",d->tm_hour,d->tm_min,d->tm_sec); - return dt; -} diff --git a/reactos/lib/crt/time/time.c b/reactos/lib/crt/time/time.c deleted file mode 100644 index 796efb6c530..00000000000 --- a/reactos/lib/crt/time/time.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/time/time.c - * PURPOSE: Get system time - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ -/* - * DOS file system functions - * - * Copyright 1993 Erik Bos - * Copyright 1996 Alexandre Julliard - */ - -#include - -VOID STDCALL GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime); - -/* - * @implemented - */ -time_t time(time_t* t) -{ - FILETIME SystemTime; - DWORD Remainder; - time_t tt; - GetSystemTimeAsFileTime(&SystemTime); - tt = FileTimeToUnixTime(&SystemTime,&Remainder); - if (t) - *t = tt; - return tt; -} - -/*********************************************************************** - * DOSFS_UnixTimeToFileTime - * - * Convert a Unix time to FILETIME format. - * The FILETIME structure is a 64-bit value representing the number of - * 100-nanosecond intervals since January 1, 1601, 0:00. - * 'remainder' is the nonnegative number of 100-ns intervals - * corresponding to the time fraction smaller than 1 second that - * couldn't be stored in the time_t value. - */ -void UnixTimeToFileTime( time_t unix_time, FILETIME *filetime, - DWORD remainder ) -{ - /* NOTES: - - CONSTANTS: - The time difference between 1 January 1601, 00:00:00 and - 1 January 1970, 00:00:00 is 369 years, plus the leap years - from 1604 to 1968, excluding 1700, 1800, 1900. - This makes (1968 - 1600) / 4 - 3 = 89 leap days, and a total - of 134774 days. - - Any day in that period had 24 * 60 * 60 = 86400 seconds. - - The time difference is 134774 * 86400 * 10000000, which can be written - 116444736000000000 - 27111902 * 2^32 + 3577643008 - 413 * 2^48 + 45534 * 2^32 + 54590 * 2^16 + 32768 - - If you find that these constants are buggy, please change them in all - instances in both conversion functions. - - VERSIONS: - There are two versions, one of them uses long long variables and - is presumably faster but not ISO C. The other one uses standard C - data types and operations but relies on the assumption that negative - numbers are stored as 2's complement (-1 is 0xffff....). If this - assumption is violated, dates before 1970 will not convert correctly. - This should however work on any reasonable architecture where WINE - will run. - - DETAILS: - - Take care not to remove the casts. I have tested these functions - (in both versions) for a lot of numbers. I would be interested in - results on other compilers than GCC. - - The operations have been designed to account for the possibility - of 64-bit time_t in future UNICES. Even the versions without - internal long long numbers will work if time_t only is 64 bit. - A 32-bit shift, which was necessary for that operation, turned out - not to work correctly in GCC, besides giving the warning. So I - used a double 16-bit shift instead. Numbers are in the ISO version - represented by three limbs, the most significant with 32 bit, the - other two with 16 bit each. - - As the modulo-operator % is not well-defined for negative numbers, - negative divisors have been avoided in DOSFS_FileTimeToUnixTime. - - There might be quicker ways to do this in C. Certainly so in - assembler. - - Claus Fischer, fischer@iue.tuwien.ac.at - */ - - - - - unsigned long a0; /* 16 bit, low bits */ - unsigned long a1; /* 16 bit, medium bits */ - unsigned long a2; /* 32 bit, high bits */ - - /* Copy the unix time to a2/a1/a0 */ - a0 = unix_time & 0xffff; - a1 = (unix_time >> 16) & 0xffff; - /* This is obsolete if unix_time is only 32 bits, but it does not hurt. - Do not replace this by >> 32, it gives a compiler warning and it does - not work. */ - a2 = (unix_time >= 0 ? (unix_time >> 16) >> 16 : - ~((~unix_time >> 16) >> 16)); - - /* Multiply a by 10000000 (a = a2/a1/a0) - Split the factor into 10000 * 1000 which are both less than 0xffff. */ - a0 *= 10000; - a1 = a1 * 10000 + (a0 >> 16); - a2 = a2 * 10000 + (a1 >> 16); - a0 &= 0xffff; - a1 &= 0xffff; - - a0 *= 1000; - a1 = a1 * 1000 + (a0 >> 16); - a2 = a2 * 1000 + (a1 >> 16); - a0 &= 0xffff; - a1 &= 0xffff; - - /* Add the time difference and the remainder */ - a0 += 32768 + (remainder & 0xffff); - a1 += 54590 + (remainder >> 16 ) + (a0 >> 16); - a2 += 27111902 + (a1 >> 16); - a0 &= 0xffff; - a1 &= 0xffff; - - /* Set filetime */ - filetime->dwLowDateTime = (a1 << 16) + a0; - filetime->dwHighDateTime = a2; -} - - -/*********************************************************************** - * DOSFS_FileTimeToUnixTime - * - * Convert a FILETIME format to Unix time. - * If not NULL, 'remainder' contains the fractional part of the filetime, - * in the range of [0..9999999] (even if time_t is negative). - */ -time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder ) -{ - /* Read the comment in the function DOSFS_UnixTimeToFileTime. */ - - unsigned long a0; /* 16 bit, low bits */ - unsigned long a1; /* 16 bit, medium bits */ - unsigned long a2; /* 32 bit, high bits */ - unsigned long r; /* remainder of division */ - unsigned int carry; /* carry bit for subtraction */ - int negative; /* whether a represents a negative value */ - - /* Copy the time values to a2/a1/a0 */ - a2 = (unsigned long)filetime->dwHighDateTime; - a1 = ((unsigned long)filetime->dwLowDateTime ) >> 16; - a0 = ((unsigned long)filetime->dwLowDateTime ) & 0xffff; - - /* Subtract the time difference */ - if (a0 >= 32768 ) a0 -= 32768 , carry = 0; - else a0 += (1 << 16) - 32768 , carry = 1; - - if (a1 >= 54590 + carry) a1 -= 54590 + carry, carry = 0; - else a1 += (1 << 16) - 54590 - carry, carry = 1; - - a2 -= 27111902 + carry; - - /* If a is negative, replace a by (-1-a) */ - negative = (a2 >= ((unsigned long)1) << 31); - if (negative) - { - /* Set a to -a - 1 (a is a2/a1/a0) */ - a0 = 0xffff - a0; - a1 = 0xffff - a1; - a2 = ~a2; - } - - /* Divide a by 10000000 (a = a2/a1/a0), put the rest into r. - Split the divisor into 10000 * 1000 which are both less than 0xffff. */ - a1 += (a2 % 10000) << 16; - a2 /= 10000; - a0 += (a1 % 10000) << 16; - a1 /= 10000; - r = a0 % 10000; - a0 /= 10000; - - a1 += (a2 % 1000) << 16; - a2 /= 1000; - a0 += (a1 % 1000) << 16; - a1 /= 1000; - r += (a0 % 1000) * 10000; - a0 /= 1000; - - /* If a was negative, replace a by (-1-a) and r by (9999999 - r) */ - if (negative) - { - /* Set a to -a - 1 (a is a2/a1/a0) */ - a0 = 0xffff - a0; - a1 = 0xffff - a1; - a2 = ~a2; - - r = 9999999 - r; - } - - if (remainder) *remainder = r; - - /* Do not replace this by << 32, it gives a compiler warning and it does - not work. */ - return ((((time_t)a2) << 16) << 16) + (a1 << 16) + a0; - -} - - - diff --git a/reactos/lib/crt/time/tz_vars.c b/reactos/lib/crt/time/tz_vars.c deleted file mode 100644 index 05af8a4d1f4..00000000000 --- a/reactos/lib/crt/time/tz_vars.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - - -int _daylight; -int _timezone; - - -void _set_daylight_export(int value) -{ - _daylight = value; -} - -void _set_timezone_export(int value) -{ - _timezone = 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/tzfile.h b/reactos/lib/crt/time/tzfile.h deleted file mode 100644 index 3999029adb9..00000000000 --- a/reactos/lib/crt/time/tzfile.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#ifndef __dj_include_tzfile_h__ -#define __dj_include_tzfile_h__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __dj_ENFORCE_ANSI_FREESTANDING - -#ifndef __STRICT_ANSI__ - -#ifndef _POSIX_SOURCE - -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Arthur David Olson of the National Cancer Institute. - * - * Redistribution and use in source and binary forms are permitted provided - * that: (1) source distributions retain this entire copyright notice and - * comment, and (2) distributions including binaries display the following - * acknowledgement: ``This product includes software developed by the - * University of California, Berkeley and its contributors'' in the - * documentation or other materials provided with the distribution and in - * all advertising materials mentioning features or use of this software. - * Neither the name of the University nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)tzfile.h 5.9 (Berkeley) 6/11/90 - */ - -/* -** Information about time zone files. -*/ - - /* Time zone object file directory */ -#define TZDIR "/usr/share/zoneinfo" -#define TZDEFAULT "/etc/localtime" -#define TZDEFRULES "posixrules" - -/* -** Each file begins with. . . -*/ - -struct tzhead { - char tzh_reserved[24]; /* reserved for future use */ - char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ - char tzh_leapcnt[4]; /* coded number of leap seconds */ - char tzh_timecnt[4]; /* coded number of transition times */ - char tzh_typecnt[4]; /* coded number of local time types */ - char tzh_charcnt[4]; /* coded number of abbr. chars */ -}; - -/* -** . . .followed by. . . -** -** tzh_timecnt (char [4])s coded transition times a la time(2) -** tzh_timecnt (unsigned char)s types of local time starting at above -** tzh_typecnt repetitions of -** one (char [4]) coded GMT offset in seconds -** one (unsigned char) used to set tm_isdst -** one (unsigned char) that's an abbreviation list index -** tzh_charcnt (char)s '\0'-terminated zone abbreviations -** tzh_leapcnt repetitions of -** one (char [4]) coded leap second transition times -** one (char [4]) total correction after above -** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition -** time is standard time, if FALSE, -** transition time is wall clock time -** if absent, transition times are -** assumed to be wall clock time -*/ - -/* -** In the current implementation, "tzset()" refuses to deal with files that -** exceed any of the limits below. -*/ - -/* -** The TZ_MAX_TIMES value below is enough to handle a bit more than a -** year's worth of solar time (corrected daily to the nearest second) or -** 138 years of Pacific Presidential Election time -** (where there are three time zone transitions every fourth year). -*/ -#define TZ_MAX_TIMES 370 - -#define NOSOLAR /* 4BSD doesn't currently handle solar time */ - -#ifndef NOSOLAR -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ -#else -#define TZ_MAX_TYPES 10 /* Maximum number of local time types */ -#endif - -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ - -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ - -#define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define DAYSPERWEEK 7 -#define DAYSPERNYEAR 365 -#define DAYSPERLYEAR 366 -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) -#define MONSPERYEAR 12 - -#define TM_SUNDAY 0 -#define TM_MONDAY 1 -#define TM_TUESDAY 2 -#define TM_WEDNESDAY 3 -#define TM_THURSDAY 4 -#define TM_FRIDAY 5 -#define TM_SATURDAY 6 - -#define TM_JANUARY 0 -#define TM_FEBRUARY 1 -#define TM_MARCH 2 -#define TM_APRIL 3 -#define TM_MAY 4 -#define TM_JUNE 5 -#define TM_JULY 6 -#define TM_AUGUST 7 -#define TM_SEPTEMBER 8 -#define TM_OCTOBER 9 -#define TM_NOVEMBER 10 -#define TM_DECEMBER 11 - -#define TM_YEAR_BASE 1900 - -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY TM_THURSDAY - -/* -** Accurate only for the past couple of centuries; -** that will probably do. -*/ - -#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) - -#endif /* !_POSIX_SOURCE */ -#endif /* !__STRICT_ANSI__ */ -#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ - -#ifndef __dj_ENFORCE_FUNCTION_CALLS -#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ - -#ifdef __cplusplus -} -#endif - -#endif /* __dj_include_tzfile_h__ */ diff --git a/reactos/lib/crt/time/wctime.c b/reactos/lib/crt/time/wctime.c deleted file mode 100644 index bb843508b31..00000000000 --- a/reactos/lib/crt/time/wctime.c +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* This file has been modified by DJ Delorie. These modifications are -** Copyright (C) 1995 DJ Delorie, 24 Kirsten Ave, Rochester NH, -** 03867-2954, USA. -*/ - -/* - * Copyright (c) 1987, 1989 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Arthur David Olson of the National Cancer Institute. - * - * Redistribution and use in source and binary forms are permitted provided - * that: (1) source distributions retain this entire copyright notice and - * comment, and (2) distributions including binaries display the following - * acknowledgement: ``This product includes software developed by the - * University of California, Berkeley and its contributors'' in the - * documentation or other materials provided with the distribution and in - * all advertising materials mentioning features or use of this software. - * Neither the name of the University nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include -#include "tzfile.h" - -/* - * @implemented - */ -wchar_t* _wasctime(const struct tm* timeptr) -{ -#ifdef __GNUC__ - static const wchar_t wday_name[DAYSPERWEEK][3] = { - L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat" - }; - static const wchar_t mon_name[MONSPERYEAR][3] = { - L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", - L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" - }; -#else - static const wchar_t wday_name[DAYSPERWEEK][4] = { - L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat" - }; - static const wchar_t mon_name[MONSPERYEAR][4] = { - L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", - L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" - }; -#endif - static wchar_t result[26]; - - (void)swprintf(result, L"%.3s %.3s%3d %02d:%02d:%02d %d\n", - wday_name[timeptr->tm_wday], - mon_name[timeptr->tm_mon], - timeptr->tm_mday, timeptr->tm_hour, - timeptr->tm_min, timeptr->tm_sec, - TM_YEAR_BASE + timeptr->tm_year); - return result; -} - - -/* - * @implemented - */ -wchar_t* _wctime(const time_t* const timep) -{ - return _wasctime(localtime(timep)); -} diff --git a/reactos/lib/crt/time/wstrdate.c b/reactos/lib/crt/time/wstrdate.c deleted file mode 100644 index 559385b7c5b..00000000000 --- a/reactos/lib/crt/time/wstrdate.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/time/strtime.c - * PURPOSE: Fills a buffer with a formatted date representation - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ -#include - -/* - * @implemented - */ -wchar_t* _wstrdate(wchar_t* datestr) -{ - time_t t; - struct tm* d; - wchar_t* dt = (wchar_t*)datestr; - - if (datestr == NULL) { - __set_errno(EINVAL); - return NULL; - } - t = time(NULL); - d = localtime(&t); - swprintf(dt,L"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year); - return dt; -} diff --git a/reactos/lib/crt/time/wstrtime.c b/reactos/lib/crt/time/wstrtime.c deleted file mode 100644 index fc78a593242..00000000000 --- a/reactos/lib/crt/time/wstrtime.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/msvcrt/time/strtime.c - * PURPOSE: Fills a buffer with a formatted time representation - * PROGRAMER: Ariadne - * UPDATE HISTORY: - * 28/12/98: Created - */ -#include - -/* - * @implemented - */ -wchar_t* _wstrtime(wchar_t* buf) -{ - time_t t; - struct tm* d; - wchar_t* dt = (wchar_t*)buf; - - if ( buf == NULL ) { - __set_errno(EINVAL); - return NULL; - } - t = time(NULL); - d = localtime(&t); - swprintf(dt,L"%d:%d:%d",d->tm_hour,d->tm_min,d->tm_sec); - return dt; -} diff --git a/reactos/lib/crt/wine/cpp.c b/reactos/lib/crt/wine/cpp.c deleted file mode 100644 index 3939c19b3fd..00000000000 --- a/reactos/lib/crt/wine/cpp.c +++ /dev/null @@ -1,1250 +0,0 @@ -/* - * msvcrt.dll C++ objects - * - * Copyright 2000 Jon Griffiths - * Copyright 2003 Alexandre Julliard - * - * 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 "wine/config.h" -#include "wine/port.h" - -#include - -#include "windef.h" -#include "winbase.h" -#include "winreg.h" -#include "winternl.h" -#include "wine/exception.h" -#include "winnt.h" -#include "excpt.h" -#include "wine/debug.h" -#include -#include - -#include -#include -#include - -WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - -/* - * exception object: base for exception, bad_cast, bad_typeid, __non_rtti_object - */ -typedef struct -{ - void* pfn_vector_dtor; - void* pfn_what; -} exception_vtable; - -typedef struct __exception -{ - const exception_vtable *vtable; - char *name; /* Name of this exception, always a new copy for each object */ - int do_free; /* Whether to free 'name' in our dtor */ -} exception; - -typedef exception bad_cast; -typedef exception bad_typeid; -typedef exception __non_rtti_object; - -typedef struct _rtti_base_descriptor -{ - type_info *type_descriptor; - int num_base_classes; - int base_class_offset; - unsigned int flags; - int unknown1; - int unknown2; -} rtti_base_descriptor; - -typedef struct _rtti_base_array -{ - const rtti_base_descriptor *bases[3]; /* First element is the class itself */ -} rtti_base_array; - -typedef struct _rtti_object_hierachy -{ - int unknown1; - int unknown2; - int array_len; /* Size of the array pointed to by 'base_classes' */ - const rtti_base_array *base_classes; -} rtti_object_hierachy; - -typedef struct _rtti_object_locator -{ - int unknown1; - int base_class_offset; - unsigned int flags; - type_info *type_descriptor; - const rtti_object_hierachy *type_hierachy; -} rtti_object_locator; - - -#ifdef __i386__ /* thiscall functions are i386-specific */ - -#define DEFINE_THISCALL_WRAPPER0(func) \ - extern void __thiscall_ ## func(); \ - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ - "popl %eax\n\t" \ - "pushl %ecx\n\t" \ - "pushl %eax\n\t" \ - "jmp " __ASM_NAME(#func) "@4" ) -#define DEFINE_THISCALL_WRAPPER1(func) \ - extern void __thiscall_ ## func(); \ - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ - "popl %eax\n\t" \ - "pushl %ecx\n\t" \ - "pushl %eax\n\t" \ - "jmp " __ASM_NAME(#func) "@8" ) - -const exception_vtable MSVCRT_exception_vtable; -const exception_vtable MSVCRT_bad_typeid_vtable; -const exception_vtable MSVCRT_bad_cast_vtable; -const exception_vtable MSVCRT___non_rtti_object_vtable; -static const exception_vtable MSVCRT_type_info_vtable; - -/* Internal common ctor for exception */ -static void WINAPI EXCEPTION_ctor(exception *_this, const char** name) -{ - _this->vtable = &MSVCRT_exception_vtable; - if (*name) - { - size_t name_len = strlen(*name) + 1; - _this->name = MSVCRT_malloc(name_len); - memcpy(_this->name, *name, name_len); - _this->do_free = TRUE; - } - else - { - _this->name = NULL; - _this->do_free = FALSE; - } -} - -/****************************************************************** - * ??0exception@@QAE@ABQBD@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_ctor); -exception * __stdcall MSVCRT_exception_ctor(exception * _this, const char ** name) -{ - TRACE("(%p,%s)\n", _this, *name); - EXCEPTION_ctor(_this, name); - return _this; -} - -/****************************************************************** - * ??0exception@@QAE@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_copy_ctor); -exception * __stdcall MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs) -{ - TRACE("(%p,%p)\n", _this, rhs); - - if (!rhs->do_free) - { - _this->vtable = &MSVCRT_exception_vtable; - _this->name = rhs->name; - _this->do_free = FALSE; - } - else - EXCEPTION_ctor(_this, (const char**)&rhs->name); - TRACE("name = %s\n", _this->name); - return _this; -} - -/****************************************************************** - * ??0exception@@QAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_exception_default_ctor); -exception * __stdcall MSVCRT_exception_default_ctor(exception * _this) -{ - static const char* empty = NULL; - - TRACE("(%p)\n", _this); - EXCEPTION_ctor(_this, &empty); - return _this; -} - -/****************************************************************** - * ??1exception@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_exception_dtor); -void __stdcall MSVCRT_exception_dtor(exception * _this) -{ - TRACE("(%p)\n", _this); - _this->vtable = &MSVCRT_exception_vtable; - if (_this->do_free) MSVCRT_free(_this->name); -} - -/****************************************************************** - * ??4exception@@QAEAAV0@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_opequals); -exception * __stdcall MSVCRT_exception_opequals(exception * _this, const exception * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - if (_this != rhs) - { - MSVCRT_exception_dtor(_this); - MSVCRT_exception_copy_ctor(_this, rhs); - } - TRACE("name = %s\n", _this->name); - return _this; -} - -/****************************************************************** - * ??_Eexception@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_vector_dtor); -void * __stdcall MSVCRT_exception_vector_dtor(exception * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT_exception_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT_exception_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/****************************************************************** - * ??_Gexception@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_scalar_dtor); -void * __stdcall MSVCRT_exception_scalar_dtor(exception * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - MSVCRT_exception_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - return _this; -} - -/****************************************************************** - * ?what@exception@@UBEPBDXZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_what_exception); -const char * __stdcall MSVCRT_what_exception(exception * _this) -{ - TRACE("(%p) returning %s\n", _this, _this->name); - return _this->name ? _this->name : "Unknown exception"; -} - -/****************************************************************** - * ??0bad_typeid@@QAE@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_copy_ctor); -bad_typeid * __stdcall MSVCRT_bad_typeid_copy_ctor(bad_typeid * _this, const bad_typeid * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_exception_copy_ctor(_this, rhs); - _this->vtable = &MSVCRT_bad_typeid_vtable; - return _this; -} - -/****************************************************************** - * ??0bad_typeid@@QAE@PBD@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_ctor); -bad_typeid * __stdcall MSVCRT_bad_typeid_ctor(bad_typeid * _this, const char * name) -{ - TRACE("(%p %s)\n", _this, name); - EXCEPTION_ctor(_this, &name); - _this->vtable = &MSVCRT_bad_typeid_vtable; - return _this; -} - -/****************************************************************** - * ??1bad_typeid@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_bad_typeid_dtor); -void __stdcall MSVCRT_bad_typeid_dtor(bad_typeid * _this) -{ - TRACE("(%p)\n", _this); - MSVCRT_exception_dtor(_this); -} - -/****************************************************************** - * ??4bad_typeid@@QAEAAV0@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_opequals); -bad_typeid * __stdcall MSVCRT_bad_typeid_opequals(bad_typeid * _this, const bad_typeid * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_exception_opequals(_this, rhs); - return _this; -} - -/****************************************************************** - * ??_Ebad_typeid@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_vector_dtor); -void * __stdcall MSVCRT_bad_typeid_vector_dtor(bad_typeid * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT_bad_typeid_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT_bad_typeid_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/****************************************************************** - * ??_Gbad_typeid@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_scalar_dtor); -void * __stdcall MSVCRT_bad_typeid_scalar_dtor(bad_typeid * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - MSVCRT_bad_typeid_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - return _this; -} - -/****************************************************************** - * ??0__non_rtti_object@@QAE@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_copy_ctor); -__non_rtti_object * __stdcall MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object * _this, - const __non_rtti_object * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_bad_typeid_copy_ctor(_this, rhs); - _this->vtable = &MSVCRT___non_rtti_object_vtable; - return _this; -} - -/****************************************************************** - * ??0__non_rtti_object@@QAE@PBD@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_ctor); -__non_rtti_object * __stdcall MSVCRT___non_rtti_object_ctor(__non_rtti_object * _this, - const char * name) -{ - TRACE("(%p %s)\n", _this, name); - EXCEPTION_ctor(_this, &name); - _this->vtable = &MSVCRT___non_rtti_object_vtable; - return _this; -} - -/****************************************************************** - * ??1__non_rtti_object@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT___non_rtti_object_dtor); -void __stdcall MSVCRT___non_rtti_object_dtor(__non_rtti_object * _this) -{ - TRACE("(%p)\n", _this); - MSVCRT_bad_typeid_dtor(_this); -} - -/****************************************************************** - * ??4__non_rtti_object@@QAEAAV0@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_opequals); -__non_rtti_object * __stdcall MSVCRT___non_rtti_object_opequals(__non_rtti_object * _this, - const __non_rtti_object *rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_bad_typeid_opequals(_this, rhs); - return _this; -} - -/****************************************************************** - * ??_E__non_rtti_object@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_vector_dtor); -void * __stdcall MSVCRT___non_rtti_object_vector_dtor(__non_rtti_object * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT___non_rtti_object_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT___non_rtti_object_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/****************************************************************** - * ??_G__non_rtti_object@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_scalar_dtor); -void * __stdcall MSVCRT___non_rtti_object_scalar_dtor(__non_rtti_object * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - MSVCRT___non_rtti_object_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - return _this; -} - -/****************************************************************** - * ??0bad_cast@@QAE@ABQBD@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_ctor); -bad_cast * __stdcall MSVCRT_bad_cast_ctor(bad_cast * _this, const char ** name) -{ - TRACE("(%p %s)\n", _this, *name); - EXCEPTION_ctor(_this, name); - _this->vtable = &MSVCRT_bad_cast_vtable; - return _this; -} - -/****************************************************************** - * ??0bad_cast@@QAE@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_copy_ctor); -bad_cast * __stdcall MSVCRT_bad_cast_copy_ctor(bad_cast * _this, const bad_cast * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_exception_copy_ctor(_this, rhs); - _this->vtable = &MSVCRT_bad_cast_vtable; - return _this; -} - -/****************************************************************** - * ??1bad_cast@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_bad_cast_dtor); -void __stdcall MSVCRT_bad_cast_dtor(bad_cast * _this) -{ - TRACE("(%p)\n", _this); - MSVCRT_exception_dtor(_this); -} - -/****************************************************************** - * ??4bad_cast@@QAEAAV0@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_opequals); -bad_cast * __stdcall MSVCRT_bad_cast_opequals(bad_cast * _this, const bad_cast * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_exception_opequals(_this, rhs); - return _this; -} - -/****************************************************************** - * ??_Ebad_cast@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_vector_dtor); -void * __stdcall MSVCRT_bad_cast_vector_dtor(bad_cast * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT_bad_cast_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT_bad_cast_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/****************************************************************** - * ??_Gbad_cast@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_scalar_dtor); -void * __stdcall MSVCRT_bad_cast_scalar_dtor(bad_cast * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - MSVCRT_bad_cast_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - return _this; -} - -/****************************************************************** - * ??8type_info@@QBEHABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_type_info_opequals_equals); -int __stdcall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs) -{ - int ret = !strcmp(_this->mangled + 1, rhs->mangled + 1); - TRACE("(%p %p) returning %d\n", _this, rhs, ret); - return ret; -} - -/****************************************************************** - * ??9type_info@@QBEHABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_type_info_opnot_equals); -int __stdcall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs) -{ - int ret = !!strcmp(_this->mangled + 1, rhs->mangled + 1); - TRACE("(%p %p) returning %d\n", _this, rhs, ret); - return ret; -} - -/****************************************************************** - * ?before@type_info@@QBEHABV1@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_type_info_before); -int __stdcall MSVCRT_type_info_before(type_info * _this, const type_info * rhs) -{ - int ret = strcmp(_this->mangled + 1, rhs->mangled + 1) < 0; - TRACE("(%p %p) returning %d\n", _this, rhs, ret); - return ret; -} - -/****************************************************************** - * ??1type_info@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_type_info_dtor); -void __stdcall MSVCRT_type_info_dtor(type_info * _this) -{ - TRACE("(%p)\n", _this); - if (_this->name) - MSVCRT_free(_this->name); -} - -/****************************************************************** - * ?name@type_info@@QBEPBDXZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_type_info_name); -const char * __stdcall MSVCRT_type_info_name(type_info * _this) -{ - if (!_this->name) - { - /* Create and set the demangled name */ - /* Nota: mangled name in type_info struct always start with a '.', while - * it isn't valid for mangled name. - * Is this '.' really part of the mangled name, or has it some other meaning ? - */ - char* name = __unDName(0, _this->mangled + 1, 0, - MSVCRT_malloc, MSVCRT_free, 0x2800); - - if (name) - { - unsigned int len = strlen(name); - - /* It seems _unDName may leave blanks at the end of the demangled name */ - while (len && name[--len] == ' ') - name[len] = '\0'; - - _mlock(_EXIT_LOCK2); - - if (_this->name) - { - /* Another thread set this member since we checked above - use it */ - MSVCRT_free(name); - } - else - _this->name = name; - - _munlock(_EXIT_LOCK2); - } - } - TRACE("(%p) returning %s\n", _this, _this->name); - return _this->name; -} - -/****************************************************************** - * ?raw_name@type_info@@QBEPBDXZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_type_info_raw_name); -const char * __stdcall MSVCRT_type_info_raw_name(type_info * _this) -{ - TRACE("(%p) returning %s\n", _this, _this->mangled); - return _this->mangled; -} - -/* Unexported */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_type_info_vector_dtor); -void * __stdcall MSVCRT_type_info_vector_dtor(type_info * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT_type_info_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT_type_info_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/* vtables */ - -const exception_vtable MSVCRT_exception_vtable = -{ - __thiscall_MSVCRT_exception_vector_dtor, - __thiscall_MSVCRT_what_exception -}; - -const exception_vtable MSVCRT_bad_typeid_vtable = -{ - __thiscall_MSVCRT_bad_typeid_vector_dtor, - __thiscall_MSVCRT_what_exception -}; - -const exception_vtable MSVCRT_bad_cast_vtable = -{ - __thiscall_MSVCRT_bad_cast_vector_dtor, - __thiscall_MSVCRT_what_exception -}; - -const exception_vtable MSVCRT___non_rtti_object_vtable = -{ - __thiscall_MSVCRT___non_rtti_object_vector_dtor, - __thiscall_MSVCRT_what_exception -}; - -static const exception_vtable MSVCRT_type_info_vtable = -{ - __thiscall_MSVCRT_type_info_vector_dtor, - NULL -}; - -/* Static RTTI for exported objects */ - -static type_info exception_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AVexception@@" -}; - -static const rtti_base_descriptor exception_rtti_base_descriptor = -{ - &exception_type_info, - 0, - 0, - 0, - 0, - 0 -}; - -static const rtti_base_array exception_rtti_base_array = -{ - { - &exception_rtti_base_descriptor, - NULL, - NULL - } -}; - -static const rtti_object_hierachy exception_type_hierachy = -{ - 0, - 0, - 1, - &exception_rtti_base_array -}; - -static const rtti_object_locator exception_rtti = -{ - 0, - 0, - 0, - &exception_type_info, - &exception_type_hierachy -}; - -static const cxx_type_info exception_cxx_type_info = -{ - 0, - &exception_type_info, - 0, - -1, - 0, - sizeof(exception), - (cxx_copy_ctor)__thiscall_MSVCRT_exception_copy_ctor -}; - -static type_info bad_typeid_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AVbad_typeid@@" -}; - -static const rtti_base_descriptor bad_typeid_rtti_base_descriptor = -{ - &bad_typeid_type_info, - 1, - 0, - 0xffffffff, - 0, - 0 -}; - -static const rtti_base_array bad_typeid_rtti_base_array = -{ - { - &bad_typeid_rtti_base_descriptor, - &exception_rtti_base_descriptor, - NULL - } -}; - -static const rtti_object_hierachy bad_typeid_type_hierachy = -{ - 0, - 0, - 2, - &bad_typeid_rtti_base_array -}; - -static const rtti_object_locator bad_typeid_rtti = -{ - 0, - 0, - 0, - &bad_typeid_type_info, - &bad_typeid_type_hierachy -}; - -static const cxx_type_info bad_typeid_cxx_type_info = -{ - 0, - &bad_typeid_type_info, - 0, - -1, - 0, - sizeof(exception), - (cxx_copy_ctor)__thiscall_MSVCRT_bad_typeid_copy_ctor -}; - -static type_info bad_cast_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AVbad_cast@@" -}; - -static const rtti_base_descriptor bad_cast_rtti_base_descriptor = -{ - &bad_cast_type_info, - 1, - 0, - 0xffffffff, - 0, - 0 -}; - -static const rtti_base_array bad_cast_rtti_base_array = -{ - { - &bad_cast_rtti_base_descriptor, - &exception_rtti_base_descriptor, - NULL - } -}; - -static const rtti_object_hierachy bad_cast_type_hierachy = -{ - 0, - 0, - 2, - &bad_cast_rtti_base_array -}; - -static const rtti_object_locator bad_cast_rtti = -{ - 0, - 0, - 0, - &bad_cast_type_info, - &bad_cast_type_hierachy -}; - -static const cxx_type_info bad_cast_cxx_type_info = -{ - 0, - &bad_cast_type_info, - 0, - -1, - 0, - sizeof(exception), - (cxx_copy_ctor)__thiscall_MSVCRT_bad_cast_copy_ctor -}; - -static type_info __non_rtti_object_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AV__non_rtti_object@@" -}; - -static const rtti_base_descriptor __non_rtti_object_rtti_base_descriptor = -{ - &__non_rtti_object_type_info, - 2, - 0, - 0xffffffff, - 0, - 0 -}; - -static const rtti_base_array __non_rtti_object_rtti_base_array = -{ - { - &__non_rtti_object_rtti_base_descriptor, - &bad_typeid_rtti_base_descriptor, - &exception_rtti_base_descriptor - } -}; - -static const rtti_object_hierachy __non_rtti_object_type_hierachy = -{ - 0, - 0, - 3, - &__non_rtti_object_rtti_base_array -}; - -static const rtti_object_locator __non_rtti_object_rtti = -{ - 0, - 0, - 0, - &__non_rtti_object_type_info, - &__non_rtti_object_type_hierachy -}; - -static const cxx_type_info __non_rtti_object_cxx_type_info = -{ - 0, - &__non_rtti_object_type_info, - 0, - -1, - 0, - sizeof(exception), - (cxx_copy_ctor)__thiscall_MSVCRT___non_rtti_object_copy_ctor -}; - -static type_info type_info_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AVtype_info@@" -}; - -static const rtti_base_descriptor type_info_rtti_base_descriptor = -{ - &type_info_type_info, - 0, - 0, - 0xffffffff, - 0, - 0 -}; - -static const rtti_base_array type_info_rtti_base_array = -{ - { - &type_info_rtti_base_descriptor, - NULL, - NULL - } -}; - -static const rtti_object_hierachy type_info_type_hierachy = -{ - 0, - 0, - 1, - &type_info_rtti_base_array -}; - -static const rtti_object_locator type_info_rtti = -{ - 0, - 0, - 0, - &type_info_type_info, - &type_info_type_hierachy -}; - -/* - * Exception RTTI for cpp objects - */ -static const cxx_type_info_table bad_cast_type_info_table = -{ - 3, - { - &__non_rtti_object_cxx_type_info, - &bad_typeid_cxx_type_info, - &exception_cxx_type_info - } -}; - -static const cxx_exception_type bad_cast_exception_type = -{ - 0, - (void*)__thiscall_MSVCRT_bad_cast_dtor, - NULL, - &bad_cast_type_info_table -}; - -static const cxx_type_info_table bad_typeid_type_info_table = -{ - 2, - { - &bad_cast_cxx_type_info, - &exception_cxx_type_info, - NULL - } -}; - -static const cxx_exception_type bad_typeid_exception_type = -{ - 0, - (void*)__thiscall_MSVCRT_bad_typeid_dtor, - NULL, - &bad_cast_type_info_table -}; - -static const cxx_exception_type __non_rtti_object_exception_type = -{ - 0, - (void*)__thiscall_MSVCRT___non_rtti_object_dtor, - NULL, - &bad_typeid_type_info_table -}; - -#endif /* __i386__ */ - - -/****************************************************************** - * ?set_terminate@@YAP6AXXZP6AXXZ@Z (MSVCRT.@) - * - * Install a handler to be called when terminate() is called. - * - * PARAMS - * func [I] Handler function to install - * - * RETURNS - * The previously installed handler function, if any. - */ -terminate_function MSVCRT_set_terminate(terminate_function func) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - terminate_function previous = data->terminate_handler; - TRACE("(%p) returning %p\n",func,previous); - data->terminate_handler = func; - return previous; -} - -/****************************************************************** - * ?set_unexpected@@YAP6AXXZP6AXXZ@Z (MSVCRT.@) - * - * Install a handler to be called when unexpected() is called. - * - * PARAMS - * func [I] Handler function to install - * - * RETURNS - * The previously installed handler function, if any. - */ -unexpected_function MSVCRT_set_unexpected(unexpected_function func) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - unexpected_function previous = data->unexpected_handler; - TRACE("(%p) returning %p\n",func,previous); - data->unexpected_handler = func; - return previous; -} - -/****************************************************************** - * ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z (MSVCRT.@) - */ -_se_translator_function MSVCRT__set_se_translator(_se_translator_function func) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - _se_translator_function previous = data->se_translator; - TRACE("(%p) returning %p\n",func,previous); - data->se_translator = func; - return previous; -} - -/****************************************************************** - * ?terminate@@YAXXZ (MSVCRT.@) - * - * Default handler for an unhandled exception. - * - * PARAMS - * None. - * - * RETURNS - * This function does not return. Either control resumes from any - * handler installed by calling set_terminate(), or (by default) abort() - * is called. - */ -void MSVCRT_terminate(void) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - if (data->terminate_handler) data->terminate_handler(); - abort(); -} - -/****************************************************************** - * ?unexpected@@YAXXZ (MSVCRT.@) - */ -void MSVCRT_unexpected(void) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - if (data->unexpected_handler) data->unexpected_handler(); - MSVCRT_terminate(); -} - -/* Get type info from an object (internal) */ -static const rtti_object_locator* RTTI_GetObjectLocator(type_info *cppobj) -{ - const rtti_object_locator *obj_locator = NULL; - -#ifdef __i386__ - const exception_vtable* vtable = (const exception_vtable*)cppobj->vtable; - - /* Perhaps this is one of classes we export? */ - if (vtable == &MSVCRT_exception_vtable) - { - TRACE("returning exception_rtti\n"); - return &exception_rtti; - } - else if (vtable == &MSVCRT_bad_typeid_vtable) - { - TRACE("returning bad_typeid_rtti\n"); - return &bad_typeid_rtti; - } - else if (vtable == &MSVCRT_bad_cast_vtable) - { - TRACE("returning bad_cast_rtti\n"); - return &bad_cast_rtti; - } - else if (vtable == &MSVCRT___non_rtti_object_vtable) - { - TRACE("returning __non_rtti_object_rtti\n"); - return &__non_rtti_object_rtti; - } - else if (vtable == &MSVCRT_type_info_vtable) - { - TRACE("returning type_info_rtti\n"); - return &type_info_rtti; - } -#endif - - if (!IsBadReadPtr(cppobj, sizeof(void *)) && - !IsBadReadPtr(cppobj->vtable - 1,sizeof(void *)) && - !IsBadReadPtr((void*)cppobj->vtable[-1], sizeof(rtti_object_locator))) - { - obj_locator = (rtti_object_locator *)cppobj->vtable[-1]; - TRACE("returning type_info from vtable (%p)\n", obj_locator); - } - - return obj_locator; -} - -/****************************************************************** - * __RTtypeid (MSVCRT.@) - * - * Retrieve the Run Time Type Information (RTTI) for a C++ object. - * - * PARAMS - * cppobj [I] C++ object to get type information for. - * - * RETURNS - * Success: A type_info object describing cppobj. - * Failure: If the object to be cast has no RTTI, a __non_rtti_object - * exception is thrown. If cppobj is NULL, a bad_typeid exception - * is thrown. In either case, this function does not return. - * - * NOTES - * This function is usually called by compiler generated code as a result - * of using one of the C++ dynamic cast statements. - */ -type_info* MSVCRT___RTtypeid(type_info *cppobj) -{ - const rtti_object_locator *obj_locator = RTTI_GetObjectLocator(cppobj); - -#ifdef __i386__ - if (!obj_locator) - { - static const char* szNullPtr = "Attempted a typeid of NULL pointer!"; - static const char* szBadPtr = "Bad read pointer - no RTTI data!"; - const cxx_exception_type *e_type; - exception e; - - /* Throw a bad_typeid or __non_rtti_object exception */ - if (!cppobj) - { - EXCEPTION_ctor(&e, &szNullPtr); - e.vtable = &MSVCRT_bad_typeid_vtable; - e_type = &bad_typeid_exception_type; - } - else - { - EXCEPTION_ctor(&e, &szBadPtr); - e.vtable = &MSVCRT___non_rtti_object_vtable; - e_type = &__non_rtti_object_exception_type; - } - - _CxxThrowException(&e, e_type); - DebugBreak(); - } - return obj_locator->type_descriptor; -#else - return NULL; -#endif -} - -/****************************************************************** - * __RTDynamicCast (MSVCRT.@) - * - * Dynamically cast a C++ object to one of its base classes. - * - * PARAMS - * cppobj [I] Any C++ object to cast - * unknown [I] Reserved, set to 0 - * src [I] type_info object describing cppobj - * dst [I] type_info object describing the base class to cast to - * do_throw [I] TRUE = throw an exception if the cast fails, FALSE = don't - * - * RETURNS - * Success: The address of cppobj, cast to the object described by dst. - * Failure: NULL, If the object to be cast has no RTTI, or dst is not a - * valid cast for cppobj. If do_throw is TRUE, a bad_cast exception - * is thrown and this function does not return. - * - * NOTES - * This function is usually called by compiler generated code as a result - * of using one of the C++ dynamic cast statements. - */ -void* MSVCRT___RTDynamicCast(type_info *cppobj, int unknown, - type_info *src, type_info *dst, - int do_throw) -{ - const rtti_object_locator *obj_locator; - - /* Note: cppobj _isn't_ a type_info, we use that struct for its vtable ptr */ - TRACE("(%p,%d,%p,%p,%d)\n", cppobj, unknown, src, dst, do_throw); - if (!cppobj) - return 0; - obj_locator= RTTI_GetObjectLocator(cppobj); - if (unknown) - FIXME("Unknown parameter is non-zero: please report\n"); - - /* To cast an object at runtime: - * 1.Find out the true type of the object from the typeinfo at vtable[-1] - * 2.Search for the destination type in the class heirachy - * 3.If destination type is found, return base object address + dest offset - * Otherwise, fail the cast - */ - if (obj_locator) - { - int count = 0; - const rtti_object_hierachy *obj_bases = obj_locator->type_hierachy; - const rtti_base_descriptor* const *base_desc = obj_bases->base_classes->bases; - int src_offset = obj_locator->base_class_offset, dst_offset = -1; - - while (count < obj_bases->array_len) - { - const type_info *typ = (*base_desc)->type_descriptor; - - if (!strcmp(typ->mangled, dst->mangled)) - { - dst_offset = (*base_desc)->base_class_offset; - break; - } - base_desc++; - count++; - } - if (dst_offset >= 0) - return (void*)((unsigned long)cppobj - src_offset + dst_offset); - } - -#ifdef __i386__ - /* VC++ sets do_throw to 1 when the result of a dynamic_cast is assigned - * to a reference, since references cannot be NULL. - */ - if (do_throw) - { - static const char* exception_text = "Bad dynamic_cast!"; - exception e; - - /* Throw a bad_cast exception */ - EXCEPTION_ctor(&e, &exception_text); - e.vtable = &MSVCRT_bad_cast_vtable; - _CxxThrowException(&e, &bad_cast_exception_type); - DebugBreak(); - } -#endif - return NULL; -} - - -/****************************************************************** - * __RTCastToVoid (MSVCRT.@) - * - * Dynamically cast a C++ object to a void*. - * - * PARAMS - * cppobj [I] The C++ object to cast - * - * RETURNS - * Success: The base address of the object as a void*. - * Failure: NULL, if cppobj is NULL or has no RTTI. - * - * NOTES - * This function is usually called by compiler generated code as a result - * of using one of the C++ dynamic cast statements. - */ -void* MSVCRT___RTCastToVoid(type_info *cppobj) -{ - const rtti_object_locator *obj_locator = RTTI_GetObjectLocator(cppobj); - - /* Note: cppobj _isn't_ a type_info, we use that struct for its vtable ptr */ - TRACE("(%p)\n", cppobj); - - /* Casts to void* simply cast to the base object */ - if (obj_locator) - return (void*)((unsigned long)cppobj - obj_locator->base_class_offset); - return NULL; -} diff --git a/reactos/lib/crt/wine/cppexcept.c b/reactos/lib/crt/wine/cppexcept.c deleted file mode 100644 index ad35968ffd7..00000000000 --- a/reactos/lib/crt/wine/cppexcept.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * msvcrt C++ exception handling - * - * Copyright 2002 Alexandre Julliard - * - * 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 - * - * NOTES - * A good reference is the article "How a C++ compiler implements - * exception handling" by Vishal Kochhar, available on - * www.thecodeproject.com. - */ - -#include "wine/config.h" -#include "wine/port.h" - -#include - -#include "windef.h" -#include "winbase.h" -#include "winreg.h" -#include "winternl.h" -#include -#include "wine/exception.h" -#include "excpt.h" -#include "wine/debug.h" - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(seh); - -#ifdef __i386__ /* CxxFrameHandler is not supported on non-i386 */ - -static DWORD cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame, - PCONTEXT exc_context, EXCEPTION_REGISTRATION_RECORD** dispatch, - cxx_function_descr *descr, EXCEPTION_REGISTRATION_RECORD* nested_frame, - int nested_trylevel ); - -/* call a function with a given ebp */ -__inline static void *call_ebp_func( void *func, void *ebp ) -{ - void *ret; - __asm__ __volatile__ ("pushl %%ebp; movl %2,%%ebp; call *%%eax; popl %%ebp" \ - : "=a" (ret) : "0" (func), "g" (ebp) : "ecx", "edx", "memory" ); - return ret; -} - -/* call a copy constructor */ -__inline static void call_copy_ctor( void *func, void *this, void *src, int has_vbase ) -{ - TRACE( "calling copy ctor %p object %p src %p\n", func, this, src ); - if (has_vbase) - /* in that case copy ctor takes an extra bool indicating whether to copy the base class */ - __asm__ __volatile__("pushl $1; pushl %2; call *%0" - : : "r" (func), "c" (this), "g" (src) : "eax", "edx", "memory" ); - else - __asm__ __volatile__("pushl %2; call *%0" - : : "r" (func), "c" (this), "g" (src) : "eax", "edx", "memory" ); -} - -/* call the destructor of the exception object */ -__inline static void call_dtor( void *func, void *object ) -{ - __asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" ); -} - -static void dump_type( const cxx_type_info *type ) -{ - DPRINTF( "flags %x type %p", type->flags, type->type_info ); - if (type->type_info) DPRINTF( " (%p %s)", type->type_info->name, type->type_info->mangled ); - DPRINTF( " offset %d vbase %d,%d size %d copy ctor %p\n", type->this_offset, - type->vbase_descr, type->vbase_offset, type->size, type->copy_ctor ); -} - -static void dump_exception_type( const cxx_exception_type *type ) -{ - UINT i; - - DPRINTF( "exception type:\n" ); - DPRINTF( "flags %x destr %p handler %p type info %p\n", - type->flags, type->destructor, type->custom_handler, type->type_info_table ); - for (i = 0; i < type->type_info_table->count; i++) - { - DPRINTF( " %d: ", i ); - dump_type( type->type_info_table->info[i] ); - } -} - -static void dump_function_descr( const cxx_function_descr *descr, const cxx_exception_type *info ) -{ - UINT i; - int j; - - DPRINTF( "function descr:\n" ); - DPRINTF( "magic %x\n", descr->magic ); - DPRINTF( "unwind table: %p %d\n", descr->unwind_table, descr->unwind_count ); - for (i = 0; i < descr->unwind_count; i++) - { - DPRINTF( " %d: prev %d func %p\n", i, - descr->unwind_table[i].prev, descr->unwind_table[i].handler ); - } - DPRINTF( "try table: %p %d\n", descr->tryblock, descr->tryblock_count ); - for (i = 0; i < descr->tryblock_count; i++) - { - DPRINTF( " %d: start %d end %d catchlevel %d catch %p %d\n", i, - descr->tryblock[i].start_level, descr->tryblock[i].end_level, - descr->tryblock[i].catch_level, descr->tryblock[i].catchblock, - descr->tryblock[i].catchblock_count ); - for (j = 0; j < descr->tryblock[i].catchblock_count; j++) - { - catchblock_info *ptr = &descr->tryblock[i].catchblock[j]; - DPRINTF( " %d: flags %x offset %d handler %p type %p", - j, ptr->flags, ptr->offset, ptr->handler, ptr->type_info ); - if (ptr->type_info) DPRINTF( " (%p %s)", ptr->type_info->name, ptr->type_info->mangled ); - DPRINTF( "\n" ); - } - } -} - -/* compute the this pointer for a base class of a given type */ -static void *get_this_pointer( const cxx_type_info *type, void *object ) -{ - void *this_ptr; - int *offset_ptr; - - if (!object) return NULL; - this_ptr = (char *)object + type->this_offset; - if (type->vbase_descr >= 0) - { - /* move this ptr to vbase descriptor */ - this_ptr = (char *)this_ptr + type->vbase_descr; - /* and fetch additional offset from vbase descriptor */ - offset_ptr = (int *)(*(char **)this_ptr + type->vbase_offset); - this_ptr = (char *)this_ptr + *offset_ptr; - } - return this_ptr; -} - -/* check if the exception type is caught by a given catch block, and return the type that matched */ -static const cxx_type_info *find_caught_type( cxx_exception_type *exc_type, catchblock_info *catchblock ) -{ - UINT i; - - for (i = 0; i < exc_type->type_info_table->count; i++) - { - const cxx_type_info *type = exc_type->type_info_table->info[i]; - - if (!catchblock->type_info) return type; /* catch(...) matches any type */ - if (catchblock->type_info != type->type_info) - { - if (strcmp( catchblock->type_info->mangled, type->type_info->mangled )) continue; - } - /* type is the same, now check the flags */ - if ((exc_type->flags & TYPE_FLAG_CONST) && - !(catchblock->flags & TYPE_FLAG_CONST)) continue; - if ((exc_type->flags & TYPE_FLAG_VOLATILE) && - !(catchblock->flags & TYPE_FLAG_VOLATILE)) continue; - return type; /* it matched */ - } - return NULL; -} - - -/* copy the exception object where the catch block wants it */ -static void copy_exception( void *object, cxx_exception_frame *frame, - catchblock_info *catchblock, const cxx_type_info *type ) -{ - void **dest_ptr; - - if (!catchblock->type_info || !catchblock->type_info->mangled[0]) return; - if (!catchblock->offset) return; - dest_ptr = (void **)((char *)&frame->ebp + catchblock->offset); - - if (catchblock->flags & TYPE_FLAG_REFERENCE) - { - *dest_ptr = get_this_pointer( type, object ); - } - else if (type->flags & CLASS_IS_SIMPLE_TYPE) - { - memmove( dest_ptr, object, type->size ); - /* if it is a pointer, adjust it */ - if (type->size == sizeof(void *)) *dest_ptr = get_this_pointer( type, *dest_ptr ); - } - else /* copy the object */ - { - if (type->copy_ctor) - call_copy_ctor( type->copy_ctor, dest_ptr, get_this_pointer(type,object), - (type->flags & CLASS_HAS_VIRTUAL_BASE_CLASS) ); - else - memmove( dest_ptr, get_this_pointer(type,object), type->size ); - } -} - -/* unwind the local function up to a given trylevel */ -static void cxx_local_unwind( cxx_exception_frame* frame, cxx_function_descr *descr, int last_level) -{ - void (*handler)(); - int trylevel = frame->trylevel; - - while (trylevel != last_level) - { - if (trylevel < 0 || trylevel >= (int)descr->unwind_count) - { - ERR( "invalid trylevel %d\n", trylevel ); - MSVCRT_terminate(); - } - handler = descr->unwind_table[trylevel].handler; - if (handler) - { - TRACE( "calling unwind handler %p trylevel %d last %d ebp %p\n", - handler, trylevel, last_level, &frame->ebp ); - call_ebp_func( handler, &frame->ebp ); - } - trylevel = descr->unwind_table[trylevel].prev; - } - frame->trylevel = last_level; -} - -/* exception frame for nested exceptions in catch block */ -struct catch_func_nested_frame -{ - EXCEPTION_REGISTRATION_RECORD frame; /* standard exception frame */ - EXCEPTION_RECORD *prev_rec; /* previous record to restore in thread data */ - cxx_exception_frame *cxx_frame; /* frame of parent exception */ - cxx_function_descr *descr; /* descriptor of parent exception */ - int trylevel; /* current try level */ -}; - -/* handler for exceptions happening while calling a catch function */ -static DWORD catch_function_nested_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame, - CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher ) -{ - struct catch_func_nested_frame *nested_frame = (struct catch_func_nested_frame *)frame; - - if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) - { - msvcrt_get_thread_data()->exc_record = nested_frame->prev_rec; - return ExceptionContinueSearch; - } - else - { - TRACE( "got nested exception in catch function\n" ); - return cxx_frame_handler( rec, nested_frame->cxx_frame, context, - NULL, nested_frame->descr, &nested_frame->frame, - nested_frame->trylevel ); - } -} - -/* find and call the appropriate catch block for an exception */ -/* returns the address to continue execution to after the catch block was called */ -__inline static void *call_catch_block( PEXCEPTION_RECORD rec, cxx_exception_frame *frame, - cxx_function_descr *descr, int nested_trylevel, - cxx_exception_type *info ) -{ - UINT i; - int j; - void *addr, *object = (void *)rec->ExceptionInformation[1]; - struct catch_func_nested_frame nested_frame; - int trylevel = frame->trylevel; - MSVCRT_thread_data *thread_data = msvcrt_get_thread_data(); - - for (i = 0; i < descr->tryblock_count; i++) - { - tryblock_info *tryblock = &descr->tryblock[i]; - - if (trylevel < tryblock->start_level) continue; - if (trylevel > tryblock->end_level) continue; - - /* got a try block */ - for (j = 0; j < tryblock->catchblock_count; j++) - { - catchblock_info *catchblock = &tryblock->catchblock[j]; - const cxx_type_info *type = find_caught_type( info, catchblock ); - if (!type) continue; - - TRACE( "matched type %p in tryblock %d catchblock %d\n", type, i, j ); - - /* copy the exception to its destination on the stack */ - copy_exception( object, frame, catchblock, type ); - - /* unwind the stack */ - RtlUnwind( frame, 0, rec, 0 ); - cxx_local_unwind( frame, descr, tryblock->start_level ); - frame->trylevel = tryblock->end_level + 1; - - /* call the catch block */ - TRACE( "calling catch block %p for type %p addr %p ebp %p\n", - catchblock, type, catchblock->handler, &frame->ebp ); - - /* setup an exception block for nested exceptions */ - - //nested_frame.frame.Handler = catch_function_nested_handler; - nested_frame.frame.Handler = (PEXCEPTION_HANDLER)catch_function_nested_handler; - nested_frame.prev_rec = thread_data->exc_record; - nested_frame.cxx_frame = frame; - nested_frame.descr = descr; - nested_frame.trylevel = nested_trylevel + 1; - - __wine_push_frame( &nested_frame.frame ); - thread_data->exc_record = rec; - addr = call_ebp_func( catchblock->handler, &frame->ebp ); - thread_data->exc_record = nested_frame.prev_rec; - __wine_pop_frame( &nested_frame.frame ); - - if (info->destructor) call_dtor( info->destructor, object ); - TRACE( "done, continuing at %p\n", addr ); - return addr; - } - } - return NULL; -} - - -/********************************************************************* - * cxx_frame_handler - * - * Implementation of __CxxFrameHandler. - */ -static DWORD cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame, - PCONTEXT exc_context, EXCEPTION_REGISTRATION_RECORD** dispatch, - cxx_function_descr *descr, EXCEPTION_REGISTRATION_RECORD* nested_frame, - int nested_trylevel ) -{ - cxx_exception_type *exc_type; - void *next_ip; - PEXCEPTION_RECORD orig_rec = rec; - - if (descr->magic != CXX_FRAME_MAGIC) - { - ERR( "invalid frame magic %x\n", descr->magic ); - return ExceptionContinueSearch; - } - if (rec->ExceptionFlags & (EH_UNWINDING|EH_EXIT_UNWIND)) - { - if (descr->unwind_count && !nested_trylevel) cxx_local_unwind( frame, descr, -1 ); - return ExceptionContinueSearch; - } - if (!descr->tryblock_count) return ExceptionContinueSearch; - - exc_type = (cxx_exception_type *)rec->ExceptionInformation[2]; - if (rec->ExceptionCode == CXX_EXCEPTION && - rec->ExceptionInformation[0] > CXX_FRAME_MAGIC && - exc_type->custom_handler) - { - return exc_type->custom_handler( rec, frame, exc_context, dispatch, - descr, nested_trylevel, nested_frame, 0 ); - } - - if (!exc_type) /* nested exception, fetch info from original exception */ - { - rec = msvcrt_get_thread_data()->exc_record; - exc_type = (cxx_exception_type *)rec->ExceptionInformation[2]; - } - - if (TRACE_ON(seh)) - { - TRACE("handling C++ exception rec %p frame %p trylevel %d descr %p nested_frame %p\n", - rec, frame, frame->trylevel, descr, nested_frame ); - dump_exception_type( exc_type ); - dump_function_descr( descr, exc_type ); - } - - next_ip = call_catch_block( rec, frame, descr, frame->trylevel, exc_type ); - - if (!next_ip) return ExceptionContinueSearch; - orig_rec->ExceptionFlags &= ~EH_NONCONTINUABLE; - exc_context->Eip = (DWORD)next_ip; - exc_context->Ebp = (DWORD)&frame->ebp; - exc_context->Esp = ((DWORD*)frame)[-1]; - return ExceptionContinueExecution; -} - - -/********************************************************************* - * __CxxFrameHandler (MSVCRT.@) - */ -DWORD __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame, - PCONTEXT exc_context, EXCEPTION_REGISTRATION_RECORD** dispatch ) -{ - cxx_function_descr *descr; - - __asm__ __volatile__("mov %%eax, %0\n" : "=m"(descr)); - return cxx_frame_handler(rec, (cxx_exception_frame *)frame, - exc_context, dispatch, descr, NULL, 0 ); -} -#endif /* __i386__ */ - -/********************************************************************* - * _CxxThrowException (MSVCRT.@) - */ -void _CxxThrowException( void *object, const cxx_exception_type *type ) -{ - DWORD args[3]; - - args[0] = CXX_FRAME_MAGIC; - args[1] = (DWORD)object; - args[2] = (DWORD)type; - RaiseException( CXX_EXCEPTION, EH_NONCONTINUABLE, 3, args ); -} - -/********************************************************************* - * __CxxDetectRethrow (MSVCRT.@) - */ -BOOL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs) -{ - PEXCEPTION_RECORD rec; - - if (!ptrs) - return FALSE; - - rec = ptrs->ExceptionRecord; - - if (rec->ExceptionCode == CXX_EXCEPTION && - rec->NumberParameters == 3 && - rec->ExceptionInformation[0] == CXX_FRAME_MAGIC && - rec->ExceptionInformation[2]) - { - ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record; - return TRUE; - } - return (msvcrt_get_thread_data()->exc_record == rec); -} - -/********************************************************************* - * __CxxQueryExceptionSize (MSVCRT.@) - */ -unsigned int __CxxQueryExceptionSize(void) -{ - return sizeof(cxx_exception_type); -} diff --git a/reactos/lib/crt/wine/heap.c b/reactos/lib/crt/wine/heap.c deleted file mode 100644 index 80352ad5111..00000000000 --- a/reactos/lib/crt/wine/heap.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * msvcrt.dll heap functions - * - * Copyright 2000 Jon Griffiths - * - * 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 - * - * Note: Win32 heap operations are MT safe. We only lock the new - * handler and non atomic heap operations - */ - -#include - -#include -#include -#include - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - -/* MT */ -#define LOCK_HEAP _mlock( _HEAP_LOCK ) -#define UNLOCK_HEAP _munlock( _HEAP_LOCK ) - - -typedef void (*MSVCRT_new_handler_func)(unsigned long size); - -static MSVCRT_new_handler_func MSVCRT_new_handler; -static int MSVCRT_new_mode; - - -/********************************************************************* - * ??2@YAPAXI@Z (MSVCRT.@) - */ -void* MSVCRT_operator_new(unsigned long size) -{ - void *retval = malloc(size); - TRACE("(%ld) returning %p\n", size, retval); - LOCK_HEAP; - if(!retval && MSVCRT_new_handler) - (*MSVCRT_new_handler)(size); - UNLOCK_HEAP; - return retval; -} - -/********************************************************************* - * ??3@YAXPAX@Z (MSVCRT.@) - */ -void MSVCRT_operator_delete(void *mem) -{ - TRACE("(%p)\n", mem); - free(mem); -} - - -/********************************************************************* - * ?_query_new_handler@@YAP6AHI@ZXZ (MSVCRT.@) - */ -MSVCRT_new_handler_func MSVCRT__query_new_handler(void) -{ - return MSVCRT_new_handler; -} - - -/********************************************************************* - * ?_query_new_mode@@YAHXZ (MSVCRT.@) - */ -int MSVCRT__query_new_mode(void) -{ - return MSVCRT_new_mode; -} - -/********************************************************************* - * ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z (MSVCRT.@) - */ -MSVCRT_new_handler_func MSVCRT__set_new_handler(MSVCRT_new_handler_func func) -{ - MSVCRT_new_handler_func old_handler; - LOCK_HEAP; - old_handler = MSVCRT_new_handler; - MSVCRT_new_handler = func; - UNLOCK_HEAP; - return old_handler; -} - -/********************************************************************* - * ?set_new_handler@@YAP6AXXZP6AXXZ@Z (MSVCRT.@) - */ -MSVCRT_new_handler_func MSVCRT_set_new_handler(void *func) -{ - TRACE("(%p)\n",func); - MSVCRT__set_new_handler(NULL); - return NULL; -} - -/********************************************************************* - * ?_set_new_mode@@YAHH@Z (MSVCRT.@) - */ -int MSVCRT__set_new_mode(int mode) -{ - int old_mode; - LOCK_HEAP; - old_mode = MSVCRT_new_mode; - MSVCRT_new_mode = mode; - UNLOCK_HEAP; - return old_mode; -} - -/********************************************************************* - * _heapadd (MSVCRT.@) - */ -int _heapadd(void* mem, size_t size) -{ - TRACE("(%p,%d) unsupported in Win32\n", mem,size); - *_errno() = ENOSYS; - return -1; -} diff --git a/reactos/lib/crt/wine/scanf.c b/reactos/lib/crt/wine/scanf.c deleted file mode 100644 index ad71b074d28..00000000000 --- a/reactos/lib/crt/wine/scanf.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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 -#include - -#define NDEBUG -#include - -#define WARN DPRINT1 - -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 crt_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 deleted file mode 100644 index e73719a437c..00000000000 --- a/reactos/lib/crt/wine/scanf.h +++ /dev/null @@ -1,560 +0,0 @@ -/* - * 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_); - - FIXME: The above is the Wine version and it doesnt work in ros - when %n is at end of input string (return one too many). - But does it fail in Wine too?? If so wine also needs fixin. - -Gunnar - */ - - *n = consumed - 1; - } - /* This is an odd one: according to the standard, - * "Execution of a %n directive does not increment the - * assignment count returned at the completion of - * execution" even if it wasn't suppressed with the - * '*' flag. The Corrigendum to the standard seems - * to contradict this (comment out the assignment to - * suppress below if you want to implement these - * alternate semantics) but the windows program I'm - * looking at expects the behavior I've coded here - * (which happens to be what glibc does as well). - */ - suppress = 1; - st = 1; - } - 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 deleted file mode 100644 index d1574d69faa..00000000000 --- a/reactos/lib/crt/wine/thread.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * msvcrt.dll thread functions - * - * Copyright 2000 Jon Griffiths - * - * 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 - -#include -#include - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - -void _amsg_exit (int errnum); -/* Index to TLS */ -DWORD MSVCRT_tls_index; - -typedef void (*_beginthread_start_routine_t)(void *); -typedef unsigned int (__stdcall *_beginthreadex_start_routine_t)(void *); - -/********************************************************************/ - -typedef struct { - _beginthread_start_routine_t start_address; - void *arglist; -} _beginthread_trampoline_t; - -/********************************************************************* - * msvcrt_get_thread_data - * - * Return the thread local storage structure. - */ -MSVCRT_thread_data *msvcrt_get_thread_data(void) -{ - MSVCRT_thread_data *ptr; - DWORD err = GetLastError(); /* need to preserve last error */ - - if (!(ptr = TlsGetValue( MSVCRT_tls_index ))) - { - if (!(ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptr) ))) - _amsg_exit( _RT_THREAD ); - if (!TlsSetValue( MSVCRT_tls_index, ptr )) - _amsg_exit( _RT_THREAD ); - if (!TlsSetValue( MSVCRT_tls_index, ptr )) - _amsg_exit( _RT_THREAD ); - } - SetLastError( err ); - return ptr; -} - -/********************************************************************* - * _beginthread_trampoline - */ -static DWORD CALLBACK _beginthread_trampoline(LPVOID arg) -{ - _beginthread_trampoline_t local_trampoline; - - /* Maybe it's just being paranoid, but freeing arg right - * away seems safer. - */ - memcpy(&local_trampoline,arg,sizeof(local_trampoline)); - free(arg); - - local_trampoline.start_address(local_trampoline.arglist); - return 0; -} - -/********************************************************************* - * _beginthread (MSVCRT.@) - */ -unsigned long _beginthread( - _beginthread_start_routine_t start_address, /* [in] Start address of routine that begins execution of new thread */ - unsigned int stack_size, /* [in] Stack size for new thread or 0 */ - void *arglist) /* [in] Argument list to be passed to new thread or NULL */ -{ - _beginthread_trampoline_t* trampoline; - - TRACE("(%p, %d, %p)\n", start_address, stack_size, arglist); - - /* Allocate the trampoline here so that it is still valid when the thread - * starts... typically after this function has returned. - * _beginthread_trampoline is responsible for freeing the trampoline - */ - trampoline=malloc(sizeof(*trampoline)); - trampoline->start_address = start_address; - trampoline->arglist = arglist; - - /* FIXME */ - return (unsigned long)CreateThread(NULL, stack_size, _beginthread_trampoline, - trampoline, 0, NULL); -} diff --git a/reactos/lib/crt/wine/undname.c b/reactos/lib/crt/wine/undname.c deleted file mode 100755 index f3ad3b21e59..00000000000 --- a/reactos/lib/crt/wine/undname.c +++ /dev/null @@ -1,1219 +0,0 @@ -/* - * Demangle VC++ symbols into C function prototypes - * - * Copyright 2000 Jon Griffiths - * 2004 Eric Pouech - * - * 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 "wine/config.h" -#include "wine/port.h" - -#include - -#include "windef.h" -#include "winbase.h" -#include "winreg.h" -#include "winternl.h" -#include "wine/exception.h" -#include "winnt.h" -#include "excpt.h" -#include "wine/debug.h" -#include -#include - -#include -#include -#include - -WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - -/* TODO: - * - document a bit (grammar + fonctions) - * - back-port this new code into tools/winedump/msmangle.c - */ - -#define UNDNAME_COMPLETE (0x0000) -#define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) /* Don't show __ in calling convention */ -#define UNDNAME_NO_MS_KEYWORDS (0x0002) /* Don't show calling convention at all */ -#define UNDNAME_NO_FUNCTION_RETURNS (0x0004) /* Don't show function/method return value */ -#define UNDNAME_NO_ALLOCATION_MODEL (0x0008) -#define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010) -#define UNDNAME_NO_MS_THISTYPE (0x0020) -#define UNDNAME_NO_CV_THISTYPE (0x0040) -#define UNDNAME_NO_THISTYPE (0x0060) -#define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) /* Don't show access specifier (public/protected/private) */ -#define UNDNAME_NO_THROW_SIGNATURES (0x0100) -#define UNDNAME_NO_MEMBER_TYPE (0x0200) /* Don't show static/virtual specifier */ -#define UNDNAME_NO_RETURN_UDT_MODEL (0x0400) -#define UNDNAME_32_BIT_DECODE (0x0800) -#define UNDNAME_NAME_ONLY (0x1000) /* Only report the variable/method name */ -#define UNDNAME_NO_ARGUMENTS (0x2000) /* Don't show method arguments */ -#define UNDNAME_NO_SPECIAL_SYMS (0x4000) -#define UNDNAME_NO_COMPLEX_TYPE (0x8000) - -/* How data types modifiers are stored: - * M (in the following definitions) is defined for - * 'A', 'B', 'C' and 'D' as follows - * {}: "" - * {}: "const " - * {}: "volatile " - * {}: "const volatile " - * - * in arguments: - * Px {}x* - * Qx {}x* const - * Ax {}x& - * in data fields: - * same as for arguments and also the following - * ?x {}x - * - */ - -#define MAX_ARRAY_ELTS 32 -struct array -{ - unsigned start; /* first valid reference in array */ - unsigned num; /* total number of used elts */ - unsigned max; - char* elts[MAX_ARRAY_ELTS]; -}; - -/* Structure holding a parsed symbol */ -struct parsed_symbol -{ - unsigned flags; /* the UNDNAME_ flags used for demangling */ - malloc_func_t mem_alloc_ptr; /* internal allocator */ - free_func_t mem_free_ptr; /* internal deallocator */ - - const char* current; /* pointer in input (mangled) string */ - char* result; /* demangled string */ - - struct array stack; /* stack of parsed strings */ - - void* alloc_list; /* linked list of allocated blocks */ - unsigned avail_in_first; /* number of available bytes in head block */ -}; - -/* Type for parsing mangled types */ -struct datatype_t -{ - const char* left; - const char* right; -}; - -/****************************************************************** - * und_alloc - * - * Internal allocator. Uses a simple linked list of large blocks - * where we use a poor-man allocator. It's fast, and since all - * allocation is pool, memory management is easy (esp. freeing). - */ -static void* und_alloc(struct parsed_symbol* sym, size_t len) -{ - void* ptr; - -#define BLOCK_SIZE 1024 -#define AVAIL_SIZE (1024 - sizeof(void*)) - - if (len > AVAIL_SIZE) - { - /* allocate a specific block */ - ptr = sym->mem_alloc_ptr(sizeof(void*) + len); - if (!ptr) return NULL; - *(void**)ptr = sym->alloc_list; - sym->alloc_list = ptr; - sym->avail_in_first = 0; - ptr = (char*)sym->alloc_list + sizeof(void*); - } - else - { - if (len > sym->avail_in_first) - { - /* add a new block */ - ptr = sym->mem_alloc_ptr(BLOCK_SIZE); - if (!ptr) return NULL; - *(void**)ptr = sym->alloc_list; - sym->alloc_list = ptr; - sym->avail_in_first = AVAIL_SIZE; - } - /* grab memory from head block */ - ptr = (char*)sym->alloc_list + BLOCK_SIZE - sym->avail_in_first; - sym->avail_in_first -= len; - } - return ptr; -#undef BLOCK_SIZE -#undef AVAIL_SIZE -} - -/****************************************************************** - * und_free - * Frees all the blocks in the list of large blocks allocated by - * und_alloc. - */ -static void und_free_all(struct parsed_symbol* sym) -{ - void* next; - - while (sym->alloc_list) - { - next = *(void**)sym->alloc_list; - sym->mem_free_ptr(sym->alloc_list); - sym->alloc_list = next; - } - sym->avail_in_first = 0; -} - -/****************************************************************** - * str_array_init - * Initialises an array of strings - */ -static void str_array_init(struct array* a) -{ - a->start = a->num = a->max = 0; -} - -/****************************************************************** - * str_array_push - * Adding a new string to an array - */ -static void str_array_push(struct parsed_symbol* sym, const char* ptr, size_t len, - struct array* a) -{ - assert(ptr); - assert(a); - assert(a->num < MAX_ARRAY_ELTS); - if (len == -1) len = strlen(ptr); - a->elts[a->num] = und_alloc(sym, len + 1); - assert(a->elts[a->num]); - memcpy(a->elts[a->num], ptr, len); - a->elts[a->num][len] = '\0'; - if (++a->num >= a->max) a->max = a->num; - { - int i; - char c; - - for (i = a->max - 1; i >= 0; i--) - { - c = '>'; - if (i < a->start) c = '-'; - else if (i >= a->num) c = '}'; - TRACE("\t%d%c %s\n", i, c, a->elts[i]); - } - } -} - -/****************************************************************** - * str_array_get_ref - * Extracts a reference from an existing array (doing proper type - * checking) - */ -static char* str_array_get_ref(struct array* cref, unsigned idx) -{ - assert(cref); - if (cref->start + idx >= cref->max) - { - WARN("Out of bounds: %p %d + %d >= %d\n", - cref, cref->start, idx, cref->max); - return NULL; - } - TRACE("Returning %p[%d] => %s\n", - cref, idx, cref->elts[cref->start + idx]); - return cref->elts[cref->start + idx]; -} - -/****************************************************************** - * str_printf - * Helper for printf type of command (only %s and %c are implemented) - * while dynamically allocating the buffer - */ -static char* str_printf(struct parsed_symbol* sym, const char* format, ...) -{ - va_list args; - size_t len = 1, i, sz; - char* tmp; - char* p; - char* t; - - va_start(args, format); - for (i = 0; format[i]; i++) - { - if (format[i] == '%') - { - switch (format[++i]) - { - case 's': t = va_arg(args, char*); if (t) len += strlen(t); break; - case 'c': (void)va_arg(args, int); len++; break; - default: i--; /* fall thru */ - case '%': len++; break; - } - } - else len++; - } - va_end(args); - if (!(tmp = (char*)und_alloc(sym, len))) return NULL; - va_start(args, format); - for (p = tmp, i = 0; format[i]; i++) - { - if (format[i] == '%') - { - switch (format[++i]) - { - case 's': - t = va_arg(args, char*); - if (t) - { - sz = strlen(t); - memcpy(p, t, sz); - p += sz; - } - break; - case 'c': - *p++ = (char)va_arg(args, int); - break; - default: i--; /* fall thru */ - case '%': *p++ = '%'; break; - } - } - else *p++ = format[i]; - } - va_end(args); - *p = '\0'; - return tmp; -} - -/* forward declaration */ -static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct, - struct array* pmt, BOOL in_args); - -/****************************************************************** - * get_args - * Parses a list of function/method arguments, creates a string corresponding - * to the arguments' list. - */ -static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_term, - char open_char, char close_char) - -{ - struct datatype_t ct; - struct array arg_collect; - char* args_str = NULL; - int i; - - str_array_init(&arg_collect); - - /* Now come the function arguments */ - while (*sym->current) - { - /* Decode each data type and append it to the argument list */ - if (*sym->current == '@') - { - sym->current++; - break; - } - if (!demangle_datatype(sym, &ct, pmt_ref, TRUE)) - return NULL; - /* 'void' terminates an argument list */ - if (!strcmp(ct.left, "void")) - { - if (!z_term && *sym->current == '@') sym->current++; - break; - } - str_array_push(sym, str_printf(sym, "%s%s", ct.left, ct.right), -1, - &arg_collect); - if (!strcmp(ct.left, "...")) break; - } - /* Functions are always terminated by 'Z'. If we made it this far and - * don't find it, we have incorrectly identified a data type. - */ - if (z_term && *sym->current++ != 'Z') return NULL; - - if (arg_collect.num == 0 || - (arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void"))) - return str_printf(sym, "%cvoid%c", open_char, close_char); - for (i = 1; i < arg_collect.num; i++) - { - args_str = str_printf(sym, "%s,%s", args_str, arg_collect.elts[i]); - } - - if (close_char == '>' && args_str && args_str[strlen(args_str) - 1] == '>') - args_str = str_printf(sym, "%c%s%s %c", - open_char, arg_collect.elts[0], args_str, close_char); - else - args_str = str_printf(sym, "%c%s%s%c", - open_char, arg_collect.elts[0], args_str, close_char); - - return args_str; -} - -/****************************************************************** - * get_modifier - * Parses the type modifier. Always returns a static string - */ -static BOOL get_modifier(char ch, const char** ret) -{ - switch (ch) - { - case 'A': *ret = NULL; break; - case 'B': *ret = "const"; break; - case 'C': *ret = "volatile"; break; - case 'D': *ret = "const volatile"; break; - default: return FALSE; - } - return TRUE; -} - -static const char* get_modified_type(struct parsed_symbol* sym, char modif) -{ - const char* modifier; - const char* ret = NULL; - const char* str_modif; - - switch (modif) - { - case 'A': str_modif = " &"; break; - case 'P': str_modif = " *"; break; - case 'Q': str_modif = " * const"; break; - case '?': str_modif = ""; break; - default: return NULL; - } - - if (get_modifier(*sym->current++, &modifier)) - { - unsigned mark = sym->stack.num; - struct datatype_t sub_ct; - - /* Recurse to get the referred-to type */ - if (!demangle_datatype(sym, &sub_ct, NULL, FALSE)) - return NULL; - ret = str_printf(sym, "%s%s%s%s%s", - sub_ct.left, sub_ct.left && modifier ? " " : NULL, - modifier, sub_ct.right, str_modif); - sym->stack.num = mark; - } - return ret; -} - -/****************************************************************** - * get_class - * Parses class as a list of parent-classes, separated by '@', terminated by '@@' - * and stores the result in 'a' array. Each parent-classes, as well as the inner - * element (either field/method name or class name), are stored as allocated - * strings in the array. - */ -static BOOL get_class(struct parsed_symbol* sym) -{ - const char* ptr; - - while (*sym->current != '@') - { - switch (*sym->current) - { - case '\0': return FALSE; - - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - ptr = str_array_get_ref(&sym->stack, *sym->current++ - '0'); - if (!ptr) return FALSE; - str_array_push(sym, ptr, -1, &sym->stack); - break; - case '?': - if (*++sym->current == '$') - { - const char* name = ++sym->current; - char* full = NULL; - char* args = NULL; - unsigned num_mark = sym->stack.num; - unsigned start_mark = sym->stack.start; - - while (*sym->current++ != '@'); - - sym->stack.start = sym->stack.num; - str_array_push(sym, name, sym->current - name -1, &sym->stack); - args = get_args(sym, NULL, FALSE, '<', '>'); - if (args != NULL) - { - full = str_printf(sym, "%s%s", sym->stack.elts[num_mark], args); - } - if (!full) return FALSE; - sym->stack.elts[num_mark] = full; - sym->stack.num = num_mark + 1; - sym->stack.start = start_mark; - } - break; - default: - ptr = sym->current; - while (*sym->current++ != '@'); - str_array_push(sym, ptr, sym->current - 1 - ptr, &sym->stack); - break; - } - } - sym->current++; - return TRUE; -} - -/****************************************************************** - * get_class_string - * From an array collected by get_class, constructs the corresponding (allocated) - * string - */ -static char* get_class_string(struct parsed_symbol* sym, /*const struct array* a, */int start) -{ - int i; - size_t len, sz; - char* ret; - struct array *a = &sym->stack; - for (len = 0, i = start; i < a->num; i++) - { - assert(a->elts[i]); - len += 2 + strlen(a->elts[i]); - } - if (!(ret = und_alloc(sym, len - 1))) return NULL; - for (len = 0, i = a->num - 1; i >= start; i--) - { - sz = strlen(a->elts[i]); - memcpy(ret + len, a->elts[i], sz); - len += sz; - if (i > start) - { - ret[len++] = ':'; - ret[len++] = ':'; - } - } - ret[len] = '\0'; - return ret; -} - -/****************************************************************** - * get_calling_convention - * Returns a static string corresponding to the calling convention described - * by char 'ch'. Sets export to TRUE iff the calling convention is exported. - */ -static BOOL get_calling_convention(struct parsed_symbol* sym, char ch, - const char** call_conv, const char** exported, - unsigned flags) -{ - *call_conv = *exported = NULL; - - if (!(flags & (UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ALLOCATION_LANGUAGE))) - { - if (flags & UNDNAME_NO_LEADING_UNDERSCORES) - { - if (((ch - 'A') % 2) == 1) *exported = "dll_export "; - switch (ch) - { - case 'A': case 'B': *call_conv = "cdecl"; break; - case 'C': case 'D': *call_conv = "pascal"; break; - case 'E': case 'F': *call_conv = "thiscall"; break; - case 'G': case 'H': *call_conv = "stdcall"; break; - case 'I': case 'J': *call_conv = "fastcall"; break; - case 'K': break; - default: ERR("Unknown calling convention %c\n", ch); return FALSE; - } - } - else - { - if (((ch - 'A') % 2) == 1) *exported = "__dll_export "; - switch (ch) - { - case 'A': case 'B': *call_conv = "__cdecl"; break; - case 'C': case 'D': *call_conv = "__pascal"; break; - case 'E': case 'F': *call_conv = "__thiscall"; break; - case 'G': case 'H': *call_conv = "__stdcall"; break; - case 'I': case 'J': *call_conv = "__fastcall"; break; - case 'K': break; - default: ERR("Unknown calling convention %c\n", ch); return FALSE; - } - } - } - return TRUE; -} - -/******************************************************************* - * get_simple_type - * Return a string containing an allocated string for a simple data type - */ -static const char* get_simple_type(struct parsed_symbol* sym, char c) -{ - const char* type_string; - - switch (c) - { - case 'C': type_string = "signed char"; break; - case 'D': type_string = "char"; break; - case 'E': type_string = "unsigned char"; break; - case 'F': type_string = "short"; break; - case 'G': type_string = "unsigned short"; break; - case 'H': type_string = "int"; break; - case 'I': type_string = "unsigned int"; break; - case 'J': type_string = "long"; break; - case 'K': type_string = "unsigned long"; break; - case 'M': type_string = "float"; break; - case 'N': type_string = "double"; break; - case 'O': type_string = "long double"; break; - case 'X': type_string = "void"; break; - case 'Z': type_string = "..."; break; - default: type_string = NULL; break; - } - return type_string; -} -/******************************************************************* - * get_extented_type - * Return a string containing an allocated string for a simple data type - */ -static const char* get_extended_type(struct parsed_symbol* sym, char c) -{ - const char* type_string; - - switch (c) - { - case 'D': type_string = "__int8"; break; - case 'E': type_string = "unsigned __int8"; break; - case 'F': type_string = "__int16"; break; - case 'G': type_string = "unsigned __int16"; break; - case 'H': type_string = "__int32"; break; - case 'I': type_string = "unsigned __int32"; break; - case 'J': type_string = "__int64"; break; - case 'K': type_string = "unsigned __int64"; break; - case 'L': type_string = "__int128"; break; - case 'M': type_string = "unsigned __int128"; break; - case 'N': type_string = "bool"; break; - case 'W': type_string = "wchar_t"; break; - default: type_string = NULL; break; - } - return type_string; -} - -/******************************************************************* - * demangle_datatype - * - * Attempt to demangle a C++ data type, which may be datatype. - * a datatype type is made up of a number of simple types. e.g: - * char** = (pointer to (pointer to (char))) - */ -static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct, - struct array* pmt_ref, BOOL in_args) -{ - char dt; - BOOL add_pmt = TRUE; - - assert(ct); - ct->left = ct->right = NULL; - - switch (dt = *sym->current++) - { - case '_': - /* MS type: __int8,__int16 etc */ - ct->left = get_extended_type(sym, *sym->current++); - break; - case 'C': case 'D': case 'E': case 'F': case 'G': - case 'H': case 'I': case 'J': case 'K': case 'M': - case 'N': case 'O': case 'X': case 'Z': - /* Simple data types */ - ct->left = get_simple_type(sym, dt); - add_pmt = FALSE; - break; - case 'T': /* union */ - case 'U': /* struct */ - case 'V': /* class */ - /* Class/struct/union */ - { - unsigned mark = sym->stack.num; - const char* struct_name = NULL; - const char* type_name = NULL; - - if (!get_class(sym) || - !(struct_name = get_class_string(sym, mark))) goto done; - sym->stack.num = mark; - if (!(sym->flags & UNDNAME_NO_COMPLEX_TYPE)) - { - switch (dt) - { - case 'T': type_name = "union "; break; - case 'U': type_name = "struct "; break; - case 'V': type_name = "class "; break; - } - } - ct->left = str_printf(sym, "%s%s", type_name, struct_name); - } - break; - case '?': - /* not all the time is seems */ - if (!(ct->left = get_modified_type(sym, '?'))) goto done; - break; - case 'A': - if (!(ct->left = get_modified_type(sym, 'A'))) goto done; - break; - case 'Q': - if (!(ct->left = get_modified_type(sym, in_args ? 'Q' : 'P'))) goto done; - break; - case 'P': /* Pointer */ - if (isdigit(*sym->current)) - { - /* FIXME: P6 = Function pointer, others who knows.. */ - if (*sym->current++ == '6') - { - char* args = NULL; - const char* call_conv; - const char* exported; - struct datatype_t sub_ct; - unsigned mark = sym->stack.num; - - if (!get_calling_convention(sym, *sym->current++, - &call_conv, &exported, - sym->flags & ~UNDNAME_NO_ALLOCATION_LANGUAGE) || - !demangle_datatype(sym, &sub_ct, pmt_ref, FALSE)) - goto done; - - args = get_args(sym, pmt_ref, TRUE, '(', ')'); - if (!args) goto done; - sym->stack.num = mark; - - ct->left = str_printf(sym, "%s%s (%s*", - sub_ct.left, sub_ct.right, call_conv); - ct->right = str_printf(sym, ")%s", args); - } - else goto done; - } - else if (!(ct->left = get_modified_type(sym, 'P'))) goto done; - break; - case 'W': - if (*sym->current == '4') - { - char* enum_name; - unsigned mark = sym->stack.num; - sym->current++; - if (!get_class(sym) || - !(enum_name = get_class_string(sym, mark))) goto done; - sym->stack.num = mark; - if (sym->flags & UNDNAME_NO_COMPLEX_TYPE) - ct->left = enum_name; - else - ct->left = str_printf(sym, "enum %s", enum_name); - } - else goto done; - break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - /* Referring back to previously parsed type */ - ct->left = str_array_get_ref(pmt_ref, dt - '0'); - if (!ct->left) goto done; - add_pmt = FALSE; - break; - case '$': - if (sym->current[0] != '0') goto done; - if (sym->current[1] >= '0' && sym->current[1] <= '9') - { - char* ptr; - ptr = und_alloc(sym, 2); - ptr[0] = sym->current[1] + 1; - ptr[1] = 0; - ct->left = ptr; - sym->current += 2; - } - else if ((sym->current[1] >= 'A' && sym->current[1] <= 'P') && - sym->current[2] == '@') - { - char* ptr; - ptr = und_alloc(sym, 3); - if (sym->current[1] <= 'J') - { - ptr[0] = '0' + sym->current[1] - 'A'; - ptr[1] = 0; - } - else - { - ptr[0] = '1'; - ptr[1] = sym->current[1] - 'K' + '0'; - ptr[2] = 0; - } - ct->left = ptr; - sym->current += 3; - } - else goto done; - break; - default : - ERR("Unknown type %c\n", dt); - break; - } - if (add_pmt && pmt_ref && in_args) - str_array_push(sym, str_printf(sym, "%s%s", ct->left, ct->right), - -1, pmt_ref); -done: - - return ct->left != NULL; -} - -/****************************************************************** - * handle_data - * Does the final parsing and handling for a variable or a field in - * a class. - */ -static BOOL handle_data(struct parsed_symbol* sym) -{ - const char* access = NULL; - const char* member_type = NULL; - const char* modifier = NULL; - struct datatype_t ct; - char* name = NULL; - BOOL ret = FALSE; - char dt; - - /* 0 private static - * 1 protected static - * 2 public static - * 3 private non-static - * 4 protected non-static - * 5 public non-static - * 6 ?? static - * 7 ?? static - */ - - if (!(sym->flags & UNDNAME_NO_ACCESS_SPECIFIERS)) - { - /* we only print the access for static members */ - switch (*sym->current) - { - case '0': access = "private: "; break; - case '1': access = "protected: "; break; - case '2': access = "public: "; break; - } - } - - if (!(sym->flags & UNDNAME_NO_MEMBER_TYPE)) - { - if (*sym->current >= '0' && *sym->current <= '2') - member_type = "static "; - } - - name = get_class_string(sym, 0); - - switch (dt = *sym->current++) - { - case '0': case '1': case '2': - case '3': case '4': case '5': - { - unsigned mark = sym->stack.num; - if (!demangle_datatype(sym, &ct, NULL, FALSE)) goto done; - if (!get_modifier(*sym->current++, &modifier)) goto done; - sym->stack.num = mark; - } - break; - case '6' : /* compiler generated static */ - case '7' : /* compiler generated static */ - ct.left = ct.right = NULL; - if (!get_modifier(*sym->current++, &modifier)) goto done; - if (*sym->current != '@') - { - unsigned mark = sym->stack.num; - char* cls = NULL; - - if (!get_class(sym) || - !(cls = get_class_string(sym, mark))) goto done; - sym->stack.num = mark; - ct.right = str_printf(sym, "{for `%s'}", cls); - } - break; - default: goto done; - } - if (sym->flags & UNDNAME_NAME_ONLY) ct.left = ct.right = modifier = NULL; - sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s", access, - member_type, ct.left, - modifier && ct.left ? " " : NULL, modifier, - modifier || ct.left ? " " : NULL, name, ct.right); - ret = TRUE; -done: - return ret; -} - -/****************************************************************** - * handle_method - * Does the final parsing and handling for a function or a method in - * a class. - */ -static BOOL handle_method(struct parsed_symbol* sym, BOOL cast_op) -{ - const char* access = NULL; - const char* member_type = NULL; - struct datatype_t ct_ret; - const char* call_conv; - const char* modifier = NULL; - const char* exported; - const char* args_str = NULL; - const char* name = NULL; - BOOL ret = FALSE; - unsigned mark; - struct array array_pmt; - - /* FIXME: why 2 possible letters for each option? - * 'A' private: - * 'B' private: - * 'C' private: static - * 'D' private: static - * 'E' private: virtual - * 'F' private: virtual - * 'G' private: thunk - * 'H' private: thunk - * 'I' protected: - * 'J' protected: - * 'K' protected: static - * 'L' protected: static - * 'M' protected: virtual - * 'N' protected: virtual - * 'O' protected: thunk - * 'P' protected: thunk - * 'Q' public: - * 'R' public: - * 'S' public: static - * 'T' public: static - * 'U' public: virtual - * 'V' public: virtual - * 'W' public: thunk - * 'X' public: thunk - * 'Y' - * 'Z' - */ - - if (!(sym->flags & UNDNAME_NO_ACCESS_SPECIFIERS)) - { - switch ((*sym->current - 'A') / 8) - { - case 0: access = "private: "; break; - case 1: access = "protected: "; break; - case 2: access = "public: "; break; - } - } - if (!(sym->flags & UNDNAME_NO_MEMBER_TYPE)) - { - if (*sym->current >= 'A' && *sym->current <= 'X') - { - switch ((*sym->current - 'A') % 8) - { - case 2: case 3: member_type = "static "; break; - case 4: case 5: member_type = "virtual "; break; - case 6: case 7: member_type = "thunk "; break; - } - } - } - - if (*sym->current >= 'A' && *sym->current <= 'X') - { - if (!((*sym->current - 'A') & 2)) - { - /* Implicit 'this' pointer */ - /* If there is an implicit this pointer, const modifier follows */ - if (!get_modifier(*++sym->current, &modifier)) goto done; - } - } - else if (*sym->current < 'A' || *sym->current > 'Z') goto done; - sym->current++; - - name = get_class_string(sym, 0); - - if (!get_calling_convention(sym, *sym->current++, - &call_conv, &exported, sym->flags)) - goto done; - - str_array_init(&array_pmt); - - /* Return type, or @ if 'void' */ - if (*sym->current == '@') - { - ct_ret.left = "void"; - ct_ret.right = NULL; - sym->current++; - } - else - { - if (!demangle_datatype(sym, &ct_ret, &array_pmt, FALSE)) - goto done; - } - if (sym->flags & UNDNAME_NO_FUNCTION_RETURNS) - ct_ret.left = ct_ret.right = NULL; - if (cast_op) - { - name = str_printf(sym, "%s%s%s", name, ct_ret.left, ct_ret.right); - ct_ret.left = ct_ret.right = NULL; - } - - mark = sym->stack.num; - if (!(args_str = get_args(sym, &array_pmt, TRUE, '(', ')'))) goto done; - if (sym->flags & UNDNAME_NAME_ONLY) args_str = modifier = NULL; - sym->stack.num = mark; - - /* Note: '()' after 'Z' means 'throws', but we don't care here - * Yet!!! FIXME - */ - sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s%s%s%s%s", - access, member_type, ct_ret.left, - (ct_ret.left && !ct_ret.right) ? " " : NULL, - call_conv, call_conv ? " " : NULL, exported, - name, args_str, modifier, - modifier ? " " : NULL, ct_ret.right); - ret = TRUE; -done: - return ret; -} - -/******************************************************************* - * demangle_symbol - * Demangle a C++ linker symbol - */ -static BOOL symbol_demangle(struct parsed_symbol* sym) -{ - BOOL ret = FALSE; - unsigned do_after = 0; - - /* MS mangled names always begin with '?' */ - if (*sym->current != '?') return FALSE; - - /* FIXME seems wrong as name, as it demangles a simple data type */ - if (sym->flags & UNDNAME_NO_ARGUMENTS) - { - struct datatype_t ct; - - if (demangle_datatype(sym, &ct, NULL, FALSE)) - { - sym->result = str_printf(sym, "%s%s", ct.left, ct.right); - ret = TRUE; - } - goto done; - } - - str_array_init(&sym->stack); - sym->current++; - - /* Then function name or operator code */ - if (*sym->current == '?' && sym->current[1] != '$') - { - const char* function_name = NULL; - - /* C++ operator code (one character, or two if the first is '_') */ - switch (*++sym->current) - { - case '0': do_after = 1; break; - case '1': do_after = 2; break; - case '2': function_name = "operator new"; break; - case '3': function_name = "operator delete"; break; - case '4': function_name = "operator="; break; - case '5': function_name = "operator>>"; break; - case '6': function_name = "operator<<"; break; - case '7': function_name = "operator!"; break; - case '8': function_name = "operator=="; break; - case '9': function_name = "operator!="; break; - case 'A': function_name = "operator[]"; break; - case 'B': function_name = "operator "; do_after = 3; break; - case 'C': function_name = "operator->"; break; - case 'D': function_name = "operator*"; break; - case 'E': function_name = "operator++"; break; - case 'F': function_name = "operator--"; break; - case 'G': function_name = "operator-"; break; - case 'H': function_name = "operator+"; break; - case 'I': function_name = "operator&"; break; - case 'J': function_name = "operator->*"; break; - case 'K': function_name = "operator/"; break; - case 'L': function_name = "operator%"; break; - case 'M': function_name = "operator<"; break; - case 'N': function_name = "operator<="; break; - case 'O': function_name = "operator>"; break; - case 'P': function_name = "operator>="; break; - case 'Q': function_name = "operator,"; break; - case 'R': function_name = "operator()"; break; - case 'S': function_name = "operator~"; break; - case 'T': function_name = "operator^"; break; - case 'U': function_name = "operator|"; break; - case 'V': function_name = "operator&&"; break; - case 'W': function_name = "operator||"; break; - case 'X': function_name = "operator*="; break; - case 'Y': function_name = "operator+="; break; - case 'Z': function_name = "operator-="; break; - case '_': - switch (*++sym->current) - { - case '0': function_name = "operator/="; break; - case '1': function_name = "operator%="; break; - case '2': function_name = "operator>>="; break; - case '3': function_name = "operator<<="; break; - case '4': function_name = "operator&="; break; - case '5': function_name = "operator|="; break; - case '6': function_name = "operator^="; break; - case '7': function_name = "`vftable'"; break; - case '8': function_name = "`vbtable'"; break; - case '9': function_name = "`vcall'"; break; - case 'A': function_name = "`typeof'"; break; - case 'B': function_name = "`local static guard'"; break; - case 'C': function_name = "`string'"; do_after = 4; break; - case 'D': function_name = "`vbase destructor'"; break; - case 'E': function_name = "`vector deleting destructor'"; break; - case 'F': function_name = "`default constructor closure'"; break; - case 'G': function_name = "`scalar deleting destructor'"; break; - case 'H': function_name = "`vector constructor iterator'"; break; - case 'I': function_name = "`vector destructor iterator'"; break; - case 'J': function_name = "`vector vbase constructor iterator'"; break; - case 'K': function_name = "`virtual displacement map'"; break; - case 'L': function_name = "`eh vector constructor iterator'"; break; - case 'M': function_name = "`eh vector destructor iterator'"; break; - case 'N': function_name = "`eh vector vbase constructor iterator'"; break; - case 'O': function_name = "`copy constructor closure'"; break; - case 'S': function_name = "`local vftable'"; break; - case 'T': function_name = "`local vftable constructor closure'"; break; - case 'U': function_name = "operator new[]"; break; - case 'V': function_name = "operator delete[]"; break; - case 'X': function_name = "`placement delete closure'"; break; - case 'Y': function_name = "`placement delete[] closure'"; break; - default: - ERR("Unknown operator: _%c\n", *sym->current); - return FALSE; - } - break; - default: - /* FIXME: Other operators */ - ERR("Unknown operator: %c\n", *sym->current); - return FALSE; - } - sym->current++; - switch (do_after) - { - case 1: case 2: - sym->stack.num = sym->stack.max = 1; - sym->stack.elts[0] = "--null--"; - break; - case 4: - sym->result = (char*)function_name; - ret = TRUE; - goto done; - default: - str_array_push(sym, function_name, -1, &sym->stack); - break; - } - sym->stack.start = 1; - } - - /* Either a class name, or '@' if the symbol is not a class member */ - if (*sym->current != '@') - { - /* Class the function is associated with, terminated by '@@' */ - if (!get_class(sym)) goto done; - } - else sym->current++; - - switch (do_after) - { - case 0: default: break; - case 1: case 2: - /* it's time to set the member name for ctor & dtor */ - if (sym->stack.num <= 1) goto done; - if (do_after == 1) - sym->stack.elts[0] = sym->stack.elts[1]; - else - sym->stack.elts[0] = str_printf(sym, "~%s", sym->stack.elts[1]); - /* ctors and dtors don't have return type */ - sym->flags |= UNDNAME_NO_FUNCTION_RETURNS; - break; - case 3: - sym->flags &= ~UNDNAME_NO_FUNCTION_RETURNS; - break; - } - - /* Function/Data type and access level */ - if (*sym->current >= '0' && *sym->current <= '7') - ret = handle_data(sym); - else if (*sym->current >= 'A' && *sym->current <= 'Z') - ret = handle_method(sym, do_after == 3); - else ret = FALSE; -done: - if (ret) - assert(sym->result); - if (!ret) - ERR("Failed at %s\n", sym->current); - - return ret; -} - -/********************************************************************* - * __unDNameEx (MSVCRT.@) - * - * Demangle a C++ identifier. - * - * PARAMS - * buffer [O] If not NULL, the place to put the demangled string - * mangled [I] Mangled name of the function - * buflen [I] Length of buffer - * memget [I] Function to allocate memory with - * memfree [I] Function to free memory with - * unknown [?] Unknown, possibly a call back - * flags [I] Flags determining demangled format - * - * RETURNS - * Success: A string pointing to the unmangled name, allocated with memget. - * Failure: NULL. - */ -char* __unDNameEx(char* buffer, const char* mangled, int buflen, - malloc_func_t memget, free_func_t memfree, - void* unknown, unsigned short int flags) -{ - struct parsed_symbol sym; - - TRACE("(%p,%s,%d,%p,%p,%p,%x) stub!\n", - buffer, mangled, buflen, memget, memfree, unknown, flags); - - /* The flags details is not documented by MS. However, it looks exactly - * like the UNDNAME_ manifest constants from imagehlp.h and dbghelp.h - * So, we copied those (on top of the file) - */ - memset(&sym, 0, sizeof(struct parsed_symbol)); - if (flags & UNDNAME_NAME_ONLY) - flags |= UNDNAME_NO_FUNCTION_RETURNS | UNDNAME_NO_ACCESS_SPECIFIERS | - UNDNAME_NO_MEMBER_TYPE | UNDNAME_NO_ALLOCATION_LANGUAGE | - UNDNAME_NO_COMPLEX_TYPE; - - sym.flags = flags; - sym.mem_alloc_ptr = memget; - sym.mem_free_ptr = memfree; - sym.current = mangled; - - if (symbol_demangle(&sym)) - { - if (buffer && buflen) - { - memcpy(buffer, sym.result, buflen - 1); - buffer[buflen - 1] = '\0'; - } - else - { - buffer = memget(strlen(sym.result) + 1); - if (buffer) strcpy(buffer, sym.result); - } - } - else buffer = NULL; - - und_free_all(&sym); - - return buffer; -} - - -/********************************************************************* - * __unDName (MSVCRT.@) - */ -char* __unDName(char* buffer, const char* mangled, int buflen, - malloc_func_t memget, free_func_t memfree, - unsigned short int flags) -{ - return __unDNameEx(buffer, mangled, buflen, memget, memfree, NULL, flags); -} - diff --git a/reactos/lib/crt/wstring/wcscoll.c b/reactos/lib/crt/wstring/wcscoll.c deleted file mode 100644 index c5237882b13..00000000000 --- a/reactos/lib/crt/wstring/wcscoll.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @unimplemented - */ -int wcscoll(const wchar_t *a1,const wchar_t *a2) -{ - /* FIXME: handle collates */ - return wcscmp(a1,a2); -} - -/* - * @unimplemented - */ -int _wcsicoll(const wchar_t *a1,const wchar_t *a2) -{ - /* FIXME: handle collates */ - return _wcsicmp(a1,a2); -} - -/* - * @unimplemented - */ -int _wcsncoll (const wchar_t *s1, const wchar_t *s2, size_t c) -{ - /* FIXME: handle collates */ - return wcsncmp(s1,s2,c); -} - -/* - * @unimplemented - */ -int _wcsnicoll (const wchar_t *s1, const wchar_t *s2, size_t c) -{ - /* FIXME: handle collates */ - return _wcsnicmp(s1,s2,c); -} diff --git a/reactos/lib/crt/wstring/wcscspn.c b/reactos/lib/crt/wstring/wcscspn.c deleted file mode 100644 index 1fcad259b43..00000000000 --- a/reactos/lib/crt/wstring/wcscspn.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -size_t wcscspn(const wchar_t *str,const wchar_t *reject) -{ - wchar_t *s; - wchar_t *t; - s=(wchar_t *)str; - do { - t=(wchar_t *)reject; - while (*t) { - if (*t==*s) - break; - t++; - } - if (*t) - break; - s++; - } while (*s); - return s-str; /* nr of wchars */ -} diff --git a/reactos/lib/crt/wstring/wcsdup.c b/reactos/lib/crt/wstring/wcsdup.c deleted file mode 100644 index 4679f8f874c..00000000000 --- a/reactos/lib/crt/wstring/wcsdup.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -wchar_t* _wcsdup(const wchar_t* ptr) -{ - wchar_t* dup; - - dup = malloc((wcslen(ptr) + 1) * sizeof(wchar_t)); - if (dup == NULL) { - __set_errno(ENOMEM); - return NULL; - } - wcscpy(dup, ptr); - return dup; -} diff --git a/reactos/lib/crt/wstring/wcsicmp.c b/reactos/lib/crt/wstring/wcsicmp.c deleted file mode 100644 index 500ce0ba1bd..00000000000 --- a/reactos/lib/crt/wstring/wcsicmp.c +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include - -/* - * @implemented - */ -int _wcsicmp(const wchar_t* cs,const wchar_t * ct) -{ - while (towlower(*cs) == towlower(*ct)) - { - if (*cs == 0) - return 0; - cs++; - ct++; - } - return towlower(*cs) - towlower(*ct); -} diff --git a/reactos/lib/crt/wstring/wcslwr.c b/reactos/lib/crt/wstring/wcslwr.c deleted file mode 100644 index c62e3f0eb72..00000000000 --- a/reactos/lib/crt/wstring/wcslwr.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * The C RunTime DLL - * - * Implements C run-time functionality as known from UNIX. - * - * Copyright 1996,1998 Marcus Meissner - * Copyright 1996 Jukka Iivonen - * Copyright 1997 Uwe Bonnes - */ - -#include - -/* - * @implemented - */ -wchar_t * _wcslwr(wchar_t *x) -{ - wchar_t *y=x; - - while (*y) { - *y=towlower(*y); - y++; - } - return x; -} diff --git a/reactos/lib/crt/wstring/wcsnicmp.c b/reactos/lib/crt/wstring/wcsnicmp.c deleted file mode 100644 index 495a21183e7..00000000000 --- a/reactos/lib/crt/wstring/wcsnicmp.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -int _wcsnicmp (const wchar_t *cs, const wchar_t *ct, size_t count) -{ - if (count == 0) - return 0; - do { - if (towupper(*cs) != towupper(*ct++)) - return towupper(*cs) - towupper(*--ct); - if (*cs++ == 0) - break; - } while (--count != 0); - return 0; -} diff --git a/reactos/lib/crt/wstring/wcspbrk.c b/reactos/lib/crt/wstring/wcspbrk.c deleted file mode 100644 index e3b7c92c6be..00000000000 --- a/reactos/lib/crt/wstring/wcspbrk.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2) -{ - const wchar_t *scanp; - int c, sc; - - while ((c = *s1++) != 0) - { - for (scanp = s2; (sc = *scanp++) != 0;) - if (sc == c) { - return (wchar_t *)(--s1); - } - } - return 0; -} diff --git a/reactos/lib/crt/wstring/wcsrev.c b/reactos/lib/crt/wstring/wcsrev.c deleted file mode 100644 index 20f5c51bdbb..00000000000 --- a/reactos/lib/crt/wstring/wcsrev.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -wchar_t * _wcsrev(wchar_t *s) -{ - wchar_t *e; - wchar_t a; - e=s; - while (*e) - e++; - while (s - -/* - * @implemented - */ -wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill) -{ - wchar_t *t = wsToFill; - size_t i = 0; - while( *wsToFill != 0 && i < sizeMaxFill) - { - *wsToFill = wcFill; - wsToFill++; - i++; - - } - return t; -} - -/* - * @implemented - */ -wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcFill) -{ - wchar_t *t = wsToFill; - while( *wsToFill != 0 ) - { - *wsToFill = wcFill; - wsToFill++; - - } - return t; -} diff --git a/reactos/lib/crt/wstring/wcsspn.c b/reactos/lib/crt/wstring/wcsspn.c deleted file mode 100644 index fdc5969b70a..00000000000 --- a/reactos/lib/crt/wstring/wcsspn.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -size_t wcsspn(const wchar_t *str,const wchar_t *accept) -{ - wchar_t *s; - wchar_t *t; - s=(wchar_t *)str; - do { - t=(wchar_t *)accept; - while (*t) { - if (*t==*s) - break; - t++; - } - if (!*t) - break; - s++; - } while (*s); - return s-str; /* nr of wchars */ -} diff --git a/reactos/lib/crt/wstring/wcsstr.c b/reactos/lib/crt/wstring/wcsstr.c deleted file mode 100644 index 188da07403b..00000000000 --- a/reactos/lib/crt/wstring/wcsstr.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -wchar_t *wcsstr(const wchar_t *s,const wchar_t *b) -{ - wchar_t *x; - wchar_t *y; - wchar_t *c; - x=(wchar_t *)s; - while (*x) { - if (*x==*b) { - y=x; - c=(wchar_t *)b; - while (*y && *c && *y==*c) { - c++; - y++; - } - if (!*c) - return x; - } - x++; - } - return NULL; -} diff --git a/reactos/lib/crt/wstring/wcstok.c b/reactos/lib/crt/wstring/wcstok.c deleted file mode 100644 index 09c2e4e4466..00000000000 --- a/reactos/lib/crt/wstring/wcstok.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -wchar_t** _wlasttoken(); /* wlasttok.c */ - -/* - * @implemented - */ -wchar_t *wcstok(wchar_t *s, const wchar_t *ct) -{ - const wchar_t *spanp; - int c, sc; - wchar_t *tok; -#if 1 - wchar_t ** wlasttoken = _wlasttoken(); -#else - PTHREADDATA ThreadData = GetThreadData(); - wchar_t ** wlasttoken = &ThreadData->wlasttoken; -#endif - - if (s == NULL && (s = *wlasttoken) == NULL) - return (NULL); - - /* - * Skip (span) leading ctiters (s += strspn(s, ct), sort of). - */ - cont: - c = *s; - s++; - for (spanp = ct; (sc = *spanp) != 0;spanp++) { - if (c == sc) - goto cont; - } - - if (c == 0) { /* no non-ctiter characters */ - *wlasttoken = NULL; - return (NULL); - } - tok = s - 1; - - /* - * Scan token (scan for ctiters: s += strcspn(s, ct), sort of). - * Note that ct must have one NUL; we stop if we see that, too. - */ - for (;;) { - c = *s; - s++; - spanp = ct; - do { - if ((sc = *spanp) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *wlasttoken = s; - return (tok); - } - spanp++; - } while (sc != 0); - } - /* NOTREACHED */ -} diff --git a/reactos/lib/crt/wstring/wcsupr.c b/reactos/lib/crt/wstring/wcsupr.c deleted file mode 100644 index e4e96b257dc..00000000000 --- a/reactos/lib/crt/wstring/wcsupr.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -wchar_t *_wcsupr(wchar_t *x) -{ - wchar_t *y = x; - - while (*y) { - *y = towupper(*y); - y++; - } - return x; -} diff --git a/reactos/lib/crt/wstring/wcsxfrm.c b/reactos/lib/crt/wstring/wcsxfrm.c deleted file mode 100644 index 762238ea522..00000000000 --- a/reactos/lib/crt/wstring/wcsxfrm.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ - -#include - -/* - * @implemented - */ -size_t wcsxfrm(wchar_t *dst,const wchar_t *src, size_t n) -{ - size_t r = 0; - int c; - - if (n != 0) { - while ((c = *src++) != 0) - { - r++; - if (--n == 0) - { - while (*src++ != 0) - r++; - break; - } - *dst++ = c; - } - *dst = 0; - } - return r; -} diff --git a/reactos/lib/crt/wstring/wlasttok.c b/reactos/lib/crt/wstring/wlasttok.c deleted file mode 100644 index bd0c7153a13..00000000000 --- a/reactos/lib/crt/wstring/wlasttok.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header - */ -#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 - * so that CRTDLL can use the wcstok source code in the same - * file. - */ -wchar_t** _wlasttoken() -{ - PTHREADDATA ptd = GetThreadData(); - assert(ptd); - return &(ptd->wlasttoken); -}