diff --git a/reactos/lib/crtdll/stdio/doprnt.c b/reactos/lib/crtdll/stdio/doprnt.c index ad4a15a9436..9e06dea9231 100644 --- a/reactos/lib/crtdll/stdio/doprnt.c +++ b/reactos/lib/crtdll/stdio/doprnt.c @@ -315,5 +315,10 @@ int _doprnt(const char *fmt, va_list args, FILE *f) return 0; } +int _dowprnt(const wchar_t *fmt, va_list args, FILE *f) +{ + return 0; +} + diff --git a/reactos/lib/crtdll/stdio/fprintf.c b/reactos/lib/crtdll/stdio/fprintf.c index fbca105d4ed..014dcacf3c2 100644 --- a/reactos/lib/crtdll/stdio/fprintf.c +++ b/reactos/lib/crtdll/stdio/fprintf.c @@ -24,3 +24,26 @@ fprintf(register FILE *iop, const char *fmt, ...) len = _doprnt(fmt, (&fmt)+1, iop); return ferror(iop) ? EOF : len; } + +int +fwprintf(register FILE *iop, const wchar_t *fmt, ...) +{ + int len; + wchar_t localbuf[BUFSIZ]; + + if (iop->_flag & _IONBF) + { + iop->_flag &= ~_IONBF; + iop->_ptr = iop->_base = localbuf; + iop->_bufsiz = BUFSIZ; + len = _dowprnt(fmt, (&fmt)+sizeof(wchar_t), iop); + fflush(iop); + iop->_flag |= _IONBF; + iop->_base = NULL; + iop->_bufsiz = 0; + iop->_cnt = 0; + } + else + len = _dowprnt(fmt, (va_list)(&fmt)+sizeof(wchar_t), iop); + return ferror(iop) ? EOF : len; +} diff --git a/reactos/lib/crtdll/stdio/printf.c b/reactos/lib/crtdll/stdio/printf.c index 0666bfb2e10..cb4acd850cd 100644 --- a/reactos/lib/crtdll/stdio/printf.c +++ b/reactos/lib/crtdll/stdio/printf.c @@ -17,3 +17,17 @@ printf(const char *fmt, ...) return ferror(stdout) ? EOF : len; } + +int wprintf(const wchar_t *fmt, ...) +{ + int len; + + len = _dowprnt(fmt, (&fmt)+sizeof(wchar_t), stdout); + + /* People were confused when printf() didn't flush stdout, + so we'll do it to reduce confusion */ + if (stdout->_flag & _IOLBF) + fflush(stdout); + + return ferror(stdout) ? EOF : len; +} diff --git a/reactos/lib/crtdll/stdio/sprintf.c b/reactos/lib/crtdll/stdio/sprintf.c index 87039b9a91e..86012f5f939 100644 --- a/reactos/lib/crtdll/stdio/sprintf.c +++ b/reactos/lib/crtdll/stdio/sprintf.c @@ -17,3 +17,16 @@ sprintf(char *str, const char *fmt, ...) *_strbuf._ptr = 0; return len; } + +swprintf(wchar_t *str, const wchar_t *fmt, ...) +{ + FILE _strbuf; + int len; + + _strbuf._flag = _IOWRT|_IOSTRG; + _strbuf._ptr = str; + _strbuf._cnt = INT_MAX; + len = _dowprnt(fmt,(va_list) &(fmt)+sizeof(wchar_t), &_strbuf); + *_strbuf._ptr = 0; + return len; +} diff --git a/reactos/lib/crtdll/stdio/vfprintf.c b/reactos/lib/crtdll/stdio/vfprintf.c index 8b4f5e690f8..debfe0715b4 100644 --- a/reactos/lib/crtdll/stdio/vfprintf.c +++ b/reactos/lib/crtdll/stdio/vfprintf.c @@ -25,3 +25,25 @@ vfprintf(FILE *f, const char *fmt, va_list ap) len = _doprnt(fmt, ap, f); return (ferror(f) ? EOF : len); } + +int vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) +{ + int len; + wchar_t localbuf[BUFSIZ]; + + if (f->_flag & _IONBF) + { + f->_flag &= ~_IONBF; + f->_ptr = f->_base = localbuf; + f->_bufsiz = BUFSIZ; + len = _dowprnt(fmt, ap, f); + (void)fflush(f); + f->_flag |= _IONBF; + f->_base = NULL; + f->_bufsiz = 0; + f->_cnt = 0; + } + else + len = _dowprnt(fmt, ap, f); + return (ferror(f) ? EOF : len); +} diff --git a/reactos/lib/crtdll/stdio/vprintf.c b/reactos/lib/crtdll/stdio/vprintf.c index c9e71d9bb31..2c436e9e940 100644 --- a/reactos/lib/crtdll/stdio/vprintf.c +++ b/reactos/lib/crtdll/stdio/vprintf.c @@ -11,3 +11,12 @@ vprintf(const char *fmt, va_list ap) len = _doprnt(fmt, ap, stdout); return (ferror(stdout) ? EOF : len); } + +int +vwprintf(const wchar_t *fmt, va_list ap) +{ + int len; + + len = _dowprnt(fmt, ap, stdout); + return (ferror(stdout) ? EOF : len); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdio/vsprintf.c b/reactos/lib/crtdll/stdio/vsprintf.c index 425725acade..ba4803bb839 100644 --- a/reactos/lib/crtdll/stdio/vsprintf.c +++ b/reactos/lib/crtdll/stdio/vsprintf.c @@ -17,3 +17,16 @@ vsprintf(char *str, const char *fmt, va_list ap) *f._ptr = 0; return len; } + +vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap) +{ + FILE f; + int len; + + f._flag = _IOWRT|_IOSTRG; + f._ptr = str; + f._cnt = INT_MAX; + len = _dowprnt(fmt, ap, &f); + *f._ptr = 0; + return len; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdlib/Exit.c b/reactos/lib/crtdll/stdlib/Exit.c index 606f660853b..59364a9c53f 100644 --- a/reactos/lib/crtdll/stdlib/Exit.c +++ b/reactos/lib/crtdll/stdlib/Exit.c @@ -4,7 +4,6 @@ #include #include -void _exit(int _status); struct __atexit *__atexit_ptr = 0; @@ -34,7 +33,7 @@ exit(int status) void _exit(int _status) { - //ExitProcess(_status); + ExitProcess(_status); } void _cexit( void ) @@ -45,4 +44,4 @@ void _cexit( void ) void _c_exit( void ) { // reset interup vectors -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/stdlib/fullpath.c b/reactos/lib/crtdll/stdlib/fullpath.c index 35a68e7439e..a7844561803 100644 --- a/reactos/lib/crtdll/stdlib/fullpath.c +++ b/reactos/lib/crtdll/stdlib/fullpath.c @@ -10,16 +10,9 @@ #include #include -#undef fullpath -char *fullpath( char *absPath, const char *relPath, size_t maxLength ) -{ - return _fullpath(absPath,relPath,maxLength ); -} char *_fullpath( char *absPath, const char *relPath, size_t maxLength ) { - - char *lpFilePart; if ( GetFullPathName(relPath,maxLength,absPath,&lpFilePart) == 0 ) return NULL; diff --git a/reactos/lib/crtdll/stdlib/malloc.c b/reactos/lib/crtdll/stdlib/malloc.c index bfc854715bb..9fdcfaba550 100644 --- a/reactos/lib/crtdll/stdlib/malloc.c +++ b/reactos/lib/crtdll/stdlib/malloc.c @@ -1,33 +1,23 @@ #include #include -//#include -#include +//#include void* malloc(size_t _size) { - return(HeapAlloc(GetProcessHeap(), - 0, - _size)); + return(HeapAlloc(GetProcessHeap(),0,_size)); } void free(void* _ptr) { - HeapFree(GetProcessHeap(), - 0, - _ptr); + HeapFree(GetProcessHeap(),0,_ptr); } void* calloc(size_t _nmemb, size_t _size) { - return(HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - _nmemb*_size)); + return(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,_nmemb*_size)); } void* realloc(void* _ptr, size_t _size) { - return(HeapReAlloc(GetProcessHeap(), - 0, - _ptr, - _size)); + return(HeapReAlloc(GetProcessHeap(),0, _ptr, _size)); } diff --git a/reactos/lib/crtdll/stdlib/mbstow.c b/reactos/lib/crtdll/stdlib/mbstow.c new file mode 100644 index 00000000000..15160593543 --- /dev/null +++ b/reactos/lib/crtdll/stdlib/mbstow.c @@ -0,0 +1,17 @@ +#include + + +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; +} diff --git a/reactos/lib/crtdll/stdlib/obsol.c b/reactos/lib/crtdll/stdlib/obsol.c new file mode 100644 index 00000000000..ddb0f063c6a --- /dev/null +++ b/reactos/lib/crtdll/stdlib/obsol.c @@ -0,0 +1,20 @@ +#include +#include + +void _seterrormode(int nMode) +{ + SetErrorMode(nMode); + return; +} + +void _beep(unsigned nFreq, unsigned dur) +{ + Beep(nFreq,nDur); + return; +} + +void _sleep(unsigned long ulTime) +{ + Sleep(ulTime); + return; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdlib/putenv.c b/reactos/lib/crtdll/stdlib/putenv.c index cb276f7ada6..f69ac31406d 100644 --- a/reactos/lib/crtdll/stdlib/putenv.c +++ b/reactos/lib/crtdll/stdlib/putenv.c @@ -3,9 +3,8 @@ #include - int -putenv(const char *val) +_putenv(const char *val) { char buffer[1024]; @@ -27,4 +26,4 @@ putenv(const char *val) - \ No newline at end of file + diff --git a/reactos/lib/crtdll/stdlib/strtod.c b/reactos/lib/crtdll/stdlib/strtod.c index 832cb2efc12..8fec8235046 100644 --- a/reactos/lib/crtdll/stdlib/strtod.c +++ b/reactos/lib/crtdll/stdlib/strtod.c @@ -2,7 +2,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include #include - +#include double strtod(const char *s, char **sret) @@ -95,3 +95,97 @@ strtod(const char *s, char **sret) *sret = (char *)s; return r * sign; } + + +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 == ' ') || (*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 = (wchar_t *)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 = (wchar_t *)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 = (wchar_t *)s; + return r * sign; +} + diff --git a/reactos/lib/crtdll/stdlib/strtol.c b/reactos/lib/crtdll/stdlib/strtol.c index 362f9bcce2e..aec08d1f477 100644 --- a/reactos/lib/crtdll/stdlib/strtol.c +++ b/reactos/lib/crtdll/stdlib/strtol.c @@ -3,6 +3,7 @@ #include #include #include +#include long @@ -89,3 +90,90 @@ strtol(const char *nptr, char **endptr, int base) *endptr = any ? (char *)s - 1 : (char *)nptr; return acc; } + + +long +wcstol(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; + + /* + * 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; + errno = ERANGE; + } + else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr; + return acc; +} + diff --git a/reactos/lib/crtdll/stdlib/strtoul.c b/reactos/lib/crtdll/stdlib/strtoul.c index d62bd5366b0..9638aaefe1d 100644 --- a/reactos/lib/crtdll/stdlib/strtoul.c +++ b/reactos/lib/crtdll/stdlib/strtoul.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include /* * Convert a string to an unsigned long integer. @@ -70,6 +70,70 @@ strtoul(const char *nptr, char **endptr, int base) else if (neg) acc = -acc; if (endptr != 0) - *endptr = any ? unconst(s, char *) - 1 : unconst(nptr, char *); + *endptr = any ? (char *)s - 1 : (char *)nptr; return acc; } + +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 (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; + errno = ERANGE; + } + else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr; + return acc; +} + diff --git a/reactos/lib/crtdll/stdlib/wcstom.c b/reactos/lib/crtdll/stdlib/wcstom.c new file mode 100644 index 00000000000..cdd11106509 --- /dev/null +++ b/reactos/lib/crtdll/stdlib/wcstom.c @@ -0,0 +1,17 @@ +#include + +size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size) +{ + return 0; +} + +int wctomb (char* mbDest, wchar_t wc) +{ + return 0; +} + +int mblen (const char* mbs, size_t sizeString) +{ + return 0; +} +