mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
Added some functions to msvcrt
svn path=/trunk/; revision=1445
This commit is contained in:
parent
a9828950fe
commit
f01dd17793
133 changed files with 4898 additions and 180 deletions
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.5 2000/11/20 19:59:08 ekohl Exp $
|
||||
# $Id: Makefile,v 1.6 2000/12/03 18:00:07 ekohl Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
|
@ -12,40 +12,168 @@ BASE_CFLAGS = -I../../include
|
|||
all: $(TARGET_DLL)
|
||||
|
||||
|
||||
OBJECTS_CTYPE = \
|
||||
ctype/isalnum.o \
|
||||
ctype/isalpha.o \
|
||||
ctype/isascii.o \
|
||||
ctype/iscntrl.o \
|
||||
ctype/isdigit.o \
|
||||
ctype/isgraph.o \
|
||||
ctype/islower.o \
|
||||
ctype/isprint.o \
|
||||
ctype/ispunct.o \
|
||||
ctype/isspace.o \
|
||||
ctype/isupper.o \
|
||||
ctype/isxdigit.o \
|
||||
ctype/toascii.o \
|
||||
ctype/tolower.o \
|
||||
ctype/toupper.o \
|
||||
ctype/iscsym.o \
|
||||
ctype/isctype.o
|
||||
|
||||
OBJECTS_DIRECT = \
|
||||
direct/chdir.o \
|
||||
direct/chdrive.o \
|
||||
direct/getcwd.o \
|
||||
direct/getdcwd.o \
|
||||
direct/getdfree.o \
|
||||
direct/getdrive.o \
|
||||
direct/mkdir.o \
|
||||
direct/rmdir.o
|
||||
|
||||
OBJECTS_MISC = \
|
||||
misc/dllmain.o \
|
||||
misc/msvcrt.coff
|
||||
misc/tls.o
|
||||
|
||||
OBJECTS_PROCESS = \
|
||||
process/thread.o
|
||||
|
||||
|
||||
#incomplete
|
||||
OBJECTS_STDLIB = \
|
||||
stdlib/errno.o
|
||||
stdlib/abs.o \
|
||||
stdlib/atof.o \
|
||||
stdlib/atoi.o \
|
||||
stdlib/atol.o \
|
||||
stdlib/bsearch.o \
|
||||
stdlib/div.o \
|
||||
stdlib/errno.o \
|
||||
stdlib/fullpath.o \
|
||||
stdlib/getenv.o \
|
||||
stdlib/itoa.o \
|
||||
stdlib/itow.o \
|
||||
stdlib/labs.o \
|
||||
stdlib/ldiv.o \
|
||||
stdlib/makepath.o \
|
||||
stdlib/malloc.o \
|
||||
stdlib/putenv.o \
|
||||
stdlib/rand.o \
|
||||
stdlib/rot.o \
|
||||
stdlib/senv.o \
|
||||
stdlib/splitp.o \
|
||||
stdlib/strtod.o \
|
||||
stdlib/strtol.o \
|
||||
stdlib/strtoul.o \
|
||||
stdlib/wcstod.o \
|
||||
stdlib/wcstol.o \
|
||||
stdlib/wcstoul.o \
|
||||
stdlib/wtoi.o
|
||||
|
||||
OBJECTS_STRING = \
|
||||
string/memccpy.o \
|
||||
string/memchr.o \
|
||||
string/memcmp.o \
|
||||
string/memcpy.o \
|
||||
string/memicmp.o \
|
||||
string/memmove.o \
|
||||
string/memset.o \
|
||||
string/strcat.o \
|
||||
string/strchr.o \
|
||||
string/strcmp.o \
|
||||
string/strcoll.o \
|
||||
string/strcpy.o \
|
||||
string/strcspn.o \
|
||||
string/strdup.o \
|
||||
string/strerror.o \
|
||||
string/stricmp.o \
|
||||
string/strlen.o \
|
||||
string/strlwr.o \
|
||||
string/strncat.o \
|
||||
string/strncmp.o \
|
||||
string/strncpy.o \
|
||||
string/strnicmp.o \
|
||||
string/strnlen.o \
|
||||
string/strpbrk.o \
|
||||
string/strrchr.o \
|
||||
string/strrev.o\
|
||||
string/strset.o \
|
||||
string/strspn.o \
|
||||
string/strstr.o \
|
||||
string/strtok.o \
|
||||
string/strupr.o \
|
||||
string/strxfrm.o
|
||||
|
||||
OBJECTS_WSTRING = \
|
||||
wstring/wcscat.o \
|
||||
wstring/wcschr.o \
|
||||
wstring/wcscmp.o \
|
||||
wstring/wcscoll.o \
|
||||
wstring/wcscpy.o \
|
||||
wstring/wcscspn.o \
|
||||
wstring/wcsdup.o \
|
||||
wstring/wcsicmp.o \
|
||||
wstring/wcslen.o \
|
||||
wstring/wcslwr.o \
|
||||
wstring/wcsncat.o \
|
||||
wstring/wcsncmp.o \
|
||||
wstring/wcsncpy.o \
|
||||
wstring/wcsnicmp.o \
|
||||
wstring/wcsnlen.o \
|
||||
wstring/wcspbrk.o \
|
||||
wstring/wcsrchr.o \
|
||||
wstring/wcsrev.o \
|
||||
wstring/wcsset.o \
|
||||
wstring/wcsspn.o \
|
||||
wstring/wcsstr.o \
|
||||
wstring/wcstok.o \
|
||||
wstring/wcsupr.o \
|
||||
wstring/wcsxfrm.o
|
||||
|
||||
OBJECTS = \
|
||||
$(OBJECTS_CTYPE) \
|
||||
$(OBJECTS_DIRECT) \
|
||||
$(OBJECTS_MISC) \
|
||||
$(OBJECTS_PROCESS) \
|
||||
$(OBJECTS_STDLIB)
|
||||
$(OBJECTS_STDLIB) \
|
||||
$(OBJECTS_STRING) \
|
||||
$(OBJECTS_WSTRING) \
|
||||
msvcrt.coff
|
||||
|
||||
ifeq ($(DOSCLI), yes)
|
||||
CLEAN_FILES = \
|
||||
ctype\*.o \
|
||||
direct\*.o \
|
||||
misc\*.o \
|
||||
misc\*.coff \
|
||||
process\*.o \
|
||||
stdlib\*.o \
|
||||
string\*.o \
|
||||
wstring\*.o \
|
||||
$(TARGET_NAME).a \
|
||||
$(TARGET_NAME).coff \
|
||||
$(TARGET_NAME).o \
|
||||
$(TARGET_NAME).dll \
|
||||
$(TARGET_NAME).sym
|
||||
$(TARGET_NAME).sym \
|
||||
base.tmp
|
||||
else
|
||||
CLEAN_FILES = \
|
||||
ctype/*.o \
|
||||
direct/*.o \
|
||||
misc/*.o \
|
||||
misc/*.coff \
|
||||
process/*.o \
|
||||
stdlib/*.o \
|
||||
string/*.o \
|
||||
wstring/*.o \
|
||||
$(TARGET_NAME).a \
|
||||
$(TARGET_NAME).coff \
|
||||
$(TARGET_NAME).o \
|
||||
$(TARGET_NAME).dll \
|
||||
$(TARGET_NAME).sym
|
||||
|
@ -56,12 +184,12 @@ $(TARGET_NAME).coff: $(TARGET_NAME).rc ../../include/reactos/resource.h
|
|||
$(TARGET_NAME).a: $(OBJECTS)
|
||||
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).a
|
||||
|
||||
$(TARGET_NAME).dll: $(DLLMAIN) $(OBJECTS) misc/$(TARGET_NAME).def
|
||||
$(TARGET_NAME).dll: $(DLLMAIN) $(OBJECTS) $(TARGET_NAME).def
|
||||
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).o
|
||||
$(DLLTOOL) \
|
||||
--dllname $(TARGET_NAME).dll \
|
||||
--def misc/$(TARGET_NAME).def \
|
||||
--output-lib misc/$(TARGET_NAME).a
|
||||
--def $(TARGET_NAME).def \
|
||||
--output-lib $(TARGET_NAME).a
|
||||
$(CC) \
|
||||
-specs=misc/$(TARGET_NAME)_specs \
|
||||
-mdll \
|
||||
|
@ -74,7 +202,7 @@ $(TARGET_NAME).dll: $(DLLMAIN) $(OBJECTS) misc/$(TARGET_NAME).def
|
|||
--dllname $(TARGET_NAME).dll \
|
||||
--base-file base.tmp \
|
||||
--output-exp temp.exp \
|
||||
--def misc/$(TARGET_NAME).def
|
||||
--def $(TARGET_NAME).def
|
||||
- $(RM) base.tmp
|
||||
$(CC) \
|
||||
-specs=misc/$(TARGET_NAME)_specs \
|
||||
|
|
23
reactos/lib/msvcrt/ctype/isalnum.c
Normal file
23
reactos/lib/msvcrt/ctype/isalnum.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/ctype/isalnum.c
|
||||
* PURPOSE: Test for a alpha numeric character
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
|
||||
#undef isalnum
|
||||
int isalnum(int c)
|
||||
{
|
||||
return _isctype(c,_ALPHA | _DIGIT);
|
||||
}
|
||||
|
||||
#undef iswalnum
|
||||
int iswalnum(wint_t c)
|
||||
{
|
||||
return iswctype(c,_ALPHA | _DIGIT);
|
||||
}
|
23
reactos/lib/msvcrt/ctype/isalpha.c
Normal file
23
reactos/lib/msvcrt/ctype/isalpha.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/mscvrt/ctype/isalpha.c
|
||||
* PURPOSE: Checks if a character is alphanumeric
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef isalpha
|
||||
int isalpha(int c)
|
||||
{
|
||||
return _isctype(c,_ALPHA);
|
||||
}
|
||||
|
||||
#undef iswalpha
|
||||
int iswalpha(wint_t c)
|
||||
{
|
||||
return iswctype(c,_ALPHA);
|
||||
}
|
29
reactos/lib/msvcrt/ctype/isascii.c
Normal file
29
reactos/lib/msvcrt/ctype/isascii.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/ctype/isascii.c
|
||||
* PURPOSE: Checks if a character is ascii
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
int __isascii(int c)
|
||||
{
|
||||
return (!((c)&(~0x7f)));
|
||||
}
|
||||
|
||||
int iswascii(wint_t c)
|
||||
{
|
||||
return __isascii(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
14
reactos/lib/msvcrt/ctype/iscntrl.c
Normal file
14
reactos/lib/msvcrt/ctype/iscntrl.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef iscntrl
|
||||
int iscntrl(int c)
|
||||
{
|
||||
return _isctype(c,_CONTROL);
|
||||
}
|
||||
|
||||
#undef iswcntrl
|
||||
int iswcntrl(wint_t c)
|
||||
{
|
||||
return iswctype(c,_CONTROL);
|
||||
}
|
21
reactos/lib/msvcrt/ctype/iscsym.c
Normal file
21
reactos/lib/msvcrt/ctype/iscsym.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/ctype/iscsym.c
|
||||
* PURPOSE: Check for a valid characters in a c symbol
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
int __iscsymf(int c)
|
||||
{
|
||||
return (isalpha(c) || ( c == '_' ));
|
||||
}
|
||||
|
||||
int __iscsym(int c)
|
||||
{
|
||||
return (isalnum(c) || ( c == '_' ));
|
||||
}
|
283
reactos/lib/msvcrt/ctype/isctype.c
Normal file
283
reactos/lib/msvcrt/ctype/isctype.c
Normal file
|
@ -0,0 +1,283 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
unsigned short _ctype[] = {
|
||||
0, /* <EOF>, 0xFFFF */
|
||||
_CONTROL, /* CTRL+@, 0x00 */
|
||||
_CONTROL, /* CTRL+A, 0x01 */
|
||||
_CONTROL, /* CTRL+B, 0x02 */
|
||||
_CONTROL, /* CTRL+C, 0x03 */
|
||||
_CONTROL, /* CTRL+D, 0x04 */
|
||||
_CONTROL, /* CTRL+E, 0x05 */
|
||||
_CONTROL, /* CTRL+F, 0x06 */
|
||||
_CONTROL, /* CTRL+G, 0x07 */
|
||||
_CONTROL, /* CTRL+H, 0x08 */
|
||||
_CONTROL | _SPACE, /* CTRL+I, 0x09 */
|
||||
_CONTROL | _SPACE, /* CTRL+J, 0x0a */
|
||||
_CONTROL | _SPACE, /* CTRL+K, 0x0b */
|
||||
_CONTROL | _SPACE, /* CTRL+L, 0x0c */
|
||||
_CONTROL | _SPACE, /* CTRL+M, 0x0d */
|
||||
_CONTROL, /* CTRL+N, 0x0e */
|
||||
_CONTROL, /* CTRL+O, 0x0f */
|
||||
_CONTROL, /* CTRL+P, 0x10 */
|
||||
_CONTROL, /* CTRL+Q, 0x11 */
|
||||
_CONTROL, /* CTRL+R, 0x12 */
|
||||
_CONTROL, /* CTRL+S, 0x13 */
|
||||
_CONTROL, /* CTRL+T, 0x14 */
|
||||
_CONTROL, /* CTRL+U, 0x15 */
|
||||
_CONTROL, /* CTRL+V, 0x16 */
|
||||
_CONTROL, /* CTRL+W, 0x17 */
|
||||
_CONTROL, /* CTRL+X, 0x18 */
|
||||
_CONTROL, /* CTRL+Y, 0x19 */
|
||||
_CONTROL, /* CTRL+Z, 0x1a */
|
||||
_CONTROL, /* CTRL+[, 0x1b */
|
||||
_CONTROL, /* CTRL+\, 0x1c */
|
||||
_CONTROL, /* CTRL+], 0x1d */
|
||||
_CONTROL, /* CTRL+^, 0x1e */
|
||||
_CONTROL, /* CTRL+_, 0x1f */
|
||||
_SPACE | _BLANK, /* ` ', 0x20 */
|
||||
_PUNCT, /* `!', 0x21 */
|
||||
_PUNCT, /* 0x22 */
|
||||
_PUNCT, /* `#', 0x23 */
|
||||
_PUNCT, /* `$', 0x24 */
|
||||
_PUNCT, /* `%', 0x25 */
|
||||
_PUNCT, /* `&', 0x26 */
|
||||
_PUNCT, /* 0x27 */
|
||||
_PUNCT, /* `(', 0x28 */
|
||||
_PUNCT, /* `)', 0x29 */
|
||||
_PUNCT, /* `*', 0x2a */
|
||||
_PUNCT, /* `+', 0x2b */
|
||||
_PUNCT, /* `,', 0x2c */
|
||||
_PUNCT, /* `-', 0x2d */
|
||||
_PUNCT, /* `.', 0x2e */
|
||||
_PUNCT, /* `/', 0x2f */
|
||||
_DIGIT | _HEX, /* `0', 0x30 */
|
||||
_DIGIT | _HEX, /* `1', 0x31 */
|
||||
_DIGIT | _HEX, /* `2', 0x32 */
|
||||
_DIGIT | _HEX, /* `3', 0x33 */
|
||||
_DIGIT | _HEX, /* `4', 0x34 */
|
||||
_DIGIT | _HEX, /* `5', 0x35 */
|
||||
_DIGIT | _HEX, /* `6', 0x36 */
|
||||
_DIGIT | _HEX, /* `7', 0x37 */
|
||||
_DIGIT | _HEX, /* `8', 0x38 */
|
||||
_DIGIT | _HEX, /* `9', 0x39 */
|
||||
_PUNCT, /* `:', 0x3a */
|
||||
_PUNCT, /* `;', 0x3b */
|
||||
_PUNCT, /* `<', 0x3c */
|
||||
_PUNCT, /* `=', 0x3d */
|
||||
_PUNCT, /* `>', 0x3e */
|
||||
_PUNCT, /* `?', 0x3f */
|
||||
_PUNCT, /* `@', 0x40 */
|
||||
_UPPER | _HEX, /* `A', 0x41 */
|
||||
_UPPER | _HEX, /* `B', 0x42 */
|
||||
_UPPER | _HEX, /* `C', 0x43 */
|
||||
_UPPER | _HEX, /* `D', 0x44 */
|
||||
_UPPER | _HEX, /* `E', 0x45 */
|
||||
_UPPER | _HEX, /* `F', 0x46 */
|
||||
_UPPER, /* `G', 0x47 */
|
||||
_UPPER, /* `H', 0x48 */
|
||||
_UPPER, /* `I', 0x49 */
|
||||
_UPPER, /* `J', 0x4a */
|
||||
_UPPER, /* `K', 0x4b */
|
||||
_UPPER, /* `L', 0x4c */
|
||||
_UPPER, /* `M', 0x4d */
|
||||
_UPPER, /* `N', 0x4e */
|
||||
_UPPER, /* `O', 0x4f */
|
||||
_UPPER, /* `P', 0x50 */
|
||||
_UPPER, /* `Q', 0x51 */
|
||||
_UPPER, /* `R', 0x52 */
|
||||
_UPPER, /* `S', 0x53 */
|
||||
_UPPER, /* `T', 0x54 */
|
||||
_UPPER, /* `U', 0x55 */
|
||||
_UPPER, /* `V', 0x56 */
|
||||
_UPPER, /* `W', 0x57 */
|
||||
_UPPER, /* `X', 0x58 */
|
||||
_UPPER, /* `Y', 0x59 */
|
||||
_UPPER, /* `Z', 0x5a */
|
||||
_PUNCT, /* `[', 0x5b */
|
||||
_PUNCT, /* 0x5c */
|
||||
_PUNCT, /* `]', 0x5d */
|
||||
_PUNCT, /* `^', 0x5e */
|
||||
_PUNCT, /* `_', 0x5f */
|
||||
_PUNCT, /* 0x60 */
|
||||
_LOWER | _HEX, /* `a', 0x61 */
|
||||
_LOWER | _HEX, /* `b', 0x62 */
|
||||
_LOWER | _HEX, /* `c', 0x63 */
|
||||
_LOWER | _HEX, /* `d', 0x64 */
|
||||
_LOWER | _HEX, /* `e', 0x65 */
|
||||
_LOWER | _HEX, /* `f', 0x66 */
|
||||
_LOWER, /* `g', 0x67 */
|
||||
_LOWER, /* `h', 0x68 */
|
||||
_LOWER, /* `i', 0x69 */
|
||||
_LOWER, /* `j', 0x6a */
|
||||
_LOWER, /* `k', 0x6b */
|
||||
_LOWER, /* `l', 0x6c */
|
||||
_LOWER, /* `m', 0x6d */
|
||||
_LOWER, /* `n', 0x6e */
|
||||
_LOWER, /* `o', 0x6f */
|
||||
_LOWER, /* `p', 0x70 */
|
||||
_LOWER, /* `q', 0x71 */
|
||||
_LOWER, /* `r', 0x72 */
|
||||
_LOWER, /* `s', 0x73 */
|
||||
_LOWER, /* `t', 0x74 */
|
||||
_LOWER, /* `u', 0x75 */
|
||||
_LOWER, /* `v', 0x76 */
|
||||
_LOWER, /* `w', 0x77 */
|
||||
_LOWER, /* `x', 0x78 */
|
||||
_LOWER, /* `y', 0x79 */
|
||||
_LOWER, /* `z', 0x7a */
|
||||
_PUNCT, /* `{', 0x7b */
|
||||
_PUNCT, /* `|', 0x7c */
|
||||
_PUNCT, /* `}', 0x7d */
|
||||
_PUNCT, /* `~', 0x7e */
|
||||
_CONTROL, /* 0x7f */
|
||||
0, /* 0x80 */
|
||||
0, /* 0x81 */
|
||||
0, /* 0x82 */
|
||||
0, /* 0x83 */
|
||||
0, /* 0x84 */
|
||||
0, /* 0x85 */
|
||||
0, /* 0x86 */
|
||||
0, /* 0x87 */
|
||||
0, /* 0x88 */
|
||||
0, /* 0x89 */
|
||||
0, /* 0x8a */
|
||||
0, /* 0x8b */
|
||||
0, /* 0x8c */
|
||||
0, /* 0x8d */
|
||||
0, /* 0x8e */
|
||||
0, /* 0x8f */
|
||||
0, /* 0x90 */
|
||||
0, /* 0x91 */
|
||||
0, /* 0x92 */
|
||||
0, /* 0x93 */
|
||||
0, /* 0x94 */
|
||||
0, /* 0x95 */
|
||||
0, /* 0x96 */
|
||||
0, /* 0x97 */
|
||||
0, /* 0x98 */
|
||||
0, /* 0x99 */
|
||||
0, /* 0x9a */
|
||||
0, /* 0x9b */
|
||||
0, /* 0x9c */
|
||||
0, /* 0x9d */
|
||||
0, /* 0x9e */
|
||||
0, /* 0x9f */
|
||||
0, /* 0xa0 */
|
||||
0, /* 0xa1 */
|
||||
0, /* 0xa2 */
|
||||
0, /* 0xa3 */
|
||||
0, /* 0xa4 */
|
||||
0, /* 0xa5 */
|
||||
0, /* 0xa6 */
|
||||
0, /* 0xa7 */
|
||||
0, /* 0xa8 */
|
||||
0, /* 0xa9 */
|
||||
0, /* 0xaa */
|
||||
0, /* 0xab */
|
||||
0, /* 0xac */
|
||||
0, /* 0xad */
|
||||
0, /* 0xae */
|
||||
0, /* 0xaf */
|
||||
0, /* 0xb0 */
|
||||
0, /* 0xb1 */
|
||||
0, /* 0xb2 */
|
||||
0, /* 0xb3 */
|
||||
0, /* 0xb4 */
|
||||
0, /* 0xb5 */
|
||||
0, /* 0xb6 */
|
||||
0, /* 0xb7 */
|
||||
0, /* 0xb8 */
|
||||
0, /* 0xb9 */
|
||||
0, /* 0xba */
|
||||
0, /* 0xbb */
|
||||
0, /* 0xbc */
|
||||
0, /* 0xbd */
|
||||
0, /* 0xbe */
|
||||
0, /* 0xbf */
|
||||
0, /* 0xc0 */
|
||||
0, /* 0xc1 */
|
||||
0, /* 0xc2 */
|
||||
0, /* 0xc3 */
|
||||
0, /* 0xc4 */
|
||||
0, /* 0xc5 */
|
||||
0, /* 0xc6 */
|
||||
0, /* 0xc7 */
|
||||
0, /* 0xc8 */
|
||||
0, /* 0xc9 */
|
||||
0, /* 0xca */
|
||||
0, /* 0xcb */
|
||||
0, /* 0xcc */
|
||||
0, /* 0xcd */
|
||||
0, /* 0xce */
|
||||
0, /* 0xcf */
|
||||
0, /* 0xd0 */
|
||||
0, /* 0xd1 */
|
||||
0, /* 0xd2 */
|
||||
0, /* 0xd3 */
|
||||
0, /* 0xd4 */
|
||||
0, /* 0xd5 */
|
||||
0, /* 0xd6 */
|
||||
0, /* 0xd7 */
|
||||
0, /* 0xd8 */
|
||||
0, /* 0xd9 */
|
||||
0, /* 0xda */
|
||||
0, /* 0xdb */
|
||||
0, /* 0xdc */
|
||||
0, /* 0xdd */
|
||||
0, /* 0xde */
|
||||
0, /* 0xdf */
|
||||
0, /* 0xe0 */
|
||||
0, /* 0xe1 */
|
||||
0, /* 0xe2 */
|
||||
0, /* 0xe3 */
|
||||
0, /* 0xe4 */
|
||||
0, /* 0xe5 */
|
||||
0, /* 0xe6 */
|
||||
0, /* 0xe7 */
|
||||
0, /* 0xe8 */
|
||||
0, /* 0xe9 */
|
||||
0, /* 0xea */
|
||||
0, /* 0xeb */
|
||||
0, /* 0xec */
|
||||
0, /* 0xed */
|
||||
0, /* 0xee */
|
||||
0, /* 0xef */
|
||||
0, /* 0xf0 */
|
||||
0, /* 0xf1 */
|
||||
0, /* 0xf2 */
|
||||
0, /* 0xf3 */
|
||||
0, /* 0xf4 */
|
||||
0, /* 0xf5 */
|
||||
0, /* 0xf6 */
|
||||
0, /* 0xf7 */
|
||||
0, /* 0xf8 */
|
||||
0, /* 0xf9 */
|
||||
0, /* 0xfa */
|
||||
0, /* 0xfb */
|
||||
0, /* 0xfc */
|
||||
0, /* 0xfd */
|
||||
0, /* 0xfe */
|
||||
0 /* 0xff */
|
||||
};
|
||||
|
||||
unsigned short *__p__pctype = _ctype + 1;
|
||||
unsigned short *__p__pwctype = _ctype + 1;
|
||||
|
||||
int _isctype (unsigned int c, int ctypeFlags)
|
||||
{
|
||||
return (__p__pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
|
||||
}
|
||||
|
||||
int iswctype(wint_t wc, wctype_t wctypeFlags)
|
||||
{
|
||||
return (__p__pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
|
||||
}
|
||||
|
||||
// obsolete
|
||||
int is_wctype(wint_t wc, wctype_t wctypeFlags)
|
||||
{
|
||||
return (__p__pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
|
||||
}
|
||||
|
||||
/* EOF */
|
14
reactos/lib/msvcrt/ctype/isdigit.c
Normal file
14
reactos/lib/msvcrt/ctype/isdigit.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef isdigit
|
||||
int isdigit(int c)
|
||||
{
|
||||
return _isctype(c,_DIGIT);
|
||||
}
|
||||
|
||||
#undef iswdigit
|
||||
int iswdigit(wint_t c)
|
||||
{
|
||||
return iswctype(c,_DIGIT);
|
||||
}
|
14
reactos/lib/msvcrt/ctype/isgraph.c
Normal file
14
reactos/lib/msvcrt/ctype/isgraph.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef isgraph
|
||||
int isgraph(int c)
|
||||
{
|
||||
return _isctype(c,_PUNCT | _ALPHA | _DIGIT);
|
||||
}
|
||||
|
||||
#undef iswgraph
|
||||
int iswgraph(wint_t c)
|
||||
{
|
||||
return iswctype(c,_PUNCT | _ALPHA | _DIGIT);
|
||||
}
|
13
reactos/lib/msvcrt/ctype/islower.c
Normal file
13
reactos/lib/msvcrt/ctype/islower.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef islower
|
||||
int islower(int c)
|
||||
{
|
||||
return _isctype(c,_LOWER);
|
||||
}
|
||||
|
||||
int iswlower(wint_t c)
|
||||
{
|
||||
return iswctype(c,_LOWER);
|
||||
}
|
13
reactos/lib/msvcrt/ctype/isprint.c
Normal file
13
reactos/lib/msvcrt/ctype/isprint.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef isprint
|
||||
int isprint(int c)
|
||||
{
|
||||
return _isctype(c,_BLANK | _PUNCT | _ALPHA | _DIGIT);
|
||||
}
|
||||
|
||||
int iswprint(wint_t c)
|
||||
{
|
||||
return iswctype((unsigned short)c,_BLANK | _PUNCT | _ALPHA | _DIGIT);
|
||||
}
|
14
reactos/lib/msvcrt/ctype/ispunct.c
Normal file
14
reactos/lib/msvcrt/ctype/ispunct.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef ispunct
|
||||
int ispunct(int c)
|
||||
{
|
||||
return _isctype(c,_PUNCT);
|
||||
}
|
||||
|
||||
#undef iswpunct
|
||||
int iswpunct(wint_t c)
|
||||
{
|
||||
return iswctype(c,_PUNCT);
|
||||
}
|
22
reactos/lib/msvcrt/ctype/isspace.c
Normal file
22
reactos/lib/msvcrt/ctype/isspace.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/ctype/isspace.c
|
||||
* PURPOSE: Checks for a whitespace characters
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef isspace
|
||||
int isspace(int c)
|
||||
{
|
||||
return _isctype(c,_SPACE);
|
||||
}
|
||||
|
||||
#undef iswspace
|
||||
int iswspace(wint_t c)
|
||||
{
|
||||
return iswctype(c,_SPACE);
|
||||
}
|
13
reactos/lib/msvcrt/ctype/isupper.c
Normal file
13
reactos/lib/msvcrt/ctype/isupper.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef isupper
|
||||
int isupper(int c)
|
||||
{
|
||||
return _isctype(c,_UPPER);
|
||||
}
|
||||
|
||||
int iswupper(wint_t c)
|
||||
{
|
||||
return iswctype(c,_UPPER);
|
||||
}
|
15
reactos/lib/msvcrt/ctype/isxdigit.c
Normal file
15
reactos/lib/msvcrt/ctype/isxdigit.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef isxdigit
|
||||
int isxdigit(int c)
|
||||
{
|
||||
return _isctype(c,_HEX);
|
||||
}
|
||||
|
||||
#undef iswxdigit
|
||||
int iswxdigit(wint_t c)
|
||||
{
|
||||
return iswctype(c,_HEX);
|
||||
}
|
||||
|
9
reactos/lib/msvcrt/ctype/toascii.c
Normal file
9
reactos/lib/msvcrt/ctype/toascii.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
|
||||
int __toascii(int c)
|
||||
{
|
||||
return ((unsigned)(c) & 0x7F );
|
||||
}
|
36
reactos/lib/msvcrt/ctype/tolower.c
Normal file
36
reactos/lib/msvcrt/ctype/tolower.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
#undef tolower
|
||||
int tolower(int c)
|
||||
{
|
||||
if (_isctype (c, _UPPER))
|
||||
return (c - ('A' - 'a'));
|
||||
return(c);
|
||||
}
|
||||
|
||||
#undef towlower
|
||||
wchar_t towlower(wchar_t c)
|
||||
{
|
||||
if (iswctype (c, _UPPER))
|
||||
return (c - (L'A' - L'a'));
|
||||
return(c);
|
||||
}
|
||||
|
||||
int _tolower(int c)
|
||||
{
|
||||
if (_isctype (c, _UPPER))
|
||||
return (c - ('A' - 'a'));
|
||||
return(c);
|
||||
}
|
||||
|
||||
/*
|
||||
wchar_t _towlower(wchar_t c)
|
||||
{
|
||||
if (iswctype (c, _UPPER))
|
||||
return (c - (L'A' - L'a'));
|
||||
return(c);
|
||||
}
|
||||
*/
|
||||
|
||||
|
35
reactos/lib/msvcrt/ctype/toupper.c
Normal file
35
reactos/lib/msvcrt/ctype/toupper.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
|
||||
#undef toupper
|
||||
int toupper(int c)
|
||||
{
|
||||
if (_isctype (c, _LOWER))
|
||||
return (c + ('A' - 'a'));
|
||||
return(c);
|
||||
}
|
||||
|
||||
#undef towupper
|
||||
wchar_t towupper(wchar_t c)
|
||||
{
|
||||
if (iswctype (c, _LOWER))
|
||||
return (c + (L'A' - L'a'));
|
||||
return(c);
|
||||
}
|
||||
|
||||
int _toupper(int c)
|
||||
{
|
||||
if (_isctype (c, _LOWER))
|
||||
return (c + ('A' - 'a'));
|
||||
return(c);
|
||||
}
|
||||
|
||||
/*
|
||||
wchar_t _towupper(wchar_t c)
|
||||
{
|
||||
if (iswctype (c, _LOWER))
|
||||
return (c + (L'A' - L'a'));
|
||||
return(c);
|
||||
}
|
||||
*/
|
24
reactos/lib/msvcrt/direct/chdir.c
Normal file
24
reactos/lib/msvcrt/direct/chdir.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/direct.h>
|
||||
|
||||
|
||||
int _chdir( const char *_path )
|
||||
{
|
||||
if ( _path[1] == ':')
|
||||
_chdrive(tolower(_path[0] - 'a')+1);
|
||||
if ( !SetCurrentDirectoryA((char *)_path) )
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wchdir( const wchar_t *_path )
|
||||
{
|
||||
if ( _path[1] == L':')
|
||||
_chdrive(towlower(_path[0] - L'a')+1);
|
||||
if ( !SetCurrentDirectoryW((wchar_t *)_path) )
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
23
reactos/lib/msvcrt/direct/chdrive.c
Normal file
23
reactos/lib/msvcrt/direct/chdrive.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
int cur_drive = 0;
|
||||
|
||||
int _chdrive( int drive )
|
||||
{
|
||||
char d[3];
|
||||
if (!( drive >= 1 && drive <= 26 ))
|
||||
return -1;
|
||||
|
||||
if ( cur_drive != drive ) {
|
||||
cur_drive = drive;
|
||||
d[0] = toupper(cur_drive + '@');
|
||||
d[1] = ':';
|
||||
d[2] = 0;
|
||||
SetCurrentDirectoryA(d);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
42
reactos/lib/msvcrt/direct/getcwd.c
Normal file
42
reactos/lib/msvcrt/direct/getcwd.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
char *_getcwd( char *buffer, int maxlen )
|
||||
{
|
||||
char *cwd;
|
||||
int len;
|
||||
if ( buffer == NULL ) {
|
||||
cwd = malloc(MAX_PATH);
|
||||
len = MAX_PATH;
|
||||
}
|
||||
else {
|
||||
cwd = buffer;
|
||||
len = maxlen;
|
||||
}
|
||||
|
||||
if ( GetCurrentDirectoryA(len,cwd) == 0 )
|
||||
return NULL;
|
||||
|
||||
return cwd;
|
||||
}
|
||||
|
||||
wchar_t *_wgetcwd( wchar_t *buffer, int maxlen )
|
||||
{
|
||||
wchar_t *cwd;
|
||||
int len;
|
||||
if ( buffer == NULL ) {
|
||||
cwd = malloc(MAX_PATH * sizeof(wchar_t));
|
||||
len = MAX_PATH;
|
||||
}
|
||||
else {
|
||||
cwd = buffer;
|
||||
len = maxlen;
|
||||
}
|
||||
|
||||
if ( GetCurrentDirectoryW(len,cwd) == 0 )
|
||||
return NULL;
|
||||
|
||||
return cwd;
|
||||
}
|
44
reactos/lib/msvcrt/direct/getdcwd.c
Normal file
44
reactos/lib/msvcrt/direct/getdcwd.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
|
||||
char* _getdcwd (int nDrive, char* caBuffer, int nBufLen)
|
||||
{
|
||||
int i =0;
|
||||
int dr = _getdrive();
|
||||
|
||||
if ( nDrive < 1 || nDrive > 26 )
|
||||
return NULL;
|
||||
|
||||
if ( dr != nDrive )
|
||||
_chdrive(nDrive);
|
||||
|
||||
i = GetCurrentDirectoryA(nBufLen,caBuffer);
|
||||
if ( i == nBufLen )
|
||||
return NULL;
|
||||
|
||||
if ( dr != nDrive )
|
||||
_chdrive(dr);
|
||||
|
||||
return caBuffer;
|
||||
}
|
||||
|
||||
wchar_t* _wgetdcwd (int nDrive, wchar_t* caBuffer, int nBufLen)
|
||||
{
|
||||
int i =0;
|
||||
int dr = _getdrive();
|
||||
|
||||
if ( nDrive < 1 || nDrive > 26 )
|
||||
return NULL;
|
||||
|
||||
if ( dr != nDrive )
|
||||
_chdrive(nDrive);
|
||||
|
||||
i = GetCurrentDirectoryW(nBufLen,caBuffer);
|
||||
if ( i == nBufLen )
|
||||
return NULL;
|
||||
|
||||
if ( dr != nDrive )
|
||||
_chdrive(dr);
|
||||
|
||||
return caBuffer;
|
||||
}
|
20
reactos/lib/msvcrt/direct/getdfree.c
Normal file
20
reactos/lib/msvcrt/direct/getdfree.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/direct.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
25
reactos/lib/msvcrt/direct/getdrive.c
Normal file
25
reactos/lib/msvcrt/direct/getdrive.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/direct.h>
|
||||
|
||||
|
||||
extern int cur_drive;
|
||||
|
||||
int _getdrive( void )
|
||||
{
|
||||
char Buffer[MAX_PATH];
|
||||
|
||||
if ( cur_drive == 0 ) {
|
||||
GetCurrentDirectoryA(MAX_PATH,Buffer);
|
||||
cur_drive = toupper(Buffer[0] - '@');
|
||||
}
|
||||
|
||||
return cur_drive;
|
||||
}
|
||||
|
||||
unsigned long _getdrives(void)
|
||||
{
|
||||
//fixme get logical drives
|
||||
//return GetLogicalDrives();
|
||||
return 5; // drive A and C
|
||||
}
|
17
reactos/lib/msvcrt/direct/mkdir.c
Normal file
17
reactos/lib/msvcrt/direct/mkdir.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
|
||||
|
||||
int _mkdir( const char *_path )
|
||||
{
|
||||
if (!CreateDirectoryA(_path,NULL))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wmkdir( const wchar_t *_path )
|
||||
{
|
||||
if (!CreateDirectoryW(_path,NULL))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
16
reactos/lib/msvcrt/direct/rmdir.c
Normal file
16
reactos/lib/msvcrt/direct/rmdir.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
|
||||
int _rmdir( const char *_path )
|
||||
{
|
||||
if (!RemoveDirectoryA(_path))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrmdir( const wchar_t *_path )
|
||||
{
|
||||
if (!RemoveDirectoryW(_path))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
|
@ -1,8 +1,21 @@
|
|||
/* $Id: dllmain.c,v 1.1 2000/06/18 10:57:42 ea Exp $
|
||||
/* $Id: dllmain.c,v 1.2 2000/12/03 17:57:25 ekohl Exp $
|
||||
*
|
||||
* ReactOS MSVCRT.DLL Compatibility Library
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
#include <msvcrt/internal/tls.h>
|
||||
|
||||
|
||||
static int nAttachCount = 0;
|
||||
|
||||
unsigned int _osver = 0;
|
||||
unsigned int _winminor = 0;
|
||||
unsigned int _winmajor = 0;
|
||||
unsigned int _winver = 0;
|
||||
|
||||
/* FUNCTIONS **************************************************************/
|
||||
|
||||
BOOLEAN
|
||||
__stdcall
|
||||
DllMain(
|
||||
|
@ -14,14 +27,44 @@ DllMain(
|
|||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
/* initialize version info */
|
||||
_osver = GetVersion();
|
||||
_winmajor = (_osver >> 8) & 0xFF;
|
||||
_winminor = _osver & 0xFF;
|
||||
_winver = (_winmajor << 8) + _winminor;
|
||||
_osver = (_osver >> 16) & 0xFFFF;
|
||||
|
||||
/* create tls stuff */
|
||||
if (!CreateThreadData())
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: more initializations... */
|
||||
|
||||
nAttachCount++;
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
FreeThreadData(NULL);
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
if (nAttachCount > 0)
|
||||
{
|
||||
nAttachCount--;
|
||||
|
||||
/* FIXME: more cleanup... */
|
||||
|
||||
|
||||
/* destroy tls stuff */
|
||||
DestroyThreadData();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
97
reactos/lib/msvcrt/misc/tls.c
Normal file
97
reactos/lib/msvcrt/misc/tls.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* tls.c */
|
||||
|
||||
#include <windows.h>
|
||||
#include <msvcrt/internal/tls.h>
|
||||
|
||||
|
||||
static unsigned long TlsIndex = (unsigned long)-1;
|
||||
|
||||
|
||||
static void InitThreadData(PTHREADDATA ThreadData)
|
||||
{
|
||||
// ThreadData->terrno = 0;
|
||||
// ThreadData->tdoserrno = 0;
|
||||
|
||||
/* 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 */
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: msvcrt.def,v 1.1 2000/06/18 10:57:42 ea Exp $
|
||||
; $Id: msvcrt.def,v 1.1 2000/12/03 18:00:07 ekohl Exp $
|
||||
;
|
||||
; ReactOS MSVCRT Compatibility Library
|
||||
;
|
||||
|
@ -100,9 +100,9 @@ EXPORTS
|
|||
; __fpecode
|
||||
; __getmainargs
|
||||
; __initenv
|
||||
; __isascii
|
||||
; __iscsym
|
||||
; __iscsymf
|
||||
__isascii
|
||||
__iscsym
|
||||
__iscsymf
|
||||
; __lc_codepage
|
||||
; __lc_collate_cp
|
||||
; __lc_handle
|
||||
|
@ -126,9 +126,9 @@ EXPORTS
|
|||
; __p__mbcasemap
|
||||
; __p__mbctype
|
||||
; __p__osver
|
||||
; __p__pctype
|
||||
__p__pctype DATA
|
||||
; __p__pgmptr
|
||||
; __p__pwctype
|
||||
__p__pwctype DATA
|
||||
; __p__timezone
|
||||
; __p__tzname
|
||||
; __p__wcmdln
|
||||
|
@ -144,7 +144,7 @@ EXPORTS
|
|||
; __setusermatherr
|
||||
; __threadhandle
|
||||
; __threadid
|
||||
; __toascii
|
||||
__toascii
|
||||
; __unDName
|
||||
; __unDNameEx
|
||||
; __unguarded_readlc_active
|
||||
|
@ -182,8 +182,8 @@ _beginthreadex
|
|||
; _callnewh
|
||||
; _cexit
|
||||
; _cgets
|
||||
; _chdir
|
||||
; _chdrive
|
||||
_chdir
|
||||
_chdrive
|
||||
; _chgsign
|
||||
; _chkesp
|
||||
; _chmod
|
||||
|
@ -199,7 +199,7 @@ _beginthreadex
|
|||
; _cputs
|
||||
; _creat
|
||||
; _cscanf
|
||||
; _ctype
|
||||
_ctype DATA
|
||||
; _cwait
|
||||
; _daylight
|
||||
; _dstbias
|
||||
|
@ -252,19 +252,19 @@ _endthreadex
|
|||
; _fstati64
|
||||
; _ftime
|
||||
; _ftol
|
||||
; _fullpath
|
||||
_fullpath
|
||||
; _futime
|
||||
; _gcvt
|
||||
; _get_osfhandle
|
||||
; _get_sbh_threshold
|
||||
; _getch
|
||||
; _getche
|
||||
; _getcwd
|
||||
; _getdcwd
|
||||
; _getdiskfree
|
||||
_getcwd
|
||||
_getdcwd
|
||||
_getdiskfree
|
||||
; _getdllprocaddr
|
||||
; _getdrive
|
||||
; _getdrives
|
||||
_getdrive
|
||||
_getdrives
|
||||
; _getmaxstdio
|
||||
; _getmbcp
|
||||
; _getpid
|
||||
|
@ -287,7 +287,7 @@ _endthreadex
|
|||
; _inpw
|
||||
; _iob
|
||||
; _isatty
|
||||
; _isctype
|
||||
_isctype
|
||||
; _ismbbalnum
|
||||
; _ismbbalpha
|
||||
; _ismbbgraph
|
||||
|
@ -318,8 +318,8 @@ _endthreadex
|
|||
; _ismbslead
|
||||
; _ismbstrail
|
||||
; _isnan
|
||||
; _itoa
|
||||
; _itow
|
||||
_itoa
|
||||
_itow
|
||||
; _j0
|
||||
; _j1
|
||||
; _jn
|
||||
|
@ -331,14 +331,14 @@ _endthreadex
|
|||
; _locking
|
||||
; _logb
|
||||
; _longjmpex
|
||||
; _lrotl
|
||||
; _lrotr
|
||||
_lrotl
|
||||
_lrotr
|
||||
; _lsearch
|
||||
; _lseek
|
||||
; _lseeki64
|
||||
; _ltoa
|
||||
; _ltow
|
||||
; _makepath
|
||||
_ltoa
|
||||
_ltow
|
||||
_makepath
|
||||
; _mbbtombc
|
||||
; _mbbtype
|
||||
; _mbcasemap
|
||||
|
@ -394,16 +394,16 @@ _endthreadex
|
|||
; _mbstok
|
||||
; _mbstrlen
|
||||
; _mbsupr
|
||||
; _memccpy
|
||||
; _memicmp
|
||||
; _mkdir
|
||||
_memccpy
|
||||
_memicmp
|
||||
_mkdir
|
||||
; _mktemp
|
||||
; _msize
|
||||
; _nextafter
|
||||
; _onexit
|
||||
; _open
|
||||
; _open_osfhandle
|
||||
; _osver
|
||||
_osver DATA
|
||||
; _outp
|
||||
; _outpd
|
||||
; _outpw
|
||||
|
@ -414,21 +414,21 @@ _endthreadex
|
|||
; _popen
|
||||
; _purecall
|
||||
; _putch
|
||||
; _putenv
|
||||
_putenv
|
||||
; _putw
|
||||
; _putws
|
||||
; _pwctype
|
||||
; _read
|
||||
; _rmdir
|
||||
_rmdir
|
||||
; _rmtmp
|
||||
; _rotl
|
||||
; _rotr
|
||||
_rotl
|
||||
_rotr
|
||||
; _safe_fdiv
|
||||
; _safe_fdivr
|
||||
; _safe_fprem
|
||||
; _safe_fprem1
|
||||
; _scalb
|
||||
; _searchenv
|
||||
_searchenv
|
||||
; _seh_longjmp_unwind
|
||||
; _set_error_mode
|
||||
; _set_sbh_threshold
|
||||
|
@ -451,25 +451,25 @@ _endthreadex
|
|||
; _spawnve
|
||||
; _spawnvp
|
||||
; _spawnvpe
|
||||
; _splitpath
|
||||
_splitpath
|
||||
; _stat
|
||||
; _stati64
|
||||
; _statusfp
|
||||
; _strcmpi
|
||||
_strcmpi
|
||||
; _strdate
|
||||
; _strdup
|
||||
; _strerror
|
||||
; _stricmp
|
||||
; _stricoll
|
||||
; _strlwr
|
||||
; _strncoll
|
||||
; _strnicmp
|
||||
; _strnicoll
|
||||
; _strnset
|
||||
; _strrev
|
||||
; _strset
|
||||
_strdup
|
||||
_strerror
|
||||
_stricmp
|
||||
_stricoll
|
||||
_strlwr
|
||||
_strncoll
|
||||
_strnicmp
|
||||
_strnicoll
|
||||
_strnset
|
||||
_strrev
|
||||
_strset
|
||||
; _strtime
|
||||
; _strupr
|
||||
_strupr
|
||||
; _swab
|
||||
; _sys_errlist
|
||||
; _sys_nerr
|
||||
|
@ -477,14 +477,14 @@ _endthreadex
|
|||
; _telli64
|
||||
; _tempnam
|
||||
; _timezone
|
||||
; _tolower
|
||||
; _toupper
|
||||
_tolower
|
||||
_toupper
|
||||
; _tzname
|
||||
; _tzset
|
||||
; _ui64toa
|
||||
; _ui64tow
|
||||
; _ultoa
|
||||
; _ultow
|
||||
_ultoa
|
||||
_ultow
|
||||
; _umask
|
||||
; _ungetch
|
||||
; _unlink
|
||||
|
@ -495,21 +495,21 @@ _endthreadex
|
|||
; _vsnwprintf
|
||||
; _waccess
|
||||
; _wasctime
|
||||
; _wchdir
|
||||
_wchdir
|
||||
; _wchmod
|
||||
; _wcmdln
|
||||
; _wcreat
|
||||
; _wcsdup
|
||||
; _wcsicmp
|
||||
; _wcsicoll
|
||||
; _wcslwr
|
||||
; _wcsncoll
|
||||
; _wcsnicmp
|
||||
; _wcsnicoll
|
||||
; _wcsnset
|
||||
; _wcsrev
|
||||
; _wcsset
|
||||
; _wcsupr
|
||||
_wcsdup
|
||||
_wcsicmp
|
||||
_wcsicoll
|
||||
_wcslwr
|
||||
_wcsncoll
|
||||
_wcsnicmp
|
||||
_wcsnicoll
|
||||
_wcsnset
|
||||
_wcsrev
|
||||
_wcsset
|
||||
_wcsupr
|
||||
; _wctime
|
||||
; _wenviron
|
||||
; _wexecl
|
||||
|
@ -528,26 +528,26 @@ _endthreadex
|
|||
; _wfopen
|
||||
; _wfreopen
|
||||
; _wfsopen
|
||||
; _wfullpath
|
||||
; _wgetcwd
|
||||
; _wgetdcwd
|
||||
; _wgetenv
|
||||
; _winmajor
|
||||
; _winminor
|
||||
; _winver
|
||||
; _wmakepath
|
||||
; _wmkdir
|
||||
_wfullpath
|
||||
_wgetcwd
|
||||
_wgetdcwd
|
||||
_wgetenv
|
||||
_winmajor DATA
|
||||
_winminor DATA
|
||||
_winver DATA
|
||||
_wmakepath
|
||||
_wmkdir
|
||||
; _wmktemp
|
||||
; _wopen
|
||||
; _wperror
|
||||
; _wpgmptr
|
||||
; _wpopen
|
||||
; _wputenv
|
||||
_wputenv
|
||||
; _wremove
|
||||
; _wrename
|
||||
; _write
|
||||
; _wrmdir
|
||||
; _wsearchenv
|
||||
_wrmdir
|
||||
_wsearchenv
|
||||
; _wsetlocale
|
||||
; _wsopen
|
||||
; _wspawnl
|
||||
|
@ -558,7 +558,7 @@ _endthreadex
|
|||
; _wspawnve
|
||||
; _wspawnvp
|
||||
; _wspawnvpe
|
||||
; _wsplitpath
|
||||
_wsplitpath
|
||||
; _wstat
|
||||
; _wstati64
|
||||
; _wstrdate
|
||||
|
@ -566,27 +566,27 @@ _endthreadex
|
|||
; _wsystem
|
||||
; _wtempnam
|
||||
; _wtmpnam
|
||||
; _wtoi
|
||||
_wtoi
|
||||
; _wtoi64
|
||||
; _wtol
|
||||
_wtol
|
||||
; _wunlink
|
||||
; _wutime
|
||||
; _y0
|
||||
; _y1
|
||||
; _yn
|
||||
; abort
|
||||
; abs
|
||||
abs
|
||||
; acos
|
||||
; asctime
|
||||
; asin
|
||||
; atan
|
||||
; atan2
|
||||
; atexit
|
||||
; atof
|
||||
; atoi
|
||||
; atol
|
||||
; bsearch
|
||||
; calloc
|
||||
atof
|
||||
atoi
|
||||
atol
|
||||
bsearch
|
||||
calloc
|
||||
; ceil
|
||||
; clearerr
|
||||
; clock
|
||||
|
@ -594,7 +594,7 @@ _endthreadex
|
|||
; cosh
|
||||
; ctime
|
||||
; difftime
|
||||
; div
|
||||
div
|
||||
; exit
|
||||
; exp
|
||||
; fabs
|
||||
|
@ -616,7 +616,7 @@ _endthreadex
|
|||
; fputwc
|
||||
; fputws
|
||||
; fread
|
||||
; free
|
||||
free
|
||||
; freopen
|
||||
; frexp
|
||||
; fscanf
|
||||
|
@ -633,49 +633,49 @@ _endthreadex
|
|||
; getwc
|
||||
; getwchar
|
||||
; gmtime
|
||||
; is_wctype
|
||||
; isalnum
|
||||
; isalpha
|
||||
; iscntrl
|
||||
; isdigit
|
||||
; isgraph
|
||||
is_wctype
|
||||
isalnum
|
||||
isalpha
|
||||
iscntrl
|
||||
isdigit
|
||||
isgraph
|
||||
; isleadbyte
|
||||
; islower
|
||||
; isprint
|
||||
; ispunct
|
||||
; isspace
|
||||
; isupper
|
||||
; iswalnum
|
||||
; iswalpha
|
||||
; iswascii
|
||||
; iswcntrl
|
||||
; iswctype
|
||||
; iswdigit
|
||||
; iswgraph
|
||||
; iswlower
|
||||
; iswprint
|
||||
; iswpunct
|
||||
; iswspace
|
||||
; iswupper
|
||||
; iswxdigit
|
||||
; isxdigit
|
||||
; labs
|
||||
islower
|
||||
isprint
|
||||
ispunct
|
||||
isspace
|
||||
isupper
|
||||
iswalnum
|
||||
iswalpha
|
||||
iswascii
|
||||
iswcntrl
|
||||
iswctype
|
||||
iswdigit
|
||||
iswgraph
|
||||
iswlower
|
||||
iswprint
|
||||
iswpunct
|
||||
iswspace
|
||||
iswupper
|
||||
iswxdigit
|
||||
isxdigit
|
||||
labs
|
||||
; ldexp
|
||||
; ldiv
|
||||
ldiv
|
||||
; localeconv
|
||||
; localtime
|
||||
; log
|
||||
; log10
|
||||
; longjmp
|
||||
; malloc
|
||||
malloc
|
||||
; mblen
|
||||
; mbstowcs
|
||||
; mbtowc
|
||||
; memchr
|
||||
; memcmp
|
||||
; memcpy
|
||||
; memmove
|
||||
; memset
|
||||
memchr
|
||||
memcmp
|
||||
memcpy
|
||||
memmove
|
||||
memset
|
||||
; mktime
|
||||
; modf
|
||||
; perror
|
||||
|
@ -689,7 +689,7 @@ _endthreadex
|
|||
; qsort
|
||||
; raise
|
||||
; rand
|
||||
; realloc
|
||||
realloc
|
||||
; remove
|
||||
; rename
|
||||
; rewind
|
||||
|
@ -704,27 +704,27 @@ _endthreadex
|
|||
; sqrt
|
||||
; srand
|
||||
; sscanf
|
||||
; strcat
|
||||
; strchr
|
||||
; strcmp
|
||||
; strcoll
|
||||
; strcpy
|
||||
; strcspn
|
||||
; strerror
|
||||
strcat
|
||||
strchr
|
||||
strcmp
|
||||
strcoll
|
||||
strcpy
|
||||
strcspn
|
||||
strerror
|
||||
; strftime
|
||||
; strlen
|
||||
; strncat
|
||||
; strncmp
|
||||
; strncpy
|
||||
; strpbrk
|
||||
; strrchr
|
||||
; strspn
|
||||
; strstr
|
||||
; strtod
|
||||
; strtok
|
||||
; strtol
|
||||
; strtoul
|
||||
; strxfrm
|
||||
strlen
|
||||
strncat
|
||||
strncmp
|
||||
strncpy
|
||||
strpbrk
|
||||
strrchr
|
||||
strspn
|
||||
strstr
|
||||
strtod
|
||||
strtok
|
||||
strtol
|
||||
strtoul
|
||||
strxfrm
|
||||
; swprintf
|
||||
; swscanf
|
||||
; system
|
||||
|
@ -733,10 +733,10 @@ _endthreadex
|
|||
; time
|
||||
; tmpfile
|
||||
; tmpnam
|
||||
; tolower
|
||||
; toupper
|
||||
; towlower
|
||||
; towupper
|
||||
tolower
|
||||
toupper
|
||||
towlower
|
||||
towupper
|
||||
; ungetc
|
||||
; ungetwc
|
||||
; vfprintf
|
||||
|
@ -745,27 +745,27 @@ _endthreadex
|
|||
; vsprintf
|
||||
; vswprintf
|
||||
; vwprintf
|
||||
; wcscat
|
||||
; wcschr
|
||||
; wcscmp
|
||||
; wcscoll
|
||||
; wcscpy
|
||||
; wcscspn
|
||||
wcscat
|
||||
wcschr
|
||||
wcscmp
|
||||
wcscoll
|
||||
wcscpy
|
||||
wcscspn
|
||||
; wcsftime
|
||||
; wcslen
|
||||
; wcsncat
|
||||
; wcsncmp
|
||||
; wcsncpy
|
||||
; wcspbrk
|
||||
; wcsrchr
|
||||
; wcsspn
|
||||
; wcsstr
|
||||
; wcstod
|
||||
; wcstok
|
||||
; wcstol
|
||||
wcslen
|
||||
wcsncat
|
||||
wcsncmp
|
||||
wcsncpy
|
||||
wcspbrk
|
||||
wcsrchr
|
||||
wcsspn
|
||||
wcsstr
|
||||
wcstod
|
||||
wcstok
|
||||
wcstol
|
||||
; wcstombs
|
||||
; wcstoul
|
||||
; wcsxfrm
|
||||
wcstoul
|
||||
wcsxfrm
|
||||
; wctomb
|
||||
; wprintf
|
||||
; wscanf
|
46
reactos/lib/msvcrt/stdlib/_exit.c
Normal file
46
reactos/lib/msvcrt/stdlib/_exit.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include <windows.h>
|
||||
#include <crtdll/stdlib.h>
|
||||
#include <crtdll/io.h>
|
||||
#include <crtdll/fcntl.h>
|
||||
#include <crtdll/internal/atexit.h>
|
||||
|
||||
struct __atexit *__atexit_ptr = 0;
|
||||
|
||||
void exit(int status)
|
||||
{
|
||||
//int i;
|
||||
struct __atexit *a = __atexit_ptr;
|
||||
__atexit_ptr = 0; /* to prevent infinite loops */
|
||||
while (a)
|
||||
{
|
||||
(a->__function)();
|
||||
a = a->__next;
|
||||
}
|
||||
/*
|
||||
if (__stdio_cleanup_hook)
|
||||
__stdio_cleanup_hook();
|
||||
for (i=0; i<djgpp_last_dtor-djgpp_first_dtor; i++)
|
||||
djgpp_first_dtor[i]();
|
||||
*/
|
||||
/* in case the program set it this way */
|
||||
_setmode(0, O_TEXT);
|
||||
_exit(status);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
|
||||
void _exit(int _status)
|
||||
{
|
||||
ExitProcess(_status);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
void _cexit( void )
|
||||
{
|
||||
// flush
|
||||
}
|
||||
|
||||
void _c_exit( void )
|
||||
{
|
||||
// reset interup vectors
|
||||
}
|
16
reactos/lib/msvcrt/stdlib/abort.c
Normal file
16
reactos/lib/msvcrt/stdlib/abort.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/stdio.h>
|
||||
#include <msvcrt/io.h>
|
||||
#include <msvcrt/signal.h>
|
||||
|
||||
char *msg ="Abort\n\r";
|
||||
|
||||
void abort()
|
||||
{
|
||||
fflush(NULL);
|
||||
fcloseall();
|
||||
raise(SIGABRT);
|
||||
_write(stderr->_file, msg, sizeof(msg)-1);
|
||||
exit(3);
|
||||
}
|
||||
|
8
reactos/lib/msvcrt/stdlib/abs.c
Normal file
8
reactos/lib/msvcrt/stdlib/abs.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
int
|
||||
abs(int j)
|
||||
{
|
||||
return j<0 ? -j : j;
|
||||
}
|
18
reactos/lib/msvcrt/stdlib/atexit.c
Normal file
18
reactos/lib/msvcrt/stdlib/atexit.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/internal/atexit.h>
|
||||
|
||||
int
|
||||
atexit(void (*a)(void))
|
||||
{
|
||||
struct __atexit *ap;
|
||||
if (a == 0)
|
||||
return -1;
|
||||
ap = (struct __atexit *)malloc(sizeof(struct __atexit));
|
||||
if (!ap)
|
||||
return -1;
|
||||
ap->__next = __atexit_ptr;
|
||||
ap->__function = a;
|
||||
__atexit_ptr = ap;
|
||||
return 0;
|
||||
}
|
8
reactos/lib/msvcrt/stdlib/atof.c
Normal file
8
reactos/lib/msvcrt/stdlib/atof.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
double
|
||||
atof(const char *ascii)
|
||||
{
|
||||
return strtod(ascii, 0);
|
||||
}
|
8
reactos/lib/msvcrt/stdlib/atoi.c
Normal file
8
reactos/lib/msvcrt/stdlib/atoi.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
int
|
||||
atoi(const char *str)
|
||||
{
|
||||
return (int)strtol(str, 0, 10);
|
||||
}
|
8
reactos/lib/msvcrt/stdlib/atol.c
Normal file
8
reactos/lib/msvcrt/stdlib/atol.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
long
|
||||
atol(const char *str)
|
||||
{
|
||||
return strtol(str, 0, 10);
|
||||
}
|
8
reactos/lib/msvcrt/stdlib/atold.c
Normal file
8
reactos/lib/msvcrt/stdlib/atold.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <crtdll/stdlib.h>
|
||||
|
||||
long double
|
||||
_atold(const char *ascii)
|
||||
{
|
||||
return _strtold(ascii, 0);
|
||||
}
|
25
reactos/lib/msvcrt/stdlib/bsearch.c
Normal file
25
reactos/lib/msvcrt/stdlib/bsearch.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
24
reactos/lib/msvcrt/stdlib/div.c
Normal file
24
reactos/lib/msvcrt/stdlib/div.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
12
reactos/lib/msvcrt/stdlib/ecvt.c
Normal file
12
reactos/lib/msvcrt/stdlib/ecvt.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/float.h>
|
||||
|
||||
char *ecvtbuf (double, int, int *, int *, char *);
|
||||
|
||||
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);
|
||||
}
|
108
reactos/lib/msvcrt/stdlib/ecvtbuf.c
Normal file
108
reactos/lib/msvcrt/stdlib/ecvtbuf.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/stdio.h>
|
||||
#include <msvcrt/string.h>
|
||||
#include <msvcrt/float.h>
|
||||
#include <msvcrt/alloc.h>
|
||||
// #include <msvcrt/locale.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -1,11 +1,23 @@
|
|||
/* $Id: errno.c,v 1.1 2000/06/18 10:57:42 ea Exp $
|
||||
/* $Id: errno.c,v 1.2 2000/12/03 17:58:38 ekohl Exp $
|
||||
*
|
||||
*/
|
||||
int errno;
|
||||
#include <msvcrt/internal/tls.h>
|
||||
|
||||
int _errno (void)
|
||||
{
|
||||
return errno;
|
||||
return (GetThreadData()->terrno);
|
||||
}
|
||||
|
||||
|
||||
int __set_errno (int error)
|
||||
{
|
||||
PTHREADDATA ThreadData;
|
||||
|
||||
ThreadData = GetThreadData();
|
||||
if (ThreadData)
|
||||
ThreadData->terrno = error;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
12
reactos/lib/msvcrt/stdlib/fcvt.c
Normal file
12
reactos/lib/msvcrt/stdlib/fcvt.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/float.h>
|
||||
|
||||
char *fcvtbuf (double, int, int *, int *, char *);
|
||||
|
||||
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);
|
||||
}
|
61
reactos/lib/msvcrt/stdlib/fcvtbuf.c
Normal file
61
reactos/lib/msvcrt/stdlib/fcvtbuf.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <crtdll/stdlib.h>
|
||||
#include <crtdll/stdio.h>
|
||||
#include <crtdll/string.h>
|
||||
#include <crtdll/float.h>
|
||||
#include <crtdll/alloc.h>
|
||||
// #include <crtdll/locale.h>
|
||||
|
||||
void __ecvround (char *, char *, const char *, int *);
|
||||
char *ecvtbuf (double, int, int *, int *, char *);
|
||||
|
||||
char *
|
||||
fcvtbuf (double value, int ndigits, int *decpt, int *sign, char *buf)
|
||||
{
|
||||
static char INFINITY[] = "Infinity";
|
||||
char decimal = '.' /* localeconv()->decimal_point[0] */;
|
||||
int digits = ndigits >= 0 ? ndigits : 0;
|
||||
char *cvtbuf = (char *)alloca (2*DBL_MAX_10_EXP + 16);
|
||||
char *s = cvtbuf;
|
||||
char *dot;
|
||||
|
||||
sprintf (cvtbuf, "%-+#.*f", DBL_MAX_10_EXP + digits + 1, value);
|
||||
|
||||
/* The sign. */
|
||||
if (*s++ == '-')
|
||||
*sign = 1;
|
||||
else
|
||||
*sign = 0;
|
||||
|
||||
/* Where's the decimal point? */
|
||||
dot = strchr (s, decimal);
|
||||
*decpt = dot ? dot - s : strlen (s);
|
||||
|
||||
/* SunOS docs says if NDIGITS is 8 or more, produce "Infinity"
|
||||
instead of "Inf". */
|
||||
if (strncmp (s, "Inf", 3) == 0)
|
||||
{
|
||||
memcpy (buf, INFINITY, ndigits >= 8 ? 9 : 3);
|
||||
if (ndigits < 8)
|
||||
buf[3] = '\0';
|
||||
return buf;
|
||||
}
|
||||
else if (ndigits < 0)
|
||||
return ecvtbuf (value, *decpt + ndigits, decpt, sign, buf);
|
||||
else if (*s == '0' && value != 0.0)
|
||||
return ecvtbuf (value, ndigits, decpt, sign, buf);
|
||||
else
|
||||
{
|
||||
memcpy (buf, s, *decpt);
|
||||
if (s[*decpt] == decimal)
|
||||
{
|
||||
memcpy (buf + *decpt, s + *decpt + 1, ndigits);
|
||||
buf[*decpt + ndigits] = '\0';
|
||||
}
|
||||
else
|
||||
buf[*decpt] = '\0';
|
||||
__ecvround (buf, buf + *decpt + ndigits - 1,
|
||||
s + *decpt + ndigits + 1, decpt);
|
||||
return buf;
|
||||
}
|
||||
}
|
29
reactos/lib/msvcrt/stdlib/fullpath.c
Normal file
29
reactos/lib/msvcrt/stdlib/fullpath.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/stdlib/fullpath.c
|
||||
* PURPOSE: Gets the fullpathname
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
char *_fullpath( char *absPath, const char *relPath, size_t maxLength )
|
||||
{
|
||||
char *lpFilePart;
|
||||
if ( GetFullPathNameA(relPath,maxLength,absPath,&lpFilePart) == 0 )
|
||||
return NULL;
|
||||
|
||||
return absPath;
|
||||
}
|
||||
|
||||
wchar_t *_wfullpath( wchar_t *absPath, const wchar_t *relPath, size_t maxLength )
|
||||
{
|
||||
wchar_t *lpFilePart;
|
||||
if ( GetFullPathNameW(relPath,maxLength,absPath,&lpFilePart) == 0 )
|
||||
return NULL;
|
||||
|
||||
return absPath;
|
||||
}
|
31
reactos/lib/msvcrt/stdlib/gcvt.c
Normal file
31
reactos/lib/msvcrt/stdlib/gcvt.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <crtdll/stdlib.h>
|
||||
#include <crtdll/stdio.h>
|
||||
#include <crtdll/string.h>
|
||||
|
||||
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;
|
||||
}
|
23
reactos/lib/msvcrt/stdlib/getenv.c
Normal file
23
reactos/lib/msvcrt/stdlib/getenv.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
char *getenv(const char *name)
|
||||
{
|
||||
char *buffer;
|
||||
buffer = (char *)malloc(MAX_PATH);
|
||||
buffer[0] = 0;
|
||||
if ( GetEnvironmentVariableA(name,buffer,MAX_PATH) == 0 )
|
||||
return NULL;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
wchar_t *_wgetenv(const wchar_t *name)
|
||||
{
|
||||
wchar_t *buffer;
|
||||
buffer = (wchar_t *)malloc(MAX_PATH * sizeof(wchar_t));
|
||||
buffer[0] = 0;
|
||||
if ( GetEnvironmentVariableW(name,buffer,MAX_PATH) == 0 )
|
||||
return NULL;
|
||||
return buffer;
|
||||
}
|
134
reactos/lib/msvcrt/stdlib/itoa.c
Normal file
134
reactos/lib/msvcrt/stdlib/itoa.c
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* 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 Boudewijn Dekker
|
||||
*/
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
char *
|
||||
_ultoa(unsigned long value, char *string, int radix)
|
||||
{
|
||||
char tmp[33];
|
||||
char *tp = tmp;
|
||||
long i;
|
||||
unsigned long v = value;
|
||||
char *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+'0';
|
||||
else
|
||||
*tp++ = i + 'a' - 10;
|
||||
}
|
||||
|
||||
if (string == 0)
|
||||
string = (char *)malloc((tp-tmp)+1);
|
||||
sp = string;
|
||||
|
||||
while (tp > tmp)
|
||||
*sp++ = *--tp;
|
||||
*sp = 0;
|
||||
return string;
|
||||
}
|
135
reactos/lib/msvcrt/stdlib/itow.c
Normal file
135
reactos/lib/msvcrt/stdlib/itow.c
Normal file
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* 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 Boudewijn Dekker
|
||||
*/
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
wchar_t *
|
||||
_itow(int value, wchar_t *string, int radix)
|
||||
{
|
||||
wchar_t tmp[33];
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
wchar_t *
|
||||
_ltow(long value, wchar_t *string, int radix)
|
||||
{
|
||||
wchar_t tmp[33];
|
||||
wchar_t *tp = tmp;
|
||||
long i;
|
||||
unsigned long 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 long)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;
|
||||
}
|
||||
|
||||
wchar_t *
|
||||
_ultow(unsigned long value, wchar_t *string, int radix)
|
||||
{
|
||||
wchar_t tmp[33];
|
||||
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;
|
||||
}
|
8
reactos/lib/msvcrt/stdlib/labs.c
Normal file
8
reactos/lib/msvcrt/stdlib/labs.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
long
|
||||
labs(long j)
|
||||
{
|
||||
return j<0 ? -j : j;
|
||||
}
|
25
reactos/lib/msvcrt/stdlib/ldiv.c
Normal file
25
reactos/lib/msvcrt/stdlib/ldiv.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
54
reactos/lib/msvcrt/stdlib/makepath.c
Normal file
54
reactos/lib/msvcrt/stdlib/makepath.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
void _makepath( char *path, const char *drive, const char *dir, const char *fname, const char *ext )
|
||||
{
|
||||
int dir_len;
|
||||
if ( drive != NULL ) {
|
||||
strcat(path,drive);
|
||||
strcat(path,":");
|
||||
}
|
||||
|
||||
if ( dir != NULL ) {
|
||||
strcat(path,dir);
|
||||
if ( *dir != '\\' )
|
||||
strcat(path,"\\");
|
||||
dir_len = strlen(dir);
|
||||
if ( *(dir + dir_len - 1) != '\\' )
|
||||
strcat(path,"\\");
|
||||
}
|
||||
if ( fname != NULL ) {
|
||||
strcat(path,fname);
|
||||
if ( ext != NULL ) {
|
||||
if ( *ext != '.')
|
||||
strcat(path,".");
|
||||
strcat(path,ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 ) {
|
||||
wcscat(path,drive);
|
||||
wcscat(path,L":");
|
||||
}
|
||||
|
||||
if ( dir != NULL ) {
|
||||
wcscat(path,dir);
|
||||
if ( *dir != L'\\' )
|
||||
wcscat(path,L"\\");
|
||||
dir_len = wcslen(dir);
|
||||
if ( *(dir + dir_len - 1) != L'\\' )
|
||||
wcscat(path,L"\\");
|
||||
}
|
||||
if ( fname != NULL ) {
|
||||
wcscat(path,fname);
|
||||
if ( ext != NULL ) {
|
||||
if ( *ext != L'.')
|
||||
wcscat(path,L".");
|
||||
wcscat(path,ext);
|
||||
}
|
||||
}
|
||||
}
|
23
reactos/lib/msvcrt/stdlib/malloc.c
Normal file
23
reactos/lib/msvcrt/stdlib/malloc.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
void* malloc(size_t _size)
|
||||
{
|
||||
return(HeapAlloc(GetProcessHeap(),0,_size));
|
||||
}
|
||||
|
||||
void free(void* _ptr)
|
||||
{
|
||||
HeapFree(GetProcessHeap(),0,_ptr);
|
||||
}
|
||||
|
||||
void* calloc(size_t _nmemb, size_t _size)
|
||||
{
|
||||
return(HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, _nmemb*_size));
|
||||
}
|
||||
|
||||
void* realloc(void* _ptr, size_t _size)
|
||||
{
|
||||
return(HeapReAlloc(GetProcessHeap(),0,_ptr,_size));
|
||||
}
|
17
reactos/lib/msvcrt/stdlib/mbstow.c
Normal file
17
reactos/lib/msvcrt/stdlib/mbstow.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
int mblen (const char* mbs, size_t sizeString)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t mbstowcs (wchar_t* wcaDest, const char* mbsConvert, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mbtowc (wchar_t* wcDest, const char* mbConvert, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
11
reactos/lib/msvcrt/stdlib/mbstowcs.c
Normal file
11
reactos/lib/msvcrt/stdlib/mbstowcs.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
|
||||
size_t mbstowcs( wchar_t *wcstr, const char *mbstr, size_t count )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mbtowc( wchar_t *wchar, const char *mbchar, size_t count )
|
||||
{
|
||||
return 0;
|
||||
}
|
24
reactos/lib/msvcrt/stdlib/obsol.c
Normal file
24
reactos/lib/msvcrt/stdlib/obsol.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
#undef _cpumode
|
||||
unsigned char _cpumode = 0;
|
||||
unsigned char *_cpumode_dll = &_cpumode;
|
||||
|
||||
void _seterrormode(int nMode)
|
||||
{
|
||||
SetErrorMode(nMode);
|
||||
return;
|
||||
}
|
||||
|
||||
void _beep(unsigned nFreq, unsigned nDur)
|
||||
{
|
||||
Beep(nFreq,nDur);
|
||||
return;
|
||||
}
|
||||
|
||||
void _sleep(unsigned long ulTime)
|
||||
{
|
||||
Sleep(ulTime);
|
||||
return;
|
||||
}
|
34
reactos/lib/msvcrt/stdlib/putenv.c
Normal file
34
reactos/lib/msvcrt/stdlib/putenv.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
|
||||
int _putenv(const char *val)
|
||||
{
|
||||
char buffer[1024];
|
||||
char *epos;
|
||||
|
||||
strcpy(buffer,val);
|
||||
epos = strchr(buffer, '=');
|
||||
if ( epos == NULL )
|
||||
return -1;
|
||||
|
||||
*epos = 0;
|
||||
|
||||
return SetEnvironmentVariableA(buffer,epos+1);
|
||||
}
|
||||
|
||||
int _wputenv(const wchar_t *val)
|
||||
{
|
||||
wchar_t buffer[1024];
|
||||
wchar_t *epos;
|
||||
|
||||
wcscpy(buffer,val);
|
||||
epos = wcschr(buffer, L'=');
|
||||
if ( epos == NULL )
|
||||
return -1;
|
||||
|
||||
*epos = 0;
|
||||
|
||||
return SetEnvironmentVariableW(buffer,epos+1);
|
||||
}
|
237
reactos/lib/msvcrt/stdlib/qsort.c
Normal file
237
reactos/lib/msvcrt/stdlib/qsort.c
Normal file
|
@ -0,0 +1,237 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
/*-
|
||||
* 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 */
|
||||
|
||||
static int (*qcmp)(const void *, const void *); /* the comparison routine */
|
||||
static int qsz; /* size of each record */
|
||||
static int thresh; /* THRESHold in chars */
|
||||
static int mthresh; /* MTHRESHold in chars */
|
||||
|
||||
/*
|
||||
* 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(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 + qsz * ((lo / qsz) >> 1);
|
||||
if (lo >= mthresh)
|
||||
{
|
||||
j = (qcmp((jj = base), i) > 0 ? jj : i);
|
||||
if (qcmp(j, (tmp = max - qsz)) > 0)
|
||||
{
|
||||
/* switch to first loser */
|
||||
j = (j == jj ? i : jj);
|
||||
if (qcmp(j, tmp) < 0)
|
||||
j = tmp;
|
||||
}
|
||||
if (j != i)
|
||||
{
|
||||
ii = qsz;
|
||||
do {
|
||||
c = *i;
|
||||
*i++ = *j;
|
||||
*j++ = c;
|
||||
} while (--ii);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Semi-standard quicksort partitioning/swapping
|
||||
*/
|
||||
for (i = base, j = max - qsz; ; )
|
||||
{
|
||||
while (i < mid && qcmp(i, mid) <= 0)
|
||||
i += qsz;
|
||||
while (j > mid)
|
||||
{
|
||||
if (qcmp(mid, j) <= 0)
|
||||
{
|
||||
j -= qsz;
|
||||
continue;
|
||||
}
|
||||
tmp = i + qsz; /* value of i after swap */
|
||||
if (i == mid)
|
||||
{
|
||||
/* j <-> mid, new mid is j */
|
||||
mid = jj = j;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* i <-> j */
|
||||
jj = j;
|
||||
j -= 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 -= qsz;
|
||||
}
|
||||
swap:
|
||||
ii = 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) + qsz;
|
||||
if ((lo = j - base) <= (hi = max - i))
|
||||
{
|
||||
if (lo >= thresh)
|
||||
qst(base, j);
|
||||
base = i;
|
||||
lo = hi;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hi >= thresh)
|
||||
qst(i, max);
|
||||
max = j;
|
||||
}
|
||||
} while (lo >= 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...
|
||||
*/
|
||||
void
|
||||
qsort(const void *base0, size_t n, size_t size, _pfunccmp_t compar)
|
||||
{
|
||||
char *base = (char *)base0;
|
||||
char c, *i, *j, *lo, *hi;
|
||||
char *min, *max;
|
||||
|
||||
if (n <= 1)
|
||||
return;
|
||||
qsz = size;
|
||||
qcmp = compar;
|
||||
thresh = qsz * THRESH;
|
||||
mthresh = qsz * MTHRESH;
|
||||
max = base + n * qsz;
|
||||
if (n >= THRESH)
|
||||
{
|
||||
qst(base, max);
|
||||
hi = base + 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 += qsz) < hi; )
|
||||
if (qcmp(j, lo) > 0)
|
||||
j = lo;
|
||||
if (j != base)
|
||||
{
|
||||
/* swap j into place */
|
||||
for (i = base, hi = base + 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 += qsz) < max; )
|
||||
{
|
||||
while (qcmp(hi -= qsz, min) > 0)
|
||||
/* void */;
|
||||
if ((hi += qsz) != min) {
|
||||
for (lo = min + qsz; --lo >= min; )
|
||||
{
|
||||
c = *lo;
|
||||
for (i = j = lo; (j -= qsz) >= hi; i = j)
|
||||
*i = *j;
|
||||
*i = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
20
reactos/lib/msvcrt/stdlib/rand.c
Normal file
20
reactos/lib/msvcrt/stdlib/rand.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/internal/tls.h>
|
||||
|
||||
int
|
||||
rand(void)
|
||||
{
|
||||
PTHREADDATA ThreadData = GetThreadData();
|
||||
|
||||
ThreadData->tnext = ThreadData->tnext * 0x5deece66dLL + 11;
|
||||
return (int)((ThreadData->tnext >> 16) & RAND_MAX);
|
||||
}
|
||||
|
||||
void
|
||||
srand(unsigned int seed)
|
||||
{
|
||||
PTHREADDATA ThreadData = GetThreadData();
|
||||
|
||||
ThreadData->tnext = (unsigned long long)seed;
|
||||
}
|
56
reactos/lib/msvcrt/stdlib/rot.c
Normal file
56
reactos/lib/msvcrt/stdlib/rot.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/stdlib/rot.c
|
||||
* PURPOSE: Performs a bitwise rotation
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 03/04/99: Created
|
||||
*/
|
||||
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
51
reactos/lib/msvcrt/stdlib/senv.c
Normal file
51
reactos/lib/msvcrt/stdlib/senv.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
void _searchenv(const char *file,const char *var,char *path )
|
||||
{
|
||||
char *env = getenv(var);
|
||||
char *x;
|
||||
char *y;
|
||||
char *FilePart;
|
||||
|
||||
x = strchr(env,'=');
|
||||
if ( x != NULL ) {
|
||||
*x = 0;
|
||||
x++;
|
||||
}
|
||||
y = strchr(env,';');
|
||||
while ( y != NULL ) {
|
||||
*y = 0;
|
||||
if ( SearchPathA(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) {
|
||||
return;
|
||||
}
|
||||
x = y+1;
|
||||
y = strchr(env,';');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void _wsearchenv(const wchar_t *file,const wchar_t *var,wchar_t *path)
|
||||
{
|
||||
wchar_t *env = _wgetenv(var);
|
||||
wchar_t *x;
|
||||
wchar_t *y;
|
||||
wchar_t *FilePart;
|
||||
|
||||
x = wcschr(env,L'=');
|
||||
if ( x != NULL ) {
|
||||
*x = 0;
|
||||
x++;
|
||||
}
|
||||
y = wcschr(env,L';');
|
||||
while ( y != NULL ) {
|
||||
*y = 0;
|
||||
if ( SearchPathW(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) {
|
||||
return;
|
||||
}
|
||||
x = y+1;
|
||||
y = wcschr(env,L';');
|
||||
}
|
||||
return;
|
||||
}
|
80
reactos/lib/msvcrt/stdlib/splitp.c
Normal file
80
reactos/lib/msvcrt/stdlib/splitp.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext )
|
||||
{
|
||||
char *tmp_drive;
|
||||
char *tmp_dir;
|
||||
char *tmp_ext;
|
||||
|
||||
tmp_drive = (char *)strchr(path,':');
|
||||
if ( tmp_drive != (char *)NULL ) {
|
||||
strncpy(drive,tmp_drive-1,1);
|
||||
*(drive+1) = 0;
|
||||
}
|
||||
else {
|
||||
*drive = 0;
|
||||
tmp_drive = (char *)path;
|
||||
}
|
||||
|
||||
tmp_dir = (char *)strrchr(path,'\\');
|
||||
if( tmp_dir != NULL && tmp_dir != tmp_drive + 1 ) {
|
||||
strncpy(dir,tmp_drive+1,tmp_dir - tmp_drive);
|
||||
*(dir + (tmp_dir - tmp_drive)) = 0;
|
||||
}
|
||||
else
|
||||
*dir =0;
|
||||
|
||||
tmp_ext = ( char *)strrchr(path,'.');
|
||||
if ( tmp_ext != NULL ) {
|
||||
strcpy(ext,tmp_ext);
|
||||
}
|
||||
else
|
||||
*ext = 0;
|
||||
|
||||
if ( tmp_dir != NULL ) {
|
||||
strncpy(fname,tmp_dir+1,tmp_ext - tmp_dir - 1);
|
||||
*(fname + (tmp_ext - tmp_dir -1)) = 0;
|
||||
}
|
||||
else
|
||||
strncpy(fname,path,tmp_ext - path);
|
||||
}
|
||||
|
||||
void _wsplitpath( const wchar_t *path, wchar_t *drive, wchar_t *dir, wchar_t *fname, wchar_t *ext )
|
||||
{
|
||||
wchar_t *tmp_drive;
|
||||
wchar_t *tmp_dir;
|
||||
wchar_t *tmp_ext;
|
||||
|
||||
tmp_drive = (wchar_t *)wcschr(path,L':');
|
||||
if ( tmp_drive != (wchar_t *)NULL ) {
|
||||
wcsncpy(drive,tmp_drive-1,1);
|
||||
*(drive+1) = 0;
|
||||
}
|
||||
else {
|
||||
*drive = 0;
|
||||
tmp_drive = (wchar_t *)path;
|
||||
}
|
||||
|
||||
tmp_dir = (wchar_t *)wcsrchr(path,L'\\');
|
||||
if( tmp_dir != NULL && tmp_dir != tmp_drive + 1 ) {
|
||||
wcsncpy(dir,tmp_drive+1,tmp_dir - tmp_drive);
|
||||
*(dir + (tmp_dir - tmp_drive)) = 0;
|
||||
}
|
||||
else
|
||||
*dir =0;
|
||||
|
||||
tmp_ext = (wchar_t *)wcsrchr(path,L'.');
|
||||
if ( tmp_ext != NULL ) {
|
||||
wcscpy(ext,tmp_ext);
|
||||
}
|
||||
else
|
||||
*ext = 0;
|
||||
|
||||
if ( tmp_dir != NULL ) {
|
||||
wcsncpy(fname,tmp_dir+1,tmp_ext - tmp_dir - 1);
|
||||
*(fname + (tmp_ext - tmp_dir -1)) = 0;
|
||||
}
|
||||
else
|
||||
wcsncpy(fname,path,tmp_ext - path);
|
||||
}
|
97
reactos/lib/msvcrt/stdlib/strtod.c
Normal file
97
reactos/lib/msvcrt/stdlib/strtod.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
91
reactos/lib/msvcrt/stdlib/strtol.c
Normal file
91
reactos/lib/msvcrt/stdlib/strtol.c
Normal file
|
@ -0,0 +1,91 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <limits.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
122
reactos/lib/msvcrt/stdlib/strtold.c
Normal file
122
reactos/lib/msvcrt/stdlib/strtold.c
Normal file
|
@ -0,0 +1,122 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <crtdll/stdlib.h>
|
||||
#include <crtdll/ctype.h>
|
||||
//#include <crtdll/unconst.h>
|
||||
|
||||
static double powten[] =
|
||||
{
|
||||
1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L
|
||||
1e512L, 1e512L*1e512L, 1e2048L, 1e4096L
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
84
reactos/lib/msvcrt/stdlib/strtoll.c
Normal file
84
reactos/lib/msvcrt/stdlib/strtoll.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <limits.h>
|
||||
#include <crtdll/ctype.h>
|
||||
#include <crtdll/errno.h>
|
||||
#include <crtdll/stdlib.h>
|
||||
//#include <crtdll/unconst.h>
|
||||
|
||||
/* constants used in Solaris */
|
||||
#define LLONG_MIN -9223372036854775807L-1L
|
||||
#define LLONG_MAX 9223372036854775807L
|
||||
#define ULLONG_MAX 18446744073709551615UL
|
||||
|
||||
long
|
||||
strtoll(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == '+')
|
||||
c = *s++;
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X'))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
|
||||
/* to prevent overflow, we take max-1 and add 1 after division */
|
||||
cutoff = neg ? -(LLONG_MIN+1) : LLONG_MAX-1;
|
||||
cutlim = cutoff % base;
|
||||
cutoff /= base;
|
||||
if (++cutlim == base)
|
||||
{
|
||||
cutlim = 0;
|
||||
cutoff++;
|
||||
}
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else
|
||||
{
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0)
|
||||
{
|
||||
acc = neg ? LLONG_MIN : LLONG_MAX;
|
||||
errno = ERANGE;
|
||||
}
|
||||
else if (neg)
|
||||
acc *= -1;
|
||||
if (endptr != 0)
|
||||
*endptr = any ? (char *)s - 1 : (char *)nptr;
|
||||
return acc;
|
||||
}
|
74
reactos/lib/msvcrt/stdlib/strtoul.c
Normal file
74
reactos/lib/msvcrt/stdlib/strtoul.c
Normal file
|
@ -0,0 +1,74 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <limits.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
/*
|
||||
* Convert a string to an unsigned long integer.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
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;
|
||||
}
|
76
reactos/lib/msvcrt/stdlib/strtoull.c
Normal file
76
reactos/lib/msvcrt/stdlib/strtoull.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <limits.h>
|
||||
#include <crtdll/ctype.h>
|
||||
#include <crtdll/errno.h>
|
||||
#include <crtdll/stdlib.h>
|
||||
//#include <crtdll/unconst.h>
|
||||
|
||||
/*
|
||||
* Convert a string to an unsigned long integer.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
unsigned long
|
||||
strtoull(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 / base;
|
||||
cutlim = (unsigned long)ULONG_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 = ULONG_MAX;
|
||||
errno = ERANGE;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != 0)
|
||||
*endptr = any ? (char *)s - 1 : (char *)nptr;
|
||||
return acc;
|
||||
}
|
18
reactos/lib/msvcrt/stdlib/swab.c
Normal file
18
reactos/lib/msvcrt/stdlib/swab.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <crtdll/stdlib.h>
|
||||
|
||||
void _swab (const char* caFrom, char* caTo, size_t sizeToCopy)
|
||||
{
|
||||
unsigned long temp;
|
||||
|
||||
sizeToCopy >>= 1; sizeToCopy++;
|
||||
#define STEP temp = *((const char *)caFrom)++,*((char *)caTo)++ = *((const char *)caFrom)++,*((char *)caTo)++ = temp
|
||||
/* round to multiple of 8 */
|
||||
while ((--sizeToCopy) & 07)
|
||||
STEP;
|
||||
sizeToCopy >>= 3;
|
||||
while (--sizeToCopy >= 0) {
|
||||
STEP; STEP; STEP; STEP;
|
||||
STEP; STEP; STEP; STEP;
|
||||
}
|
||||
}
|
95
reactos/lib/msvcrt/stdlib/wcstod.c
Normal file
95
reactos/lib/msvcrt/stdlib/wcstod.c
Normal file
|
@ -0,0 +1,95 @@
|
|||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
33
reactos/lib/msvcrt/stdlib/wcstol.c
Normal file
33
reactos/lib/msvcrt/stdlib/wcstol.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
14
reactos/lib/msvcrt/stdlib/wcstom.c
Normal file
14
reactos/lib/msvcrt/stdlib/wcstom.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <crtdll/stdlib.h>
|
||||
|
||||
size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wctomb (char* mbDest, wchar_t wc)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
122
reactos/lib/msvcrt/stdlib/wcstomb.c
Normal file
122
reactos/lib/msvcrt/stdlib/wcstomb.c
Normal file
|
@ -0,0 +1,122 @@
|
|||
/* 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 <crtdll/stdlib.h>
|
||||
#include <crtdll/wchar.h>
|
||||
|
||||
#include <crtdll/errno.h>
|
||||
#include <crtdll/wchar.h>
|
||||
#include <crtdll/internal/file.h>
|
||||
|
||||
#ifndef EILSEQ
|
||||
#define EILSEQ EINVAL
|
||||
#endif
|
||||
|
||||
static const wchar_t encoding_mask[] =
|
||||
{
|
||||
~0x7ff, ~0xffff, ~0x1fffff, ~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'. */
|
||||
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)
|
||||
{
|
||||
/* 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;
|
||||
}
|
152
reactos/lib/msvcrt/stdlib/wcstombs.c
Normal file
152
reactos/lib/msvcrt/stdlib/wcstombs.c
Normal file
|
@ -0,0 +1,152 @@
|
|||
/* 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 <crtdll/stdlib.h>
|
||||
#include <crtdll/wchar.h>
|
||||
|
||||
#include <crtdll/errno.h>
|
||||
#include <crtdll/wchar.h>
|
||||
|
||||
#ifndef EILSEQ
|
||||
#define EILSEQ EINVAL
|
||||
#endif
|
||||
|
||||
|
||||
static const wchar_t encoding_mask[] =
|
||||
{
|
||||
~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff
|
||||
};
|
||||
|
||||
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 internal;
|
||||
|
||||
|
||||
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'. */
|
||||
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 = &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 (wc < 0 || wc > 0x7fffffff)
|
||||
{
|
||||
/* This is no correct ISO 10646 character. */
|
||||
__set_errno (EILSEQ);
|
||||
return (size_t) -1;
|
||||
}
|
||||
|
||||
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)
|
101
reactos/lib/msvcrt/stdlib/wcstoul.c
Normal file
101
reactos/lib/msvcrt/stdlib/wcstoul.c
Normal file
|
@ -0,0 +1,101 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <limits.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
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
|
11
reactos/lib/msvcrt/stdlib/wtoi.c
Normal file
11
reactos/lib/msvcrt/stdlib/wtoi.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
|
||||
int _wtoi( const wchar_t *str )
|
||||
{
|
||||
return (int)wcstol(str, 0, 10);
|
||||
}
|
||||
|
||||
long _wtol( const wchar_t *str )
|
||||
{
|
||||
return (int)wcstol(str, 0, 10);
|
||||
}
|
9
reactos/lib/msvcrt/string/memccpy.c
Normal file
9
reactos/lib/msvcrt/string/memccpy.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <msvcrt/string.h>
|
||||
|
||||
|
||||
void *
|
||||
_memccpy (void *to, const void *from,int c,size_t count)
|
||||
{
|
||||
memcpy(to,from,count);
|
||||
return memchr(to,c,count);
|
||||
}
|
17
reactos/lib/msvcrt/string/memchr.c
Normal file
17
reactos/lib/msvcrt/string/memchr.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
|
||||
void *
|
||||
memchr(const void *s, int c, size_t n)
|
||||
{
|
||||
if (n)
|
||||
{
|
||||
const char *p = s;
|
||||
do {
|
||||
if (*p++ == c)
|
||||
return (void *)(p-1);
|
||||
} while (--n != 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
17
reactos/lib/msvcrt/string/memcmp.c
Normal file
17
reactos/lib/msvcrt/string/memcmp.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
int
|
||||
memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
if (n != 0)
|
||||
{
|
||||
const unsigned char *p1 = s1, *p2 = s2;
|
||||
|
||||
do {
|
||||
if (*p1++ != *p2++)
|
||||
return (*--p1 - *--p2);
|
||||
} while (--n != 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
16
reactos/lib/msvcrt/string/memcpy.c
Normal file
16
reactos/lib/msvcrt/string/memcpy.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <msvcrt/string.h>
|
||||
|
||||
/* This is the most reliable way to avoid incompatibilities
|
||||
in available built-in functions on various systems. */
|
||||
void *
|
||||
memcpy (void *to, const void *from, size_t count)
|
||||
{
|
||||
register char *f = (char *)from;
|
||||
register char *t = (char *)to;
|
||||
register int i = count;
|
||||
|
||||
while (i-- > 0)
|
||||
*t++ = *f++;
|
||||
|
||||
return to;
|
||||
}
|
20
reactos/lib/msvcrt/string/memicmp.c
Normal file
20
reactos/lib/msvcrt/string/memicmp.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
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;
|
||||
}
|
36
reactos/lib/msvcrt/string/memmove.c
Normal file
36
reactos/lib/msvcrt/string/memmove.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include <msvcrt/string.h>
|
||||
|
||||
|
||||
void * memmove(void *dest,const void *src,size_t count)
|
||||
{
|
||||
char *char_dest = (char *)dest;
|
||||
char *char_src = (char *)src;
|
||||
|
||||
if ((char_dest <= char_src) || (char_dest >= (char_src+count)))
|
||||
{
|
||||
/* non-overlapping buffers */
|
||||
while(count > 0)
|
||||
{
|
||||
*char_dest = *char_src;
|
||||
char_dest++;
|
||||
char_src++;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* overlaping buffers */
|
||||
char_dest = (char *)dest + count - 1;
|
||||
char_src = (char *)src + count - 1;
|
||||
|
||||
while(count > 0)
|
||||
{
|
||||
*char_dest = *char_src;
|
||||
char_dest--;
|
||||
char_src--;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
13
reactos/lib/msvcrt/string/memset.c
Normal file
13
reactos/lib/msvcrt/string/memset.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include <msvcrt/string.h>
|
||||
|
||||
void * memset(void *src,int val,size_t count)
|
||||
{
|
||||
char *char_src = (char *)src;
|
||||
|
||||
while(count>0) {
|
||||
*char_src = val;
|
||||
char_src++;
|
||||
count--;
|
||||
}
|
||||
return src;
|
||||
}
|
12
reactos/lib/msvcrt/string/strcat.c
Normal file
12
reactos/lib/msvcrt/string/strcat.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
char *
|
||||
strcat(char *s, const char *append)
|
||||
{
|
||||
char *save = s;
|
||||
|
||||
for (; *s; ++s);
|
||||
while ((*s++ = *append++));
|
||||
return save;
|
||||
}
|
19
reactos/lib/msvcrt/string/strchr.c
Normal file
19
reactos/lib/msvcrt/string/strchr.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
|
||||
char *strchr(const char *s, int c)
|
||||
{
|
||||
char cc = c;
|
||||
while (*s)
|
||||
{
|
||||
if (*s == cc)
|
||||
return (char *)s;
|
||||
s++;
|
||||
}
|
||||
if (cc == 0)
|
||||
return (char *)s;
|
||||
return 0;
|
||||
}
|
||||
|
14
reactos/lib/msvcrt/string/strcmp.c
Normal file
14
reactos/lib/msvcrt/string/strcmp.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
int strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 == *s2)
|
||||
{
|
||||
if (*s1 == 0)
|
||||
return 0;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return *(unsigned const char *)s1 - *(unsigned const char *)(s2);
|
||||
}
|
39
reactos/lib/msvcrt/string/strcoll.c
Normal file
39
reactos/lib/msvcrt/string/strcoll.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
/* 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
|
||||
int strcoll (const char* s1, const char* s2)
|
||||
{
|
||||
return strcmp(s1,s2);
|
||||
}
|
||||
|
||||
int _stricoll (const char* s1, const char* s2)
|
||||
{
|
||||
return _stricmp(s1,s2);
|
||||
}
|
||||
|
||||
int _strncoll (const char *s1, const char *s2, size_t c)
|
||||
{
|
||||
return strncmp(s1,s2,c);
|
||||
}
|
||||
|
||||
int _strnicoll (const char *s1, const char *s2, size_t c)
|
||||
{
|
||||
return _strnicmp(s1,s2,c);
|
||||
}
|
||||
#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
|
11
reactos/lib/msvcrt/string/strcpy.c
Normal file
11
reactos/lib/msvcrt/string/strcpy.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
|
||||
char* strcpy(char *to, const char *from)
|
||||
{
|
||||
char *save = to;
|
||||
|
||||
for (; (*to = *from); ++from, ++to);
|
||||
return save;
|
||||
}
|
19
reactos/lib/msvcrt/string/strcspn.c
Normal file
19
reactos/lib/msvcrt/string/strcspn.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
size_t strcspn(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p, *spanp;
|
||||
char c, sc;
|
||||
|
||||
for (p = s1;;)
|
||||
{
|
||||
c = *p++;
|
||||
spanp = s2;
|
||||
do {
|
||||
if ((sc = *spanp++) == c)
|
||||
return p - 1 - s1;
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
16
reactos/lib/msvcrt/string/strdup.c
Normal file
16
reactos/lib/msvcrt/string/strdup.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
100
reactos/lib/msvcrt/string/strerror.c
Normal file
100
reactos/lib/msvcrt/string/strerror.c
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/errno.h>
|
||||
|
||||
|
||||
char __syserr00[] = "No Error";
|
||||
char __syserr01[] = "Input to function out of range (EDOM)";
|
||||
char __syserr02[] = "Output of function out of range (ERANGE)";
|
||||
char __syserr03[] = "Argument list too long (E2BIG)";
|
||||
char __syserr04[] = "Permission denied (EACCES)";
|
||||
char __syserr05[] = "Resource temporarily unavailable (EAGAIN)";
|
||||
char __syserr06[] = "Bad file descriptor (EBADF)";
|
||||
char __syserr07[] = "Resource busy (EBUSY)";
|
||||
char __syserr08[] = "No child processes (ECHILD)";
|
||||
char __syserr09[] = "Resource deadlock avoided (EDEADLK)";
|
||||
char __syserr10[] = "File exists (EEXIST)";
|
||||
char __syserr11[] = "Bad address (EFAULT)";
|
||||
char __syserr12[] = "File too large (EFBIG)";
|
||||
char __syserr13[] = "Interrupted system call (EINTR)";
|
||||
char __syserr14[] = "Invalid argument (EINVAL)";
|
||||
char __syserr15[] = "Input or output error (EIO)";
|
||||
char __syserr16[] = "Is a directory (EISDIR)";
|
||||
char __syserr17[] = "Too many open files (EMFILE)";
|
||||
char __syserr18[] = "Too many links (EMLINK)";
|
||||
char __syserr19[] = "File name too long (ENAMETOOLONG)";
|
||||
char __syserr20[] = "Too many open files in system (ENFILE)";
|
||||
char __syserr21[] = "No such device (ENODEV)";
|
||||
char __syserr22[] = "No such file or directory (ENOENT)";
|
||||
char __syserr23[] = "Unable to execute file (ENOEXEC)";
|
||||
char __syserr24[] = "No locks available (ENOLCK)";
|
||||
char __syserr25[] = "Not enough memory (ENOMEM)";
|
||||
char __syserr26[] = "No space left on drive (ENOSPC)";
|
||||
char __syserr27[] = "Function not implemented (ENOSYS)";
|
||||
char __syserr28[] = "Not a directory (ENOTDIR)";
|
||||
char __syserr29[] = "Directory not empty (ENOTEMPTY)";
|
||||
char __syserr30[] = "Inappropriate I/O control operation (ENOTTY)";
|
||||
char __syserr31[] = "No such device or address (ENXIO)";
|
||||
char __syserr32[] = "Operation not permitted (EPERM)";
|
||||
char __syserr33[] = "Broken pipe (EPIPE)";
|
||||
char __syserr34[] = "Read-only file system (EROFS)";
|
||||
char __syserr35[] = "Invalid seek (ESPIPE)";
|
||||
char __syserr36[] = "No such process (ESRCH)";
|
||||
char __syserr37[] = "Improper link (EXDEV)";
|
||||
char __syserr38[] = "No more files (ENMFILE)";
|
||||
|
||||
const 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
|
||||
};
|
||||
|
||||
int __sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]);
|
||||
|
||||
int* _sys_nerr_dll = &__sys_nerr;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
char *_strerror(const char *s)
|
||||
{
|
||||
if ( s == NULL )
|
||||
return strerror(errno);
|
||||
|
||||
return strerror(atoi(s));
|
||||
}
|
22
reactos/lib/msvcrt/string/stricmp.c
Normal file
22
reactos/lib/msvcrt/string/stricmp.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
int
|
||||
_strcmpi(const char *s1, const char *s2)
|
||||
{
|
||||
return _stricmp(s1,s2);
|
||||
}
|
14
reactos/lib/msvcrt/string/strlen.c
Normal file
14
reactos/lib/msvcrt/string/strlen.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
size_t
|
||||
strlen(const char *str)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
if (str == 0)
|
||||
return 0;
|
||||
for (s = str; *s; ++s);
|
||||
return s-str;
|
||||
}
|
||||
|
23
reactos/lib/msvcrt/string/strlwr.c
Normal file
23
reactos/lib/msvcrt/string/strlwr.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* 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 <msvcrt/string.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
char * _strlwr(char *x)
|
||||
{
|
||||
char *y=x;
|
||||
|
||||
while (*y) {
|
||||
*y=tolower(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
22
reactos/lib/msvcrt/string/strncat.c
Normal file
22
reactos/lib/msvcrt/string/strncat.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
char *
|
||||
strncat(char *dst, const char *src, size_t n)
|
||||
{
|
||||
if (n != 0)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
|
||||
while (*d != 0)
|
||||
d++;
|
||||
do {
|
||||
if ((*d = *s++) == 0)
|
||||
break;
|
||||
d++;
|
||||
} while (--n != 0);
|
||||
*d = 0;
|
||||
}
|
||||
return dst;
|
||||
}
|
18
reactos/lib/msvcrt/string/strncmp.c
Normal file
18
reactos/lib/msvcrt/string/strncmp.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
|
||||
int
|
||||
strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
do {
|
||||
if (*s1 != *s2++)
|
||||
return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
|
||||
if (*s1++ == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
return 0;
|
||||
}
|
21
reactos/lib/msvcrt/string/strncpy.c
Normal file
21
reactos/lib/msvcrt/string/strncpy.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
char *
|
||||
strncpy(char *dst, const char *src, size_t n)
|
||||
{
|
||||
if (n != 0) {
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
{
|
||||
while (--n != 0)
|
||||
*d++ = 0;
|
||||
break;
|
||||
}
|
||||
} while (--n != 0);
|
||||
}
|
||||
return dst;
|
||||
}
|
17
reactos/lib/msvcrt/string/strnicmp.c
Normal file
17
reactos/lib/msvcrt/string/strnicmp.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
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;
|
||||
}
|
14
reactos/lib/msvcrt/string/strnlen.c
Normal file
14
reactos/lib/msvcrt/string/strnlen.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
size_t
|
||||
strnlen(const char *str, size_t count)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
if (str == 0)
|
||||
return 0;
|
||||
for (s = str; *s && count; ++s, count--);
|
||||
return s-str;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue