+++ /dev/null
-*.d
-*.o
-*.sym
+++ /dev/null
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/assert.h>
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/signal.h>
-
-void _assert(const char *msg, const char *file, int line)
-{
- /* Assertion failed at foo.c line 45: x<y */
- fprintf(stderr, "Assertion failed at %s line %d: %s\n", file, line, msg);
- raise(SIGABRT);
-}
-#include <crtdll/conio.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/stdlib.h>
-char *
-_cgets(char *string)
+
+char *_cgets(char *string)
{
unsigned len = 0;
unsigned int maxlen_wanted;
-#include <crtdll/stdio.h>
-#include <crtdll/conio.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/conio.h>
int
_cprintf(const char *fmt, ...)
* 28/12/98: Created
*/
#include <windows.h>
-#include <crtdll/conio.h>
-#include <crtdll/string.h>
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
int _cputs(const char *_str)
{
-#include <crtdll/conio.h>
-#include <stdarg.h>
-#include <stdio.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/stdarg.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/stdio.h>
-int
-_cscanf(char *fmt, ...)
+int _cscanf(char *fmt, ...)
{
- int cnt;
+ int cnt;
- va_list ap;
-
- //fixme cscanf should scan the console's keyboard
- va_start(ap, fmt);
- cnt = __vscanf(fmt, ap);
- va_end(ap);
- return cnt;
-}
+ va_list ap;
+ //fixme cscanf should scan the console's keyboard
+ va_start(ap, fmt);
+ cnt = __vscanf(fmt, ap);
+ va_end(ap);
+ return cnt;
+}
* 28/12/98: Created
*/
#include <windows.h>
-#include <crtdll/conio.h>
-#include <crtdll/stdio.h>
-#include <crtdll/io.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/console.h>
-extern int char_avail;
-extern int ungot_char;
+int _getch(void)
+{
+ DWORD NumberOfCharsRead = 0;
+ char c;
+ if (char_avail) {
+ c = ungot_char;
+ char_avail = 0;
+ } else {
+ ReadConsoleA(_get_osfhandle(stdin->_file),
+ &c,
+ 1,
+ &NumberOfCharsRead,
+ NULL);
+ }
+ if (c == 10)
+ c = 13;
+ putchar(c);
+ return c;
+}
-int
-_getch(void)
+#if 0
+int _getche(void)
{
-
- DWORD NumberOfCharsRead = 0;
- char c;
- if (char_avail)
- {
- c = ungot_char;
- char_avail = 0;
- }
- else
- {
- ReadConsoleA(_get_osfhandle(stdin->_file), &c,1,&NumberOfCharsRead ,NULL);
-
- }
- if ( c == 10 )
- c = 13;
- putchar(c);
- return c;
+ int c;
+
+ c = _getch();
+ _putch(c);
+
+ return c;
}
+#endif
* 28/12/98: Created
*/
-#include <crtdll/process.h>
-#include <crtdll/conio.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/internal/console.h>
-extern int char_avail;
-int
-getche(void)
+int getche(void)
{
if (char_avail)
/*
*/
#include <windows.h>
-#include <crtdll/conio.h>
-#include <crtdll/stdio.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/internal/console.h>
// FIXME PeekCosoleInput returns more than keyboard hits
-extern int char_avail;
-int
-_kbhit(void)
+int _kbhit(void)
{
- INPUT_RECORD InputRecord;
+ //INPUT_RECORD InputRecord;
DWORD NumberRead=0;
if (char_avail)
return(1);
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/conio.h>
#include <windows.h>
+#include <msvcrt/conio.h>
int _putch( int c )
{
DWORD NumberOfCharsWritten;
+
if ( WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL) ) {
return -1;
}
-
return NumberOfCharsWritten;
}
* 28/12/98: Created
*/
-#include <crtdll/process.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/internal/console.h>
+
#define EOF -1
int char_avail = 0;
-char ungot_char = 0;
+int ungot_char = 0;
-int
-_ungetch(int c)
+int _ungetch(int c)
{
if (char_avail)
return(EOF);
--- /dev/null
+/* 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 */
+};
+
+/* EOF */
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/crtdll/conio/getch.c
- * PURPOSE: Writes a character to stdout
+ * FILE: lib/crtdll/ctype/isascii.c
+ * PURPOSE: Checks if a character is ascii
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/ctype.h>
+#include <msvcrt/ctype.h>
int __isascii(int c)
{
{
return __isascii(c);
}
-
-
-
-
-
-
-
-
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/ctype.h>
+#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 */
-};
+
+extern unsigned short _ctype[];
unsigned short *_pctype_dll = _ctype + 1;
unsigned short *_pwctype_dll = _ctype + 1;
-int _isctype (unsigned int c, int ctypeFlags)
+
+int _isctype(unsigned int c, int ctypeFlags)
{
return (_pctype_dll[(unsigned char)(c & 0xFF)] & ctypeFlags);
}
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/ctype.h>
+#include <msvcrt/ctype.h>
#undef isgraph
int isgraph(int c)
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/ctype.h>
+#include <msvcrt/ctype.h>
#undef isprint
int isprint(int c)
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/ctype.h>
+#include <msvcrt/ctype.h>
#undef isspace
int isspace(int c)
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/ctype.h>
+#include <msvcrt/ctype.h>
#undef tolower
int tolower(int c)
return(c);
}
+/*
wchar_t _towlower(wchar_t c)
{
if (iswctype (c, _UPPER))
return (c - (L'A' - L'a'));
return(c);
}
-
+*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/ctype.h>
-#include <crtdll/wchar.h>
+#include <msvcrt/ctype.h>
+
#undef toupper
int toupper(int c)
return(c);
}
+/*
wchar_t _towupper(wchar_t c)
{
if (iswctype (c, _LOWER))
return (c + (L'A' - L'a'));
return(c);
}
+*/
+
#include <windows.h>
-#include <crtdll/direct.h>
-#include <crtdll/ctype.h>
-
+#include <msvcrt/ctype.h>
+#include <msvcrt/direct.h>
int _chdir( const char *_path )
_chdrive(tolower(_path[0] - 'a')+1);
if ( !SetCurrentDirectoryA((char *)_path) )
return -1;
-
return 0;
}
-
-
-
-#include <crtdll/direct.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/ctype.h>
#include <windows.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/direct.h>
+#include <msvcrt/stdlib.h>
-int cur_drive = 0;
+int cur_drive = 0;
int _chdrive( int drive )
d[2] = 0;
SetCurrentDirectoryA(d);
}
-
-
return 0;
}
#include <windows.h>
-#include <crtdll/direct.h>
-#include <crtdll/stdlib.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 {
+ } else {
cwd = buffer;
len = maxlen;
}
-
- if ( GetCurrentDirectoryA(len,cwd) == 0 )
+ if (GetCurrentDirectoryA(len, cwd) == 0) {
return NULL;
-
+ }
return cwd;
}
-
#include <windows.h>
-#include <crtdll/direct.h>
+#include <msvcrt/direct.h>
char* _getdcwd (int nDrive, char* caBuffer, int nBufLen)
{
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;
}
-#include <crtdll/direct.h>
#include <windows.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/direct.h>
unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace)
-#include <crtdll/direct.h>
-#include <crtdll/ctype.h>
#include <windows.h>
-
-extern int cur_drive;
+#include <msvcrt/ctype.h>
+#include <msvcrt/direct.h>
+extern int cur_drive;
int _getdrive( void )
{
-#include <crtdll/direct.h>
#include <windows.h>
+#include <msvcrt/direct.h>
int _mkdir( const char *_path )
-#include <crtdll/direct.h>
#include <windows.h>
-
+#include <msvcrt/direct.h>
int _rmdir( const char *_path )
* Significantly revised and rewinddir, seekdir and telldir added by Colin
* Peters <colin@fu.is.saga-u.ac.jp>
*
- * $Revision: 1.2 $
- * $Author: ariadne $
- * $Date: 1999/04/02 21:43:47 $
+ * $Revision: 1.3 $
+ * $Author: robd $
+ * $Date: 2002/11/24 18:42:13 $
*
*/
-#include <crtdll/stdlib.h>
-/* #include <crtdll/ctype.h> */
-#include <crtdll/errno.h>
-#include <crtdll/string.h>
-#include <crtdll/dir.h>
-#include <crtdll/direct.h>
-#include <crtdll/sys/stat.h>
+#include <msvcrt/stdlib.h>
+/* #include <msvcrt/ctype.h> */
+#include <msvcrt/errno.h>
+#include <msvcrt/string.h>
+#include <msvcrt/dir.h>
+#include <msvcrt/direct.h>
+#include <msvcrt/sys/stat.h>
-#include <crtdll/dirent.h>
+#include <msvcrt/dirent.h>
#define SUFFIX "*"
#define SLASH "\\"
#include <windows.h>
+
+#ifdef __GNUC__
+
int _abnormal_termination(void)
{
printf("Abnormal Termination\n");
// return AbnormalTermination();
}
+
+#else
+#endif
#include <windows.h>
+#include <ntos/except.h>
+
+
+#ifdef __GNUC__
+#else
+#endif
+
+ULONG DbgPrint(PCH Format, ...)
+{
+ return 0;
+}
+
+VOID STDCALL
+MsvcrtDebug(ULONG Value)
+{
+ //DbgPrint("MsvcrtDebug 0x%.08x\n", Value);
+}
+
EXCEPTION_DISPOSITION
_except_handler2(
-struct _EXCEPTION_RECORD *ExceptionRecord,
-void *Frame,
-struct _CONTEXT *ContextRecord,
-void *DispatcherContext)
+ struct _EXCEPTION_RECORD* ExceptionRecord, void* Frame,
+ struct _CONTEXT *ContextRecord, void* DispatcherContext)
{
- printf("exception handler\n");
+ //printf("_except_handler2()\n");
+ return 0;
}
+#include <windows.h>
+#include <ntos/except.h>
+
+
struct _exception {
- int type;
- char *name;
- double arg1;
- double arg2;
- double retval;
- } ;
-
-int _matherr(struct _exception *e)
+ int type;
+ char* name;
+ double arg1;
+ double arg2;
+ double retval;
+} ;
+
+
+int _matherr(struct _exception* e)
{
return 0;
}
+
+
+// not exported by NTDLL
+void __setusermatherr(int (*handler)(struct _exception*))
+{
+
+}
+
+
#define _FPIEEE_RECORD void
int _fpieee_flt(
- unsigned long exception_code,
- struct _EXCEPTION_POINTERS *ExceptionPointer,
- int (* handler)(_FPIEEE_RECORD *)
+ unsigned long exception_code,
+ struct _EXCEPTION_POINTERS* ExceptionPointer,
+ int (*handler)(_FPIEEE_RECORD*)
)
{
- return 0;
+ return 0;
}
-#include <crtdll/float.h>
+#include <msvcrt/float.h>
unsigned int _clearfp (void)
{
-
unsigned short __res = _statusfp();
-
+#ifdef __GNUC__
__asm__ __volatile__ (
"fclex \n\t"
);
+#else
+#endif /*__GNUC__*/
return __res;
}
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/float.h>
+#include <msvcrt/float.h>
unsigned int _controlfp (unsigned int unNew, unsigned int unMask)
{
unsigned int _control87 (unsigned int unNew, unsigned int unMask)
{
-
register unsigned int __res;
+#ifdef __GNUC__
__asm__ __volatile__ (
"pushl %%eax \n\t" /* make room on stack */
"fstcw (%%esp) \n\t"
"fldcw (%%esp) \n\t"
"popl %%edx \n\t"
-
:"=r" (__res):"r" (unNew),"r" (unMask): "ax", "dx", "cx");
-/* :"=a" (__res):"c" (unNew),"d" (unMask):"ax", "dx", "cx"); */
-
+#else
+#endif /*__GNUC__*/
return __res;
}
-#include <crtdll/float.h>
-#include <crtdll/internal/ieee.h>
+#include <msvcrt/float.h>
+#include <msvcrt/internal/ieee.h>
double _copysign (double __d, double __s)
{
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-double _logb (double __x);
+#include <msvcrt/float.h>
double _logb (double __x)
{
- register double __value, __junk;
+ register double __value;
+#ifdef __GNUC__
+ register double __junk;
__asm __volatile__
("fxtract\n\t"
: "=t" (__junk), "=u" (__value) : "0" (__x));
-
+#else
+#endif /*__GNUC__*/
return __value;
}
-#include <crtdll/float.h>
-#include <crtdll/internal/ieee.h>
+#include <msvcrt/float.h>
+#include <msvcrt/internal/ieee.h>
double _scalb( double __x, long e )
{
x->exponent += e;
return __x;
-
}
-#include <crtdll/float.h>
+#include <msvcrt/float.h>
unsigned int _statusfp (void)
{
register unsigned short __res;
-
+#ifdef __GNUC__
__asm__ __volatile__ (
"fstsw %0 \n\t"
// "movzwl %ax, %eax"
:"=a" (__res)
);
+#else
+#endif /*__GNUC__*/
return __res;
}
-#include <crtdll/io.h>
#include <windows.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
-#ifndef F_OK
- #define F_OK 0x01
-#endif
-#ifndef R_OK
- #define R_OK 0x02
-#endif
-#ifndef W_OK
- #define W_OK 0x04
-#endif
-#ifndef X_OK
- #define X_OK 0x08
-#endif
-#ifndef D_OK
- #define D_OK 0x10
-#endif
int _access( const char *_path, int _amode )
{
- DWORD Attributes = GetFileAttributesA(_path);
+ DWORD Attributes = GetFileAttributesA(_path);
+ DPRINT("_access('%s', %x)\n", _path, _amode);
- if ( Attributes == -1 )
- return -1;
-
- if ( (_amode & W_OK) == W_OK ) {
- if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY )
- return -1;
- }
- if ( (_amode & D_OK) == D_OK ) {
- if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY )
- return -1;
- }
-
- return 0;
-
+ if (Attributes == -1) {
+ __set_errno(ENOENT);
+ return -1;
+ }
+ if ((_amode & W_OK) == W_OK) {
+ if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) {
+ __set_errno(EACCES);
+ return -1;
+ }
+ }
+ if ((_amode & D_OK) == D_OK) {
+ if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
+ __set_errno(EACCES);
+ return -1;
+ }
+ }
+ return 0;
}
#include <windows.h>
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
#define mode_t int
-int
-_chmod(const char *filename, mode_t mode)
+
+int _chmod(const char* filename, mode_t mode)
{
- DWORD FileAttributes = 0;
-
- FileAttributes = GetFileAttributes(filename);
- if ( FileAttributes == -1 )
- return -1;
-
- if ( mode == 0 )
- return -1;
-
-
- if ( (mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
- FileAttributes &= FILE_ATTRIBUTE_READONLY;
- else if ( ((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE) )
- FileAttributes &= FILE_ATTRIBUTE_NORMAL;
- else
- FileAttributes &= FILE_ATTRIBUTE_NORMAL;
-
-
-
- if ( SetFileAttributes(filename,FileAttributes) == FALSE )
- return -1;
-
- return 1;
+ DWORD FileAttributes = 0;
+ DPRINT("_chmod('%s', %x)\n", filename, mode);
+
+ FileAttributes = GetFileAttributesA(filename);
+ if ( FileAttributes == -1 )
+ return -1;
+
+ if ( mode == 0 )
+ return -1;
+
+ if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
+ FileAttributes &= FILE_ATTRIBUTE_READONLY;
+ else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE))
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+ else
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+
+ if (SetFileAttributesA(filename, FileAttributes) == FALSE)
+ return -1;
+
+ return 1;
}
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
int _chsize(int _fd, long size)
{
+ DPRINT("_chsize(fd %d, size %d)\n", _fd, size);
if (lseek(_fd, size, 0) == -1)
return -1;
if (_write(_fd, 0, 0) < 0)
-#include <crtdll/io.h>
#include <windows.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
-int _close(int _fd)
+int _close(int _fd)
{
- if ( _fd == -1 )
- return -1;
- if ( CloseHandle(_get_osfhandle(_fd)) == FALSE )
- return -1;
- return __fileno_close(_fd);
-
+ DPRINT("_close(fd %d)\n", _fd);
+ if (_fd == -1)
+ return -1;
+ if (CloseHandle(_get_osfhandle(_fd)) == FALSE)
+ return -1;
+ return __fileno_close(_fd);
}
#include <windows.h>
-#include <crtdll/io.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
-int _commode_dll = _IOCOMMIT;
int _commit(int _fd)
{
-#include <crtdll/io.h>
-#include <crtdll/fcntl.h>
+#include <msvcrt/io.h>
+#include <msvcrt/fcntl.h>
int _creat(const char *filename, int mode)
{
+/* $Id: dup.c,v 1.7 2002/11/24 18:42:13 robd Exp $ */
#include <windows.h>
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
// fixme change type of mode argument to mode_t
int __fileno_alloc(HANDLE hFile, int mode);
int __fileno_getmode(int _fd);
-int _dup( int handle )
+int _dup(int handle)
{
- return __fileno_alloc(_get_osfhandle(handle), __fileno_getmode(handle));
+ HANDLE hFile;
+ int fd;
+ hFile = _get_osfhandle(handle);
+ fd = __fileno_alloc(hFile, __fileno_getmode(handle));
+ return fd;
}
-#include <windows.h>
-#include <crtdll/io.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
int _dup2( int handle1, int handle2 )
{
#include <windows.h>
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
int _eof( int _fd )
{
return 1;
return 0;
-
-
-
-
}
#include <windows.h>
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
-long
-_filelength(int _fd)
+
+long _filelength(int _fd)
{
return GetFileSize(_get_osfhandle(_fd),NULL);
}
#include <windows.h>
-#include <crtdll/io.h>
-#include <crtdll/string.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/io.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
+int _findclose(int handle)
+{
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+ return FindClose((void*)handle);
+}
-int _findfirst(const char *_name, struct _finddata_t *result)
+int _findfirst(const char* _name, struct _finddata_t* result)
{
+ WIN32_FIND_DATA FindFileData;
+ char dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
- WIN32_FIND_DATA FindFileData;
- char dir[MAX_PATH];
- long hFindFile;
- int len = 0;
-
- if ( _name == NULL || _name[0] == 0 ) {
- len = GetCurrentDirectory(MAX_PATH-4,dir);
- if (dir[len-1] != '\\') {
- dir[len] = '\\';
- dir[len+1] = 0;
- }
- strcat(dir,"*.*");
- }
- else
- strcpy(dir,_name);
- hFindFile = (long)FindFirstFileA( dir, &FindFileData );
- if ( hFindFile == -1 ) {
- memset(result,0,sizeof(struct _finddata_t));
- return -1;
+ if (_name == NULL || _name[0] == 0) {
+ len = GetCurrentDirectory(MAX_PATH-4,dir);
+ if (dir[len-1] != '\\') {
+ dir[len] = '\\';
+ dir[len+1] = 0;
}
- result->attrib = FindFileData.dwFileAttributes;
+ strcat(dir,"*.*");
+ } else {
+ strcpy(dir,_name);
+ }
+ hFindFile = (long)FindFirstFileA(dir, &FindFileData);
+ if (hFindFile == -1) {
+ memset(result,0,sizeof(struct _finddata_t));
+ return -1;
+ }
- result->time_create = FileTimeToUnixTime( &FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime( &FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime( &FindFileData.ftLastWriteTime,NULL);
- result->size = FindFileData.nFileSizeLow;
- strncpy(result->name,FindFileData.cFileName,260);
-
- // if no wildcard the find file handle can be closed right away
- // a return value of 0 can flag this.
-
- if(!strchr(dir,'*') && !strchr(dir,'?')) {
- _findclose(hFindFile);
- return 0;
- }
-
-
- return hFindFile;
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ strncpy(result->name,FindFileData.cFileName,260);
+
+ // if no wildcard the find file handle can be closed right away
+ // a return value of 0 can flag this.
+
+ if (!strchr(dir,'*') && !strchr(dir,'?')) {
+ _findclose(hFindFile);
+ return 0;
+ }
+ return hFindFile;
}
-int _findnext(int handle, struct _finddata_t *result)
+int _findnext(int handle, struct _finddata_t* result)
{
- WIN32_FIND_DATA FindFileData;
-
- // check no wildcards or invalid handle
- if ( handle == 0 || handle == -1)
- return 0;
-
-
+ WIN32_FIND_DATA FindFileData;
- if ( !FindNextFile((void *)handle, &FindFileData ) )
- return -1;
-
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime( &FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime( &FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime( &FindFileData.ftLastWriteTime,NULL);
- result->size = FindFileData.nFileSizeLow;
- strncpy(result->name,FindFileData.cFileName,260);
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
return 0;
-}
-int _findclose(int handle)
-{
- // check no wildcards or invalid handle
- if ( handle == 0 || handle == -1)
- return 0;
- return FindClose((void *)handle);
+ if (!FindNextFileA((void*)handle, &FindFileData))
+ return -1;
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ strncpy(result->name,FindFileData.cFileName, MAX_PATH);
+
+ return 0;
}
+
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/fcntl.h>
-#include <crtdll/io.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/io.h>
#undef _fmode
unsigned int _fmode = O_TEXT;
-#include <crtdll/io.h>
-#include <crtdll/sys/stat.h>
+#include <msvcrt/io.h>
+#include <msvcrt/sys/stat.h>
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
int _isatty( int fd )
{
struct stat buf;
-
+ DPRINT("_isatty(fd %d)\n", fd);
if (_fstat (fd, &buf) < 0)
return 0;
if (S_ISCHR (buf.st_mode))
#include <windows.h>
-#include <crtdll/io.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
+
long _lseek(int _fildes, long _offset, int _whence)
{
return _llseek((HFILE)filehnd(_fildes),_offset,_whence);
}
-
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
-#include <crtdll/io.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/io.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
char* _mktemp (char *_template)
char *cp, *dp;
int i, len, xcount, loopcnt;
-
-
+ DPRINT("_mktemp('%s')\n", _template);
len = strlen (_template);
cp = _template + len;
-/*
+/* $Id: open.c,v 1.13 2002/11/24 18:42:13 robd Exp $
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/io/open.c
#include <windows.h>
#include <stdarg.h>
-#include <crtdll/io.h>
-#include <crtdll/fcntl.h>
-#include <crtdll/sys/stat.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/string.h>
-#include <crtdll/share.h>
+#include <msvcrt/io.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/sys/stat.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
+#include <msvcrt/string.h>
+#include <msvcrt/share.h>
+
+#define STD_AUX_HANDLE 3
+#define STD_PRINTER_HANDLE 4
typedef struct _fileno_modes_type
{
- HANDLE hFile;
- int mode;
- int fd;
+ HANDLE hFile;
+ int mode;
+ int fd;
} fileno_modes_type;
+int __fileno_alloc(HANDLE hFile, int mode);
+
fileno_modes_type *fileno_modes = NULL;
int maxfno = 5;
int minfno = 5;
-char __is_text_file(FILE *p)
+char __is_text_file(FILE* p)
{
- if ( p == NULL || fileno_modes == NULL )
+ if (p == NULL || fileno_modes == NULL)
return FALSE;
return (!((p)->_flag&_IOSTRG) && (fileno_modes[(p)->_file].mode&O_TEXT));
}
-
-
-
-int __fileno_alloc(HANDLE hFile, int mode);
-
-
-int _open(const char *_path, int _oflag,...)
+int _open(const char* _path, int _oflag,...)
{
- HANDLE hFile;
- DWORD dwDesiredAccess = 0;
- DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
- DWORD dwCreationDistribution = 0;
- DWORD dwFlagsAndAttributes = 0;
- int mode;
- va_list arg;
-
- va_start (arg, _oflag);
- mode = va_arg(arg,int);
- va_end (arg);
- if ( (mode == S_IWRITE) || (mode == 0) )
- dwFlagsAndAttributes = FILE_ATTRIBUTE_READONLY;
-
- /*
- *
- * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
- * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
- *
- */
- if (( _oflag & _O_RDWR ) == _O_RDWR )
- dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ ;
- else if (( _oflag & _O_WRONLY ) == _O_WRONLY )
- dwDesiredAccess |= GENERIC_WRITE ;
- else
- dwDesiredAccess |= GENERIC_READ ;
-
- if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) )
- dwCreationDistribution |= CREATE_NEW;
-
- else if (( _oflag & O_TRUNC ) == O_TRUNC ) {
- if (( _oflag & O_CREAT ) == O_CREAT )
- dwCreationDistribution |= CREATE_ALWAYS;
- else if (( _oflag & O_RDONLY ) != O_RDONLY )
- dwCreationDistribution |= TRUNCATE_EXISTING;
- }
- else if (( _oflag & _O_APPEND ) == _O_APPEND )
- dwCreationDistribution |= OPEN_EXISTING;
- else if (( _oflag & _O_CREAT ) == _O_CREAT )
- dwCreationDistribution |= OPEN_ALWAYS;
- else
- dwCreationDistribution |= OPEN_EXISTING;
-
- if (( _oflag & _O_RANDOM ) == _O_RANDOM )
- dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
- if (( _oflag & _O_SEQUENTIAL ) == _O_SEQUENTIAL )
- dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
-
- if (( _oflag & _O_TEMPORARY ) == _O_TEMPORARY )
- dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
-
- if (( _oflag & _O_SHORT_LIVED ) == _O_SHORT_LIVED )
- dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
-
- hFile = CreateFileA(_path,
- dwDesiredAccess,
- dwShareMode,
- NULL,
- dwCreationDistribution,
- dwFlagsAndAttributes,
- NULL);
- if (hFile == (HANDLE)-1)
- return -1;
- return __fileno_alloc(hFile,_oflag);
-
-// _O_APPEND Moves file pointer to end of file before every write operation.
+ HANDLE hFile;
+ DWORD dwDesiredAccess = 0;
+ DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ DWORD dwCreationDistribution = 0;
+ DWORD dwFlagsAndAttributes = 0;
+ int mode;
+ va_list arg;
+
+ va_start(arg, _oflag);
+ mode = va_arg(arg,int);
+ va_end (arg);
+ if ((mode == S_IWRITE) || (mode == 0))
+ dwFlagsAndAttributes = FILE_ATTRIBUTE_READONLY;
+ /*
+ *
+ * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
+ * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
+ *
+ */
+ if (( _oflag & _O_RDWR ) == _O_RDWR )
+ dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ ;
+ else if (( _oflag & _O_WRONLY ) == _O_WRONLY )
+ dwDesiredAccess |= GENERIC_WRITE ;
+ else
+ dwDesiredAccess |= GENERIC_READ ;
+
+ if ((_oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL))
+ dwCreationDistribution |= CREATE_NEW;
+
+ else if ((_oflag & O_TRUNC) == O_TRUNC) {
+ if ((_oflag & O_CREAT) == O_CREAT)
+ dwCreationDistribution |= CREATE_ALWAYS;
+ else if ((_oflag & O_RDONLY ) != O_RDONLY)
+ dwCreationDistribution |= TRUNCATE_EXISTING;
+ }
+ else if ((_oflag & _O_APPEND) == _O_APPEND)
+ dwCreationDistribution |= OPEN_EXISTING;
+ else if ((_oflag & _O_CREAT) == _O_CREAT)
+ dwCreationDistribution |= OPEN_ALWAYS;
+ else
+ dwCreationDistribution |= OPEN_EXISTING;
+
+ if ((_oflag & _O_RANDOM) == _O_RANDOM)
+ dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
+ if ((_oflag & _O_SEQUENTIAL) == _O_SEQUENTIAL)
+ dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
+
+ if ((_oflag & _O_TEMPORARY) == _O_TEMPORARY)
+ dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
+
+ if ((_oflag & _O_SHORT_LIVED) == _O_SHORT_LIVED)
+ dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
+
+ hFile = CreateFileA(_path,
+ dwDesiredAccess,
+ dwShareMode,
+ NULL,
+ dwCreationDistribution,
+ dwFlagsAndAttributes,
+ NULL);
+ if (hFile == (HANDLE)-1)
+ return -1;
+ return __fileno_alloc(hFile,_oflag);
+
+// _O_APPEND Moves file pointer to end of file before every write operation.
}
-
-
int
__fileno_alloc(HANDLE hFile, int mode)
{
-
int i;
/* Check for bogus values */
if (hFile < 0)
- return -1;
+ return -1;
for(i=minfno;i<maxfno;i++) {
- if (fileno_modes[i].fd == -1 ) {
- fileno_modes[i].fd = i;
- fileno_modes[i].mode = mode;
- fileno_modes[i].hFile = hFile;
- return i;
- }
+ if (fileno_modes[i].fd == -1 ) {
+ fileno_modes[i].fd = i;
+ fileno_modes[i].mode = mode;
+ fileno_modes[i].hFile = hFile;
+ return i;
+ }
}
-
/* See if we need to expand the tables. Check this BEFORE it might fail,
so that when we hit the count'th request, we've already up'd it. */
if ( i == maxfno)
{
int oldcount = maxfno;
fileno_modes_type *old_fileno_modes = fileno_modes;
- maxfno += 255;
+ maxfno += 255;
fileno_modes = (fileno_modes_type *)malloc(maxfno * sizeof(fileno_modes_type));
if ( old_fileno_modes != NULL )
{
- memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type));
+ memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type));
free ( old_fileno_modes );
}
memset(fileno_modes + oldcount, 0, (maxfno-oldcount)*sizeof(fileno_modes));
-
}
/* Fill in the value */
void *filehnd(int fileno)
{
-
-
-
- if ( fileno < 0 )
- return (void *)-1;
-#define STD_AUX_HANDLE 3
-#define STD_PRINTER_HANDLE 4
-
- switch(fileno)
- {
- case 0:
- return GetStdHandle(STD_INPUT_HANDLE);
- case 1:
- return GetStdHandle(STD_OUTPUT_HANDLE);
- case 2:
- return GetStdHandle(STD_ERROR_HANDLE);
- case 3:
- return GetStdHandle(STD_AUX_HANDLE);
- case 4:
- return GetStdHandle(STD_PRINTER_HANDLE);
- default:
- break;
- }
-
- if ( fileno >= maxfno )
- return (void *)-1;
-
- if ( fileno_modes[fileno].fd == -1 )
- return (void *)-1;
- return fileno_modes[fileno].hFile;
-}
-
-int __fileno_dup2( int handle1, int handle2 )
-{
- if ( handle1 >= maxfno )
- return -1;
-
- if ( handle1 < 0 )
- return -1;
- if ( handle2 >= maxfno )
- return -1;
-
- if ( handle2 < 0 )
- return -1;
-
- memcpy(&fileno_modes[handle1],&fileno_modes[handle2],sizeof(fileno_modes));
-
-
- return handle1;
+ if (fileno < 0)
+ return (void*)-1;
+ switch (fileno) {
+ case 0:
+ return GetStdHandle(STD_INPUT_HANDLE);
+ case 1:
+ return GetStdHandle(STD_OUTPUT_HANDLE);
+ case 2:
+ return GetStdHandle(STD_ERROR_HANDLE);
+ case 3:
+ return GetStdHandle(STD_AUX_HANDLE);
+ case 4:
+ return GetStdHandle(STD_PRINTER_HANDLE);
+ default:
+ break;
+ }
+ if (fileno >= maxfno)
+ return (void*)-1;
+ if (fileno_modes[fileno].fd == -1)
+ return (void*)-1;
+ return fileno_modes[fileno].hFile;
}
int __fileno_setmode(int _fd, int _newmode)
{
- int m;
- if ( _fd < minfno )
- return -1;
-
- if ( _fd >= maxfno )
- return -1;
+ int m;
- m = fileno_modes[_fd].mode;
- fileno_modes[_fd].mode = _newmode;
- return m;
+ if (_fd < minfno) {
+ return -1;
+ }
+ if (_fd >= maxfno)
+ return -1;
+ m = fileno_modes[_fd].mode;
+ fileno_modes[_fd].mode = _newmode;
+ return m;
}
int __fileno_getmode(int _fd)
{
- if ( _fd < minfno )
- return -1;
-
- if ( _fd >= maxfno )
- return -1;
-
- return fileno_modes[_fd].mode;
-
+ if (_fd < minfno) {
+ return -1;
+ }
+ if (_fd >= maxfno)
+ return -1;
+ return fileno_modes[_fd].mode;
}
-
-int __fileno_close(int _fd)
+int __fileno_close(int _fd)
{
- if ( _fd < 0 )
- return -1;
-
- if ( _fd >= maxfno )
- return -1;
+ if (_fd < 0) {
+ return -1;
+ }
+ if (_fd >= maxfno)
+ return -1;
+ fileno_modes[_fd].fd = -1;
+ fileno_modes[_fd].hFile = (HANDLE)-1;
+ return 0;
+}
- fileno_modes[_fd].fd = -1;
- fileno_modes[_fd].hFile = (HANDLE)-1;
- return 0;
+int _open_osfhandle(void *osfhandle, int flags)
+{
+ return __fileno_alloc((HANDLE)osfhandle, flags);
}
-int _open_osfhandle (void *osfhandle, int flags )
+void *_get_osfhandle(int fileno)
{
- return __fileno_alloc((HANDLE)osfhandle, flags);
-}
+ return filehnd(fileno);
+}
-void *_get_osfhandle( int fileno )
+int __fileno_dup2(int handle1, int handle2)
{
- return filehnd(fileno);
+ if (handle1 >= maxfno) {
+ return -1;
+ }
+ if (handle1 < 0)
+ return -1;
+ if (handle2 >= maxfno)
+ return -1;
+ if (handle2 < 0)
+ return -1;
+ memcpy(&fileno_modes[handle1],&fileno_modes[handle2],sizeof(fileno_modes));
+ return handle1;
}
-/*
+/* $Id: pipe.c,v 1.4 2002/11/24 18:42:13 robd Exp $
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/io/pipe.c
* 28/12/98: Appropriated for Reactos
*/
#include <windows.h>
-#include <crtdll/io.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
int _pipe(int _fildes[2], unsigned int size, int mode )
-/*
+/* $Id: read.c,v 1.9 2002/11/24 18:42:13 robd Exp $
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/io/read.c
* PURPOSE: Reads a file
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
- * 28/12/98: Created
+ * 28/12/1998: Created
*/
-#include <crtdll/io.h>
#include <windows.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
size_t _read(int _fd, void *_buf, size_t _nbyte)
{
-/*
+/* $Id: setmode.c,v 1.5 2002/11/24 18:42:13 robd Exp $
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/io/setmode.c
* 28/12/98: Created
*/
-#include <crtdll/io.h>
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/io.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
int _setmode(int _fd, int _newmode)
{
+ DPRINT("_setmod(fd %d, newmode %x)\n", _fd, _newmode);
return __fileno_setmode(_fd, _newmode);
}
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
int _sopen(char *path,int access,int shflag,int mode)
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/errno.h>
-#include <crtdll/io.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/io.h>
-off_t
-_tell(int _file)
+off_t _tell(int _file)
{
return _lseek(_file, 0, SEEK_CUR);
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/sys/stat.h>
+#include <msvcrt/sys/stat.h>
unsigned _unMode_dll = 022;
* 28/12/98: Created
*/
#include <windows.h>
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
-#include <crtdll/stdio.h>
-#include <crtdll/io.h>
-#include <crtdll/errno.h>
-#include <crtdll/sys/utime.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/sys/utime.h>
+#include <msvcrt/internal/file.h>
+
int _utime(const char* filename, struct _utimbuf* buf)
{
if ( _close(fn) < 0 )
return -1;
return ret;
-
}
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/io.h>
#include <windows.h>
+#include <msvcrt/io.h>
-#include <crtdll/stdio.h>
-#include <crtdll/locale.h>
-#include <crtdll/string.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/locale.h>
+#include <msvcrt/string.h>
#include <limits.h>
int _current_category; /* used by setlocale */
const char *_current_locale;
-int __mb_cur_max_dll = 1;
int parse_locale(char *locale, char *lang, char *country, char *code_page);
{
return (struct lconv *) &_lconv;
}
-
-# $Id: makefile,v 1.49 2002/11/19 17:16:14 robd Exp $
+# $Id: makefile,v 1.50 2002/11/24 18:42:12 robd Exp $
PATH_TO_TOP = ../..
+PATH_TO_MSVCRT = ../msvcrt
+
TARGET_DEFONLY = yes
TARGET_TYPE = dynlink
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CLEAN = \
- assert/*.o \
conio/*.o \
ctype/*.o \
direct/*.o \
include $(TOOLS_PATH)/helper.mk
-ASSERT_OBJECTS = \
- assert/assert.o
-
CONIO_OBJECTS = \
conio/cgets.o \
conio/cprintf.o \
conio/ungetch.o
CTYPE_OBJECTS = \
+ ctype/ctype.o \
ctype/isalnum.o \
ctype/isalpha.o \
ctype/isascii.o \
MISC_OBJECTS = \
misc/amsg.o \
+ misc/assert.o \
+ misc/debug.o \
misc/dllmain.o \
misc/GetArgs.o \
misc/initterm.o \
time/strtime.o \
time/time.o
-WCHAR_OBJECTS = \
- wchar/wcscat.o \
- wchar/wcschr.o \
- wchar/wcscmp.o \
+WSTRING_OBJECTS = \
+ $(PATH_TO_MSVCRT)/wstring/wcscat.o \
+ $(PATH_TO_MSVCRT)/wstring/wcschr.o \
+ $(PATH_TO_MSVCRT)/wstring/wcscmp.o \
wchar/wcscoll.o \
- wchar/wcscpy.o \
- wchar/wcscspn.o \
- wchar/wcsdup.o \
- wchar/wcsicmp.o \
+ $(PATH_TO_MSVCRT)/wstring/wcscpy.o \
+ $(PATH_TO_MSVCRT)/wstring/wcscspn.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsdup.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsicmp.o \
wchar/wcslen.o \
- wchar/wcslwr.o \
- wchar/wcsncat.o \
- wchar/wcsncmp.o \
- wchar/wcsncpy.o \
- wchar/wcsnlen.o \
- wchar/wcspbrk.o \
- wchar/wcsrchr.o \
- wchar/wcsrev.o \
- wchar/wcsset.o \
- wchar/wcsspn.o \
- wchar/wcsstr.o \
+ $(PATH_TO_MSVCRT)/wstring/wcslwr.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsncat.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsncmp.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsncpy.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsnlen.o \
+ $(PATH_TO_MSVCRT)/wstring/wcspbrk.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsrchr.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsrev.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsset.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsspn.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsstr.o \
wchar/wcstod.o \
wchar/wcstok.o \
wchar/wcstol.o \
- wchar/wcsupr.o \
- wchar/wcsxfrm.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsupr.o \
+ $(PATH_TO_MSVCRT)/wstring/wcsxfrm.o \
wchar/wtoi.o \
wchar/wcstombs.o \
- wchar/wcsnicmp.o
+ $(PATH_TO_MSVCRT)/wstring/wcsnicmp.o
+
OBJECTS = \
- $(ASSERT_OBJECTS) \
$(CONIO_OBJECTS) \
$(CTYPE_OBJECTS) \
$(DIRECT_OBJECTS) \
$(SYS_STAT_OBJECTS) \
$(TCHAR_OBJECTS) \
$(TIME_OBJECTS) \
- $(WCHAR_OBJECTS)
+ $(WSTRING_OBJECTS)
$(TARGET_NAME).o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).o
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
+
double atan (double __x);
double atan (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fld1\n\t"
"fpatan"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_atan(__x);
+#endif /*__GNUC__*/
return __value;
}
+
+#include <msvcrt/math.h>
+
double atan2 (double __y, double __x);
double atan2 (double __y, double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fpatan\n\t"
"fld %%st(0)"
: "=t" (__value) : "0" (__x), "u" (__y));
-
+#else
+ __value = linkme_atan2(__x, __y);
+#endif /*__GNUC__*/
return __value;
}
-#include <crtdll/math.h>
+#include <msvcrt/math.h>
double _cabs( struct _complex z )
{
-#include <crtdll/math.h>
-
-double ceil (double __x);
+#include <msvcrt/math.h>
double ceil (double __x)
{
register double __value;
+#ifdef __GNUC__
__volatile unsigned short int __cw, __cwtmp;
__asm __volatile ("fnstcw %0" : "=m" (__cw));
__asm __volatile ("fldcw %0" : : "m" (__cwtmp));
__asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
__asm __volatile ("fldcw %0" : : "m" (__cw));
-
+#else
+ __value = linkme_ceil(__x);
+#endif /*__GNUC__*/
return __value;
}
+#include <msvcrt/math.h>
+
double cos (double __x);
double cos (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fcos"
: "=t" (__value): "0" (__x));
-
+#else
+ __value = linkme_cos(__x);
+#endif /*__GNUC__*/
return __value;
}
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
double exp (double __x);
double exp (double __x)
{
+#ifdef __GNUC__
register double __value, __exponent;
__asm __volatile__
("fldl2e # e^x = 2^(x * log2(e))\n\t"
: "=t" (__value) : "0" (__value), "u" (__exponent));
return __value;
+#else
+ return linkme_exp(__x);
+#endif /*__GNUC__*/
}
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
double fabs (double __x);
double fabs (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fabs"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_fabs(__x);
+#endif /*__GNUC__*/
return __value;
}
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
double floor (double __x);
double floor (double __x)
{
register double __value;
+#ifdef __GNUC__
__volatile unsigned short int __cw, __cwtmp;
__asm __volatile ("fnstcw %0" : "=m" (__cw));
__asm __volatile ("fldcw %0" : : "m" (__cwtmp));
__asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
__asm __volatile ("fldcw %0" : : "m" (__cw));
-
+#else
+ __value = linkme_floor(__x);
+#endif /*__GNUC__*/
return __value;
}
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
double fmod (double __x, double __y);
double fmod (double __x, double __y)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("1: fprem\n\t"
"fstsw %%ax\n\t"
"sahf\n\t"
"jp 1b"
: "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc");
-
+#else
+ __value = linkme_fmod(__x, __y);
+#endif /*__GNUC__*/
return __value;
}
-#include <crtdll/math.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/internal/ieee.h>
+#include <msvcrt/math.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/ieee.h>
double
frexp(double __x, int *exptr)
-#include <crtdll/float.h>
+#include <msvcrt/float.h>
-long _ftol(double fl) {
+long _ftol(double fl)
+{
return (long)fl;
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/internal/ieee.h>
+#include <msvcrt/internal/ieee.h>
#undef _HUGE
double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };
*
*/
-#include <crtdll/float.h>
-#include <crtdll/math.h>
-#include <crtdll/errno.h>
+#include <msvcrt/float.h>
+#include <msvcrt/math.h>
+#include <msvcrt/errno.h>
/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers
between these two shouldn't neither overflow nor underflow
#ifdef TEST
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
int
main(void)
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
+
double ldexp (double __x, int __y);
double ldexp (double __x, int __y)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fscale"
: "=t" (__value) : "0" (__x), "u" ((double) __y));
-
+#else
+ __value = linkme_ldexp(__x, __y);
+#endif /*__GNUC__*/
return __value;
}
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
+
double log (double __x);
double log (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fldln2\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_log(__x);
+#endif /*__GNUC__*/
return __value;
}
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
double log10 (double __x);
double log10 (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fldlg2\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_log10(__x);
+#endif /*__GNUC__*/
return __value;
}
* ====================================================
*/
-#include <crtdll/float.h>
-#include <crtdll/math.h>
-#include <crtdll/internal/ieee.h>
+#include <msvcrt/float.h>
+#include <msvcrt/math.h>
+#include <msvcrt/internal/ieee.h>
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
+
double pow (double __x, double __y);
double __log2 (double __x);
double __log2 (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fld1\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
-
+#else
+ //__value = linkme_log2(__x);
+ __value = 0;
+#endif /*__GNUC__*/
return __value;
}
double pow (double __x, double __y)
{
- register double __value, __exponent;
+ register double __value;
+#ifdef __GNUC__
+ register double __exponent;
long __p = (long) __y;
if (__x == 0.0 && __y > 0.0)
__asm __volatile__
("fscale"
: "=t" (__value) : "0" (__value), "u" (__exponent));
-
+#else
+ __value = linkme_pow(__x, __y);
+#endif /*__GNUC__*/
return __value;
}
{
return pow(__x,__y/2)*pow(__x,__y/2);
}
-
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
double sin (double __x);
double sin (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fsin"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_sin(__x);
+#endif /*__GNUC__*/
return __value;
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/math.h>
+#include <msvcrt/math.h>
double sinh(double x)
{
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 <msvcrt/math.h>
double sqrt (double __x);
double sqrt (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fsqrt"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_sqrt(__x);
+#endif /*__GNUC__*/
return __value;
}
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <msvcrt/math.h>
double tan (double __x);
double tan (double __x)
{
register double __value;
+#ifdef __GNUC__
register double __value2 __attribute__ ((unused));
__asm __volatile__
("fptan"
: "=t" (__value2), "=u" (__value) : "0" (__x));
-
+#else
+ __value = linkme_tan(__x);
+#endif /*__GNUC__*/
return __value;
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/math.h>
+#include <msvcrt/math.h>
double tanh(double x)
{
* 12/04/99: Created
*/
-#include <crtdll/mbctype.h>
+#include <msvcrt/mbctype.h>
static unsigned short han_to_zen_ascii_table[0x5f] = {
0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166,
Modified from Taiji Yamada japanese code system utilities
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/mbctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/mbctype.h>
int _ismbbkana(unsigned char c)
{
-#include <crtdll/mbctype.h>
+#include <msvcrt/mbctype.h>
int _ismbbkalpha(unsigned char c)
{
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbctype.h>
+#include <msvcrt/mbctype.h>
int _ismbbkpunct( unsigned int c )
{
#include <windows.h>
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
int isleadbyte(char *mbstr)
{
* 12/04/99: Created
*/
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
// code page 952 only
int _ismbclower( unsigned int c )
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
-
-int _ismbbkalnum( unsigned int c );
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
int _ismbbalpha(unsigned char c)
{
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
-int _ismbbkalnum( unsigned int c );
int _ismbbalnum(unsigned char c)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
int _ismbbalpha(unsigned char c);
int _ismbbalnum(unsigned char c);
-#include <crtdll/mbstring.h>
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
int _ismbbgraph(unsigned char c)
{
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
int _ismbbkalnum( unsigned int c )
{
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/mbctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/mbctype.h>
size_t _mbclen2(const unsigned int s);
-#include <crtdll/mbstring.h>
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
int _ismbbprint(unsigned char c)
{
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/mbctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/mbctype.h>
size_t _mbclen2(const unsigned int s);
* 12/04/99: Created
*/
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
// code page 952 only
int _ismbcupper( unsigned int c )
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned short _mbcjistojms(unsigned short c)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned short _mbcjmstojis(unsigned short c)
{
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/mbctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/mbctype.h>
int _mbbtype(unsigned char c , int type)
{
-#include <crtdll/mbstring.h>
-#include <crtdll/string.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/string.h>
size_t _mbclen2(const unsigned int s);
-#include <crtdll/mbstring.h>
-
-#include <crtdll/stdlib.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/stdlib.h>
size_t _mbclen(const unsigned char *s)
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
unsigned char * _mbscat(unsigned char *dst, const unsigned char *src)
{
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
unsigned char * _mbschr(const unsigned char *str, unsigned int c)
{
-#include <crtdll/mbstring.h>
-#include <crtdll/string.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/string.h>
int _mbscmp(const unsigned char *str1, const unsigned char *str2)
{
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
int colldif(unsigned short c1, unsigned short c2);
-#include <crtdll/mbstring.h>
-#include <crtdll/string.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/string.h>
unsigned char * _mbscpy(unsigned char *dst, const unsigned char *str)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
// not correct
size_t _mbscspn(const unsigned char *s1, const unsigned char *s2)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned char * _mbsdec(const unsigned char *str, const unsigned char *cur)
{
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/stdlib.h>
unsigned char * _mbsdup(const unsigned char *_s)
{
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
int _mbsicmp(const unsigned char *str1, const unsigned char *str2)
{
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
int colldif(unsigned short c1, unsigned short c2);
int _mbsicoll(const unsigned char *str1, const unsigned char *str2)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned char * _mbsinc(const unsigned char *s)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
size_t _mbclen2(const unsigned int s);
-#include <crtdll/mbstring.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/ctype.h>
unsigned int _mbbtolower(unsigned int c)
{
return tolower(c);
return c;
}
+
// code page 952
#define CASE_DIFF (0x8281 - 0x8260)
unsigned int _mbctolower(unsigned int c)
{
-
- if ((c & 0xFF00) != 0) {
-// true multibyte case conversion needed
- if ( _ismbclower(c) )
- return c + CASE_DIFF;
-
- } else
- return _mbbtolower(c);
-
- return 0;
+ if ((c & 0xFF00) != 0) {
+ // true multibyte case conversion needed
+ if (_ismbclower(c))
+ return c + CASE_DIFF;
+ } else {
+ return _mbbtolower(c);
+ }
+ return 0;
}
unsigned char * _mbslwr(unsigned char *x)
{
- unsigned char *y=x;
+ unsigned char *y=x;
- while (*y) {
- if (!_ismbblead(*y) )
- *y = tolower(*y);
- else {
- *y=_mbctolower(*(unsigned short *)y);
- y++;
- }
+ while (*y) {
+ if (!_ismbblead(*y)) {
+ *y = tolower(*y);
+ } else {
+ *y=_mbctolower(*(unsigned short *)y);
+ y++;
}
- return x;
+ }
+ return x;
}
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/string.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/string.h>
size_t _mbclen2(const unsigned int s);
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
size_t _mbsnccnt(const unsigned char *str, size_t n)
{
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
int _mbsncmp(const unsigned char *str1, const unsigned char *str2, size_t n)
{
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
int colldif(unsigned short c1, unsigned short c2);
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned char *_mbsncpy(unsigned char *str1, const unsigned char *str2, size_t n)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned int _mbsnextc (const unsigned char *src)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
int _mbsnicoll(const unsigned char *s1, const unsigned char *s2, size_t n)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned char * _mbsninc(const unsigned char *str, size_t n)
{
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
size_t _mbclen2(const unsigned int s);
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
// not correct
unsigned char * _mbspbrk(const unsigned char *s1, const unsigned char *s2)
{
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
size_t _mbclen2(const unsigned int s);
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned char * _mbsrev(unsigned char *s)
{
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
size_t _mbclen2(const unsigned int s);
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
// not correct
size_t _mbsspn(const unsigned char *s1, const unsigned char *s2)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
// not correct
unsigned char * _mbsspnp(const unsigned char *s1, const unsigned char *s2)
{
-#include <crtdll/mbstring.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/stdlib.h>
unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2)
{
-#include <crtdll/mbstring.h>
+#include <msvcrt/mbstring.h>
unsigned char * _mbstok(unsigned char *s, unsigned char *delim)
{
-#include <crtdll/mbstring.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/stdlib.h>
size_t _mbstrlen( const char *string )
{
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/ctype.h>
unsigned int _mbbtoupper(unsigned int c)
{
#include <windows.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
char *_pgmptr_dll;
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/crtdll/conio/kbhit.c
- * PURPOSE: Checks for keyboard hits
+ * FILE: lib/crtdll/misc/amsg.c
+ * PURPOSE: Print runtime error messages
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/stdlib.h>
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
-int _aexit_rtn_dll(int exitcode)
+int _aexit_rtn_dll(int exitcode)
{
_exit(exitcode);
}
-void _amsg_exit (int errnum)
+void _amsg_exit(int errnum)
{
fprintf(stderr,strerror(errnum));
- _aexit_rtn_dll(-1);
+ _aexit_rtn_dll(-1);
}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <msvcrt/assert.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/signal.h>
+
+
+void _assert(const char* msg, const char* file, int line)
+{
+ /* Assertion failed at foo.c line 45: x<y */
+ fprintf(stderr, "Assertion failed at %s line %d: %s\n", file, line, msg);
+ raise(SIGABRT);
+}
* DISCLAMED. This includes but is not limited to warrenties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.3 $
- * $Author: ariadne $
- * $Date: 1999/04/23 18:42:21 $
+ * $Revision: 1.4 $
+ * $Author: robd $
+ * $Date: 2002/11/24 18:42:15 $
*
*/
-#include <crtdll/stdlib.h>
-#include <crtdll/stdio.h>
-#include <crtdll/io.h>
-#include <crtdll/fcntl.h>
-#include <crtdll/process.h>
-#include <crtdll/float.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/process.h>
+#include <msvcrt/float.h>
#include <windows.h>
/* NOTE: The code for initializing the _argv, _argc, and environ variables
--- /dev/null
+#include <windows.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+
+void debug_printf(char* fmt, ...)
+{
+ va_list args;
+ char buffer[255];
+ HANDLE OutputHandle;
+
+ AllocConsole();
+ OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
+ va_start(args,fmt);
+ vsprintf(buffer,fmt,args);
+ WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
+ va_end(args);
+}
-/*
+/* $Id: dllmain.c,v 1.5 2002/11/24 18:42:15 robd Exp $
+ *
* dllmain.c
*
* A stub DllMain function which will be called by DLLs which do not
* DISCLAMED. This includes but is not limited to warrenties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.4 $
- * $Author: ekohl $
- * $Date: 1999/04/29 23:34:23 $
+ * $Revision: 1.5 $
+ * $Author: robd $
+ * $Date: 2002/11/24 18:42:15 $
*
*/
#include <windows.h>
#include <stdarg.h>
-#include <stdio.h>
+#include <msvcrt/stdio.h>
#include <string.h>
-void debug_printf(char* fmt, ...)
-{
- va_list args;
- char buffer[255];
- HANDLE OutputHandle;
-
- AllocConsole();
- OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
- va_start(args,fmt);
- vsprintf(buffer,fmt,args);
- WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
- va_end(args);
-}
-BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
+/* EXTERNAL PROTOTYPES ********************************************************/
+
+void debug_printf(char* fmt, ...);
+
+
+/* LIBRARY GLOBAL VARIABLES ***************************************************/
+
+int __mb_cur_max_dll = 1;
+int _commode_dll = _IOCOMMIT;
+
+
+/* LIBRARY ENTRY POINT ********************************************************/
+
+BOOL
+WINAPI
+DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
{
return TRUE;
}
+/* EOF */
* DISCLAMED. This includes but is not limited to warrenties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.3 $
- * $Author: ariadne $
- * $Date: 1999/04/23 18:42:21 $
+ * $Revision: 1.4 $
+ * $Author: robd $
+ * $Date: 2002/11/24 18:42:15 $
*
*/
* Access to a standard 'main'-like argument count and list. Also included
* is a table of environment variables.
*/
-int _argc = 0;
-char** _argv = 0;
+int _argc = 0;
+char** _argv = 0;
/* NOTE: Thanks to Pedro A. Aranda Gutiirrez <paag@tid.es> for pointing
* this out to me. GetMainArgs (used below) takes a fourth argument
* defining _CRT_glob and setting it to zero, like this:
* int _CRT_glob = 0;
*/
-extern int _CRT_glob;
+extern int _CRT_glob;
-#ifdef __MSVCRT__
-extern void __getmainargs(int *, char***, char***, int);
-#else
extern void __GetMainArgs(int *, char***, char***, int);
-#endif
/*
* Initialize the _argc, _argv and environ variables.
static void
_mingw32_init_mainargs (void)
{
- /* The environ variable is provided directly in stdlib.h through
- * a dll function call. */
- char** dummy_environ;
+ /* The environ variable is provided directly in stdlib.h through
+ * a dll function call. */
+ char** dummy_environ;
- /*
- * Microsoft's runtime provides a function for doing just that.
- */
-#ifdef __MSVCRT__
- (void) __getmainargs(&_argc, &_argv, &dummy_environ, _CRT_glob);
+ /*
+ * Microsoft's runtime provides a function for doing just that.
+ */
+#ifdef _MSVCRT_LIB_
+ (void) __getmainargs(&_argc, &_argv, &dummy_environ, _CRT_glob);
#else
- /* CRTDLL version */
- (void) __GetMainArgs(&_argc, &_argv, &dummy_environ, _CRT_glob);
+ /* CRTDLL version */
+ (void) __GetMainArgs(&_argc, &_argv, &dummy_environ, _CRT_glob);
#endif
}
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdlib.h>
-void _initterm (
- void (* fStart[])(void),
- void (* fEnd[])(void)
- )
+void _initterm(void (*fStart[])(void), void (*fEnd[])(void))
{
int i = 0;
-
if ( fStart == NULL || fEnd == NULL )
return;
i++;
}
}
+
+
typedef int (* _onexit_t)(void);
-_onexit_t __dllonexit (
- _onexit_t func,
- void (** fStart[])(void),
- void (** fEnd[])(void)
- )
+_onexit_t __dllonexit(_onexit_t func, void (** fStart[])(void), void (** fEnd[])(void))
{
}
-/*
+/* $Id: _system.c,v 1.6 2002/11/24 18:42:15 robd Exp $
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/process/system.c
* 04/03/99: Created
*/
#include <windows.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
-#include <crtdll/process.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+#include <msvcrt/process.h>
int system(const char *command)
{
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
#include <stdarg.h>
int _execl(const char* szPath, const char* szArgv0, ...)
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/stdarg.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/stdarg.h>
// fixme rewrite to pass the array variants to va_list variant
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/stdarg.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/stdarg.h>
int _execlp(const char *szPath, const char *szArgv0, ...)
{
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/stdarg.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/stdarg.h>
int execlpe(const char *path, const char *szArgv0, ... /*, const char **envp */)
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
int _execv(const char* szPath, char* const* szaArgv)
{
-/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details *///#include <crtdll/stubs.h>
-//#include <crtdll/unistd.h>
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details *///#include <msvcrt/stubs.h>
+//#include <msvcrt/unistd.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
int _execvp(const char* szPath, char* const* szaArgv)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/process.h>
+#include <msvcrt/process.h>
int _execvpe(const char* szPath, char* const* szaArgv, char* const* szaEnv)
{
#include <windows.h>
-#include <crtdll/process.h>
+#include <msvcrt/process.h>
int _getpid (void)
{
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
#include <stdarg.h>
int _spawnlp(int nMode, const char* szPath, const char* szArgv0, ...)
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/stdarg.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/stdarg.h>
int _spawnlpe(int mode, const char *path, const char *szArgv0, ... /*, const char **envp */)
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
int _spawnv(int nMode, const char* szPath, char* const* szaArgv)
{
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <windows.h>
-
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
-#include <crtdll/errno.h>
-//#include <crtdll/limits.h>
-#include <crtdll/process.h>
-#include <crtdll/ctype.h>
-#include <crtdll/io.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/process.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/io.h>
#ifndef F_OK
int _fileinfo_dll = 0;
static int
-direct_exec_tail(const char *program, const char *args,
- char * const envp[],
- PROCESS_INFORMATION *ProcessInformation)
+direct_exec_tail(const char* program, const char* args,
+ char* const envp[],
+ PROCESS_INFORMATION* ProcessInformation)
{
-
- static STARTUPINFO StartupInfo;
-
- StartupInfo.cb = sizeof(STARTUPINFO);
- StartupInfo.lpReserved= NULL;
- StartupInfo.dwFlags = 0;
- StartupInfo.wShowWindow = SW_SHOWDEFAULT;
- StartupInfo.lpReserved2 = NULL;
- StartupInfo.cbReserved2 = 0;
-
-
- if (! CreateProcessA((char *)program,(char *)args,NULL,NULL,FALSE,0,(char **)envp,NULL,&StartupInfo,ProcessInformation) )
- {
- __set_errno( GetLastError() );
- return -1;
- }
-
- return (int)ProcessInformation->hProcess;
+ static STARTUPINFO StartupInfo;
+
+ StartupInfo.cb = sizeof(STARTUPINFO);
+ StartupInfo.lpReserved= NULL;
+ StartupInfo.dwFlags = 0;
+ StartupInfo.wShowWindow = SW_SHOWDEFAULT;
+ StartupInfo.lpReserved2 = NULL;
+ StartupInfo.cbReserved2 = 0;
+ if (!CreateProcessA((char*)program,(char*)args,NULL,NULL,FALSE,0,(char**)envp,NULL,&StartupInfo,ProcessInformation)) {
+ __set_errno( GetLastError() );
+ return -1;
+ }
+ return (int)ProcessInformation->hProcess;
}
-static int vdm_exec(const char *program, char **argv, char **envp,
- PROCESS_INFORMATION *ProcessInformation)
+static int vdm_exec(const char* program, char** argv, char** envp,
+ PROCESS_INFORMATION* ProcessInformation)
{
- static char args[1024];
- int i = 0;
- args[0] = 0;
-
- strcpy(args,"vdm.exe ");
- while(argv[i] != NULL ) {
- strcat(args,argv[i]);
- strcat(args," ");
+ static char args[1024];
+ int i = 0;
+ args[0] = 0;
+
+ strcpy(args, "vdm.exe ");
+ while (argv[i] != NULL) {
+ strcat(args, argv[i]);
+ strcat(args, " ");
i++;
- }
-
- return direct_exec_tail(program,args,envp,ProcessInformation);
+ }
+ return direct_exec_tail(program,args,envp,ProcessInformation);
}
-static int go32_exec(const char *program, char **argv, char **envp,
- PROCESS_INFORMATION *ProcessInformation)
+static int go32_exec(const char* program, char** argv, char** envp,
+ PROCESS_INFORMATION* ProcessInformation)
{
-
-
- static char args[1024];
- static char envblock[2048];
- char * penvblock;
- int i = 0;
-
-
- envblock[0] = 0;
- penvblock=envblock;
-
- while(envp[i] != NULL ) {
+ static char args[1024];
+ static char envblock[2048];
+ char* penvblock;
+ int i = 0;
+
+ envblock[0] = 0;
+ penvblock=envblock;
+ while(envp[i] != NULL ) {
strcat(penvblock,envp[i]);
- penvblock+=strlen(envp[i])+1;
+ penvblock+=strlen(envp[i])+1;
i++;
- }
- penvblock[0]=0;
-
- args[0] = 0;
- i = 0;
- while(argv[i] != NULL ) {
+ }
+ penvblock[0]=0;
+ args[0] = 0;
+ i = 0;
+ while(argv[i] != NULL ) {
strcat(args,argv[i]);
strcat(args," ");
i++;
- }
-
- return direct_exec_tail(program,args,envp,ProcessInformation);
+ }
+ return direct_exec_tail(program,args,envp,ProcessInformation);
}
-int
-command_exec(const char *program, char **argv, char **envp,
- PROCESS_INFORMATION *ProcessInformation)
+int command_exec(const char* program, char** argv, char** envp,
+ PROCESS_INFORMATION* ProcessInformation)
{
- static char args[1024];
- int i = 0;
-
-
+ static char args[1024];
+ int i = 0;
- args[0] = 0;
-
- strcpy(args,"cmd.exe /c ");
- while(argv[i] != NULL ) {
+ args[0] = 0;
+ strcpy(args,"cmd.exe /c ");
+ while(argv[i] != NULL ) {
strcat(args,argv[i]);
strcat(args," ");
i++;
- }
-
- return direct_exec_tail(program,args,envp,ProcessInformation);
-
+ }
+ return direct_exec_tail(program,args,envp,ProcessInformation);
}
-static int script_exec(const char *program, char **argv, char **envp,
- PROCESS_INFORMATION *ProcessInformation)
+static int script_exec(const char* program, char** argv, char** envp,
+ PROCESS_INFORMATION* ProcessInformation)
{
- return 0;
+ return 0;
}
those extensions that can be *omitted* when you invoke the
executable from one of the shells used on MSDOS. */
static struct {
- const char *extension;
- int (*interp)(const char *, char **, char **,
- PROCESS_INFORMATION *);
+ const char* extension;
+ int (*interp)(const char*, char**, char**, PROCESS_INFORMATION*);
} interpreters[] = {
- { ".com", vdm_exec },
- { ".exe", go32_exec },
- { ".dll", go32_exec },
- { ".cmd", command_exec },
- { ".bat", command_exec },
- { ".btm", command_exec },
- { ".sh", script_exec }, /* for compatibility with ms_sh */
- { ".ksh", script_exec },
- { ".pl", script_exec }, /* Perl */
- { ".sed", script_exec },
- { "", go32_exec },
- { 0, script_exec }, /* every extension not mentioned above calls it */
- { 0, 0 },
+ { ".com", vdm_exec },
+ { ".exe", go32_exec },
+ { ".dll", go32_exec },
+ { ".cmd", command_exec },
+ { ".bat", command_exec },
+ { ".btm", command_exec },
+ { ".sh", script_exec }, /* for compatibility with ms_sh */
+ { ".ksh", script_exec },
+ { ".pl", script_exec }, /* Perl */
+ { ".sed", script_exec },
+ { "", go32_exec },
+ { 0, script_exec }, /* every extension not mentioned above calls it */
+ { 0, 0 },
};
/* This is the index into the above array of the interpreter
/*-------------------------------------------------*/
-
-
-
-int _spawnve(int mode, const char *path, char *const argv[], char *const envp[])
+int _spawnve(int mode, const char* path, char* const argv[], char* const envp[])
{
- /* This is the one that does the work! */
- PROCESS_INFORMATION ProcessInformation;
- union { char *const *x; char **p; } u;
- int i = -1;
- char **argvp;
- char **envpp;
- char rpath[FILENAME_MAX], *rp, *rd=0;
- int e = errno;
- int is_dir = 0;
- int found = 0;
- DWORD ExitCode;
-
- if (path == 0 || argv[0] == 0)
- {
- errno = EINVAL;
- return -1;
- }
- if (strlen(path) > FILENAME_MAX - 1)
- {
- errno = ENAMETOOLONG;
- return -1;
- }
-
- u.x = argv; argvp = u.p;
- u.x = envp; envpp = u.p;
-
- fflush(stdout); /* just in case */
- for (rp=rpath; *path; *rp++ = *path++)
- {
+ /* This is the one that does the work! */
+ PROCESS_INFORMATION ProcessInformation;
+ union { char* const* x; char** p; } u;
+ int i = -1;
+ char** argvp;
+ char** envpp;
+ char rpath[FILENAME_MAX], *rp, *rd = 0;
+ int e = errno;
+ int is_dir = 0;
+ int found = 0;
+ DWORD ExitCode;
+
+ if (path == 0 || argv[0] == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (strlen(path) > FILENAME_MAX - 1) {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ u.x = argv; argvp = u.p;
+ u.x = envp; envpp = u.p;
+ fflush(stdout); /* just in case */
+ for (rp=rpath; *path; *rp++ = *path++) {
if (*path == '.')
- rd = rp;
- if (*path == '\\' || *path == '/')
- rd = 0;
- }
- *rp = 0;
-
- /* If LFN is supported on the volume where rpath resides, we
- might have something like foo.bar.exe or even foo.exe.com.
- If so, look for RPATH.ext before even trying RPATH itself. */
- if (!rd)
- {
- for (i=0; interpreters[i].extension; i++)
- {
- strcpy(rp, interpreters[i].extension);
- if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0)))
- {
- found = 1;
- break;
- }
+ rd = rp;
+ if (*path == '\\' || *path == '/')
+ rd = 0;
+ }
+ *rp = 0;
+
+ /* If LFN is supported on the volume where rpath resides, we
+ might have something like foo.bar.exe or even foo.exe.com.
+ If so, look for RPATH.ext before even trying RPATH itself. */
+ if (!rd) {
+ for (i=0; interpreters[i].extension; i++) {
+ strcpy(rp, interpreters[i].extension);
+ if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0))) {
+ found = 1;
+ break;
+ }
+ }
}
- }
- if (!found)
- {
- const char *rpath_ext;
+ if (!found) {
+ const char *rpath_ext;
- if (rd)
- {
- i = 0;
- rpath_ext = rd;
+ if (rd) {
+ i = 0;
+ rpath_ext = rd;
+ } else {
+ i = INTERP_NO_EXT;
+ rpath_ext = "";
+ }
+ for ( ; interpreters[i].extension; i++)
+ if (_stricmp(rpath_ext, interpreters[i].extension) == 0
+ && _access(rpath, F_OK) == 0
+ && !(is_dir = (_access(rpath, D_OK) == 0)))
+ {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ errno = is_dir ? EISDIR : ENOENT;
+ return -1;
}
- else
- {
- i = INTERP_NO_EXT;
- rpath_ext = "";
+ errno = e;
+ i = interpreters[i].interp(rpath, argvp, envpp, &ProcessInformation);
+ if (mode == P_OVERLAY)
+ exit(i);
+ if (mode == P_WAIT) {
+ WaitForSingleObject(ProcessInformation.hProcess,INFINITE);
+ GetExitCodeProcess(ProcessInformation.hProcess,&ExitCode);
+ i = (int)ExitCode;
}
- for ( ; interpreters[i].extension; i++)
- if (_stricmp(rpath_ext, interpreters[i].extension) == 0
- && _access(rpath, F_OK) == 0
- && !(is_dir = (_access(rpath, D_OK) == 0)))
- {
- found = 1;
- break;
- }
- }
- if (!found)
- {
- errno = is_dir ? EISDIR : ENOENT;
- return -1;
- }
- errno = e;
- i = interpreters[i].interp(rpath, argvp, envpp, &ProcessInformation);
- if (mode == P_OVERLAY)
- exit(i);
- if (mode == P_WAIT)
- {
- WaitForSingleObject(ProcessInformation.hProcess,INFINITE);
- GetExitCodeProcess(ProcessInformation.hProcess,&ExitCode);
- i = (int)ExitCode;
- }
- return i;
+ return i;
}
-
-
-
-const char * find_exec(char * path,char *rpath)
+const char* find_exec(char* path, char* rpath)
{
- char *rp, *rd=0;
- int i;
- int is_dir = 0;
- int found = 0;
- if (path == 0 )
- return 0;
- if (strlen(path) > FILENAME_MAX - 1)
- return path;
-
- /* copy path in rpath */
- for (rd=path,rp=rpath; *rd; *rp++ = *rd++)
+ char *rp, *rd=0;
+ int i;
+ int is_dir = 0;
+ int found = 0;
+
+ if (path == 0 )
+ return 0;
+ if (strlen(path) > FILENAME_MAX - 1)
+ return path;
+
+ /* copy path in rpath */
+ for (rd=path,rp=rpath; *rd; *rp++ = *rd++)
;
- *rp = 0;
- /* try first with the name as is */
- for (i=0; interpreters[i].extension; i++)
- {
- strcpy(rp, interpreters[i].extension);
- if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0)))
- {
- found = 1;
- break;
+ *rp = 0;
+ /* try first with the name as is */
+ for (i=0; interpreters[i].extension; i++) {
+ strcpy(rp, interpreters[i].extension);
+ if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0))) {
+ found = 1;
+ break;
+ }
}
- }
-
- if (!found)
- {
- /* search in the PATH */
- char winpath[MAX_PATH];
- if( GetEnvironmentVariableA("PATH",winpath,MAX_PATH))
- {
- char *ep=winpath;
- while( *ep)
- {
- if(*ep == ';') ep++;
- rp=rpath;
- for ( ; *ep && (*ep != ';') ; *rp++ = *ep++)
- ;
- *rp++='/';
- for (rd=path ; *rd ; *rp++ = *rd++)
- ;
-
- for (i=0; interpreters[i].extension; i++)
- {
- strcpy(rp, interpreters[i].extension);
- if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0)))
- {
- found = 1;
- break;
- }
+ if (!found) {
+ /* search in the PATH */
+ char winpath[MAX_PATH];
+ if (GetEnvironmentVariableA("PATH", winpath, MAX_PATH)) {
+ char* ep = winpath;
+ while (*ep) {
+ if (*ep == ';') ep++;
+ rp = rpath;
+ for ( ; *ep && (*ep != ';') ; *rp++ = *ep++)
+ ;
+ *rp++ = '/';
+ for (rd = path ; *rd ; *rp++ = *rd++)
+ ;
+ for (i = 0; interpreters[i].extension; i++) {
+ strcpy(rp, interpreters[i].extension);
+ if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0))) {
+ found = 1;
+ break;
+ }
+ }
+ if (found) break;
+ }
}
- if (found) break;
- }
}
- }
- if (!found)
- return path;
-
- return rpath;
+ if (!found)
+ return path;
+ return rpath;
}
int _spawnvpe(int nMode, const char* szPath, char* const* szaArgv, char* const* szaEnv)
{
- char rpath[FILENAME_MAX];
-
- return _spawnve(nMode, find_exec((char*)szPath,rpath), szaArgv, szaEnv);
+ char rpath[FILENAME_MAX];
+ return _spawnve(nMode, find_exec((char*)szPath,rpath), szaArgv, szaEnv);
}
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/process.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/process.h>
+#include <msvcrt/stdlib.h>
int _spawnvp(int nMode, const char* szPath, char* const* szaArgv)
{
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/process.h>
-#include <crtdll/errno.h>
+#include <msvcrt/process.h>
+#include <msvcrt/errno.h>
int _spawnvpe(int nMode, const char* szPath, char* const* szaArgv, char* const* szaEnv)
#include <windows.h>
-#include <crtdll/process.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/process.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
unsigned long
#include <windows.h>
-#include <crtdll/process.h>
+#include <msvcrt/process.h>
unsigned long __threadid (void)
{
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: divdi3.c,v 1.1 1999/04/17 09:10:23 ariadne Exp $
+ * $Id: divdi3.c,v 1.2 2002/11/24 18:42:16 robd Exp $
*/
-#include <crtdll/internal/quad.h>
+#include <msvcrt/internal/quad.h>
/*
* Divide two signed quads.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: moddi3.c,v 1.1 1999/04/17 09:10:23 ariadne Exp $
+ * $Id: moddi3.c,v 1.2 2002/11/24 18:42:16 robd Exp $
*/
-#include <crtdll/internal/quad.h>
+#include <msvcrt/internal/quad.h>
/*
* Return remainder after dividing two signed quads.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: qdivrem.c,v 1.1 1999/04/17 09:10:23 ariadne Exp $
+ * $Id: qdivrem.c,v 1.2 2002/11/24 18:42:16 robd Exp $
*/
/*
* section 4.3.1, pp. 257--259.
*/
-#include <crtdll/internal/quad.h>
+#include <msvcrt/internal/quad.h>
#define B (1 << HALF_BITS) /* digit base */
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: udivdi3.c,v 1.1 1999/04/17 09:10:23 ariadne Exp $
+ * $Id: udivdi3.c,v 1.2 2002/11/24 18:42:16 robd Exp $
*/
-#include <crtdll/internal/quad.h>
+#include <msvcrt/internal/quad.h>
/*
* Divide two unsigned quads.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: umoddi3.c,v 1.1 1999/04/17 09:10:23 ariadne Exp $
+ * $Id: umoddi3.c,v 1.2 2002/11/24 18:42:16 robd Exp $
*/
-#include <crtdll/internal/quad.h>
+#include <msvcrt/internal/quad.h>
/*
* Return remainder after dividing two unsigned quads.
-#include <crtdll/search.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/search.h>
+#include <msvcrt/stdlib.h>
void *_lfind(const void *key, const void *base, size_t *nelp,
{
char *char_base = (char *)base;
int i;
- for(i=0;i<*nelp;i++) {
+
+ for (i = 0; i < *nelp; i++) {
if ( compar(key,char_base) == 0)
return char_base;
char_base += width;
-#include <crtdll/search.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
+#include <msvcrt/search.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
void *_lsearch(const void *key, void *base, size_t *nelp, size_t width,
int (*compar)(const void *, const void *))
{
- void *ret_find = _lfind(key,base,nelp,width,compar);
- if ( ret_find != NULL )
- return ret_find;
+ void *ret_find = _lfind(key,base,nelp,width,compar);
- memcpy( base + (*nelp*width), key, width );
- (*nelp)++;
- return base ;
+ if (ret_find != NULL)
+ return ret_find;
+
+#ifdef __GNUC__
+ memcpy(base + (*nelp*width), key, width);
+#else
+ memcpy((int*)base + (*nelp*width), key, width);
+#endif
+ (*nelp)++;
+ return base;
}
//push ebp generated by the compiler
//mov ebp, esp
+#ifdef __GNUC__
__asm__ __volatile__ (
"movl 8(%ebp),%edi\n\t" /* get jmp_buf */
"movl 12(%ebp),%eax\n\t" /* store retval in j->eax */
"iret\n\t" /* actually jump to new cs:eip loading flags */
);
+#else
+#endif /*__GNUC__*/
return value; // dummy return never reached
}
-
+#ifdef __GNUC__
int _setjmp( jmp_buf env )
{
//push ebp generated by the compiler
//mov ebp, esp
-
__asm__ __volatile__ (
-
"pushl %edi\n\t"
"movl 8(%ebp),%edi\n\t"
"popl %edi\n\t"
);
-
-
-
-
-
return 0;
}
+
+#else
+#endif /*__GNUC__*/
-#include <crtdll/signal.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/errno.h>
-#include <crtdll/string.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/signal.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
void _default_handler(int signal);
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdlib.h>
void **__pxcptinfoptrs (void)
{
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
FILE * __alloc_file(void);
file->_flag = _IOWRT;
file->_base = file->_ptr = NULL;
+
return file;
}
-
-
-
-
-
-
-
-
-
-
+
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/errno.h>
-#include <crtdll/sys/types.h>
-#include <crtdll/sys/stat.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/io.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/sys/stat.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
+#include <msvcrt/io.h>
int fflush(FILE *f)
do {
n = _write(fileno(f), base, rn);
if (n <= 0) {
- f->_flag |= _IOERR;
- return EOF;
+ f->_flag |= _IOERR;
+ return EOF;
}
rn -= n;
base += n;
25/02/99: Added fgetwc
*/
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
-int
-fgetc(FILE *f)
+int fgetc(FILE *f)
{
return getc(f);
}
-wint_t
-fgetwc(FILE *f)
+wint_t fgetwc(FILE *f)
{
return getwc(f);
}
-#include <crtdll/stdio.h>
-#include <crtdll/conio.h>
-#include <crtdll/wchar.h>
+/* $Id: fgetchar.c,v 1.5 2002/11/24 18:42:17 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * fgetchar.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <msvcrt/stdio.h>
+#include <msvcrt/conio.h>
int _fgetchar (void)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/errno.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
-int
-fgetpos(FILE *stream, fpos_t *pos)
+int fgetpos(FILE *stream, fpos_t *pos)
{
if (stream && pos)
{
+/* $Id: fgets.c,v 1.3 2002/11/24 18:42:17 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * fgets.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * 28/12/1998: Appropriated for Reactos
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
-char *
-fgets(char *s, int n, FILE *f)
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
+
+
+char* fgets(char* s, int n, FILE* f)
{
int c=0;
char *cs;
cs = s;
- while (--n>0 && (c = getc(f)) != EOF)
- {
+ while (--n>0 && (c = getc(f)) != EOF) {
*cs++ = c;
if (c == '\n')
break;
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
+
+//wchar_t* fgetws(wchar_t* wcaBuffer, int nBufferSize, FILE* fileRead);
+//char* fgets(char *s, int n, FILE *f);
+//int _getw(FILE *stream);
+/*
+// Read a word (int) from STREAM.
+int _getw(FILE *stream)
+{
+ int w;
+
+ // Is there a better way?
+ if (fread( &w, sizeof(w), 1, stream) != 1)
+ return(EOF);
+ return(w);
+}
+
+//getc can be a macro
+#undef getc
+
+int getc(FILE *fp)
+{
+ int c = -1;
+// check for invalid stream
+ if ( !__validfp (fp) ) {
+ __set_errno(EINVAL);
+ return EOF;
+ }
+// check for read access on stream
+ if ( !OPEN4READING(fp) ) {
+ __set_errno(EINVAL);
+ return -1;
+ }
+ if(fp->_cnt > 0) {
+ fp->_cnt--;
+ c = (int)*fp->_ptr++;
+ }
+ else {
+ c = _filbuf(fp);
+ }
+ return c;
+}
+ */
+
+wchar_t* fgetws(wchar_t* s, int n, FILE* f)
+{
+ int c = 0;
+ wchar_t* cs;
+
+ cs = s;
+ while (--n > 0 && (c = _getw(f)) != EOF) {
+ *cs++ = c;
+ if (c == L'\n')
+ break;
+ }
+ if (c == EOF && cs == s) {
+ return NULL;
+ }
+ *cs++ = L'\0';
+ return s;
+}
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
#undef fileno
int fileno(FILE *f)
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/wchar.h>
-#include <crtdll/sys/types.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/io.h>
-#include <crtdll/errno.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/wchar.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+
int cntcr(char *bufp, int bufsiz);
int convert(char *endp, int bufsiz,int n);
int _writecnv(int fn, void *buf, size_t bufsiz);
-int
-_flsbuf(int c, FILE *f)
+
+int _flsbuf(int c, FILE *f)
{
char *base;
int n, rn;
char c1;
int size;
-
-
if (!OPEN4WRITING(f)) {
__set_errno (EINVAL);
return EOF;
}
-// no file associated with buffer
-// this is a memory stream
-
- if ( fileno(f) == -1 )
+ // no file associated with buffer, this is a memory stream
+ if (fileno(f) == -1) {
return c;
+ }
/* if the buffer is not yet allocated, allocate it */
- if ((base = f->_base) == NULL && (f->_flag & _IONBF) == 0)
- {
+ if ((base = f->_base) == NULL && (f->_flag & _IONBF) == 0) {
size = 4096;
- if ((f->_base = base = malloc (size)) == NULL)
- {
+ if ((f->_base = base = malloc (size)) == NULL) {
f->_flag |= _IONBF;
f->_flag &= ~(_IOFBF|_IOLBF);
- }
- else
- {
+ } else {
f->_flag |= _IOMYBUF;
f->_cnt = f->_bufsiz = size;
f->_ptr = base;
rn = 0;
- if (f == stdout && isatty (fileno (stdout)))
- f->_flag |= _IOLBF;
+ if (f == stdout && isatty (fileno (stdout))) {
+ f->_flag |= _IOLBF;
+ }
}
}
- if (f->_flag & _IOLBF)
- {
+ if (f->_flag & _IOLBF) {
/* in line-buffering mode we get here on each character */
*f->_ptr++ = c;
rn = f->_ptr - base;
- if (c == '\n' || rn >= f->_bufsiz)
- {
+ if (c == '\n' || rn >= f->_bufsiz) {
/* time for real flush */
f->_ptr = base;
f->_cnt = 0;
- }
- else
- {
+ } else {
/* we got here because _cnt is wrong, so fix it */
- /* Negative _cnt causes all output functions
- to call _flsbuf for each character, thus realizing line-buffering */
+ /* Negative _cnt causes all output functions to call */
+ /* _flsbuf for each character, thus realizing line-buffering */
f->_cnt = -rn;
return c;
}
- }
- else if (f->_flag & _IONBF)
- {
+ } else if (f->_flag & _IONBF) {
c1 = c;
rn = 1;
base = &c1;
- f->_cnt = 0;
- }
- else /* _IOFBF */
- {
+ f->_cnt = 0;
+ } else { /* _IOFBF */
rn = f->_ptr - base;
f->_ptr = base;
if ( (f->_flag & _IOAHEAD) == _IOAHEAD )
f->_cnt = f->_bufsiz;
f->_flag &= ~_IOAHEAD;
}
-
-
-
f->_flag &= ~_IODIRTY;
- while (rn > 0)
- {
+ while (rn > 0) {
n = _write(fileno(f), base, rn);
- if (n <= 0)
- {
+ if (n <= 0) {
f->_flag |= _IOERR;
return EOF;
}
rn -= n;
base += n;
}
-
-
- if ((f->_flag&(_IOLBF|_IONBF)) == 0)
- {
+ if ((f->_flag&(_IOLBF|_IONBF)) == 0) {
f->_cnt--;
*f->_ptr++ = c;
}
wint_t _flswbuf(wchar_t c,FILE *fp)
{
- return (wint_t )_flsbuf((int)c,fp);
-}
+ int result;
+ result = _flsbuf((int)c, fp);
+ if (result == EOF)
+ return WEOF;
+ return (wint_t)result;
+}
int _writecnv(int fn, void *buf, size_t siz)
{
char *bufp = (char *)buf;
int bufsiz = siz;
-
- char *tmp;
+ char *tmp;
int cr1 = 0;
int cr2 = 0;
-
int n;
-
cr1 = cntcr(bufp,bufsiz);
-
tmp = malloc(cr1);
memcpy(tmp,bufp+bufsiz-cr1,cr1);
cr2 = cntcr(tmp,cr1);
-
convert(bufp,bufsiz-cr2,cr1-cr2);
n = _write(fn, bufp, bufsiz + cr1);
-
convert(tmp,cr1,cr2);
n += _write(fn, tmp, cr1 + cr2);
free(tmp);
return n;
-
-
}
int convert(char *endp, int bufsiz,int n)
}
return n;
}
+
int cntcr(char *bufp, int bufsiz)
{
int cr = 0;
+
while (bufsiz > 0) {
- if (*bufp == '\n')
+ if (*bufp == '\n') {
cr++;
+ }
bufp++;
bufsiz--;
}
-
return cr;
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/wchar.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/wchar.h>
+#include <msvcrt/internal/file.h>
int
fputc(int c, FILE *fp)
wint_t
fputwc(wchar_t c, FILE *fp)
{
- return fputwc(c,fp);
+ return putwc(c,fp);
}
-#include <crtdll/stdio.h>
-#include <crtdll/conio.h>
-#include <crtdll/wchar.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/wchar.h>
int _fputchar (int c)
{
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <windows.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
+#include <msvcrt/string.h>
+
+//int fputws(const wchar_t* wsOutput, FILE* fileWrite)
+//int fputs(const char *s, FILE *f)
+
+int
+fputws(const wchar_t* s, FILE* f)
+{
+ int r = 0;
+ int c;
+ int unbuffered;
+ wchar_t localbuf[BUFSIZ];
+
+ unbuffered = f->_flag & _IONBF;
+ if (unbuffered)
+ {
+ f->_flag &= ~_IONBF;
+ f->_ptr = f->_base = localbuf;
+ f->_bufsiz = BUFSIZ;
+ }
+
+ while ((c = *s++))
+ r = putwc(c, f);
+
+ if (unbuffered)
+ {
+ fflush(f);
+ f->_flag |= _IONBF;
+ f->_base = NULL;
+ f->_bufsiz = 0;
+ f->_cnt = 0;
+ }
+ return(r);
+}
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/sys/types.h>
-#include <crtdll/stdio.h>
-#include <crtdll/fcntl.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/io.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
-
-FILE *
-freopen(const char *file, const char *mode, FILE *f)
+FILE *freopen(const char *file, const char *mode, FILE *f)
{
int fd, rw, oflags=0;
char tbchar;
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/fcntl.h>
-#include <crtdll/io.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
int fseek(FILE *f, long offset, int ptrname)
return 0;
}
}
-
p = lseek(fileno(f), offset, ptrname);
f->_cnt = 0;
-1 : 0;
}
return p==-1 ? -1 : 0;
-
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
-int
-fsetpos(FILE *stream,const fpos_t *pos)
+int fsetpos(FILE *stream,const fpos_t *pos)
{
if (stream && pos)
{
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/sys/types.h>
-#include <crtdll/stdio.h>
-#include <crtdll/io.h>
-#include <crtdll/fcntl.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/share.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/share.h>
+#include <msvcrt/internal/file.h>
-FILE * __alloc_file(void);
+FILE* __alloc_file(void);
-FILE* _fsopen(const char *file, const char *mode, int shflag)
+FILE* _fsopen(const char* file, const char* mode, int shflag)
{
- FILE *f;
+ FILE* f;
int fd, rw, oflags = 0;
char tbchar;
else
oflags |= (_fmode & (O_TEXT|O_BINARY));
-
-
if ( shflag == _SH_DENYNO )
- shf = _S_IREAD | _S_IWRITE;
+ shf = _S_IREAD | _S_IWRITE;
else if( shflag == _SH_DENYRD )
- shf = _S_IWRITE;
+ shf = _S_IWRITE;
else if( shflag == _SH_DENYRW )
- shf = 0;
+ shf = 0;
else if( shflag == _SH_DENYWR )
- shf = _S_IREAD;
+ shf = _S_IREAD;
else
- shf = _S_IREAD | _S_IWRITE;
-
+ shf = _S_IREAD | _S_IWRITE;
+
fd = _open(file, oflags, shf);
if (fd < 0)
return NULL;
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-//#include <crtdll/stubs.h>
-#include <crtdll/stdio.h>
-//#include <crtdll/unistd.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/fcntl.h>
-#include <crtdll/io.h>
+
+#include <msvcrt/stdio.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/io.h>
#include <errno.h>
+#include <msvcrt/internal/file.h>
-long
-ftell(FILE *f)
+long ftell(FILE *f)
{
long tres;
int adjust=0;
if (f->_cnt < 0)
f->_cnt = 0;
-
else if (f->_flag&_IOREAD)
{
adjust = - f->_cnt;
if (f->_base && (f->_flag&_IONBF)==0)
adjust = f->_ptr - f->_base;
}
-
else
return -1;
+
tres = lseek(fileno(f), 0L, SEEK_CUR);
if (tres<0)
return tres;
//f->_cnt = f->_bufsiz - tres;
//f->_ptr = f->_base + tres;
+
return tres;
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
-// not exported by crtdll
-__file_rec *__file_rec_list;
-void
-_fwalk(void (*func)(FILE *))
+// not exported by msvcrt or crtdll
+__file_rec* __file_rec_list;
+
+void _fwalk(void (*func)(FILE*))
{
- __file_rec *fr;
- int i;
-
- for (fr=__file_rec_list; fr; fr=fr->next)
- for (i=0; i<fr->count; i++)
- if (fr->files[i]->_flag)
- func(fr->files[i]);
+ __file_rec* fr;
+ int i;
+
+ for (fr=__file_rec_list; fr; fr=fr->next)
+ for (i=0; i<fr->count; i++)
+ if (fr->files[i]->_flag)
+ func(fr->files[i]);
}
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
#if 0
size_t
* 28/12/98: Appropriated for Reactos
*/
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
-char *
-gets(char *s)
+char* gets(char* s)
{
int c;
char *cs;
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
/* Read a word (int) from STREAM. */
-int
-_getw(FILE *stream)
+int _getw(FILE *stream)
{
int w;
/* Is there a better way? */
- if (fread( &w, sizeof(w), 1, stream) != 1)
+ if (fread( &w, sizeof(w), 1, stream) != 1) {
+ // EOF is a legitimate integer value so users must
+ // check feof or ferror to verify an EOF return.
return(EOF);
+ }
return(w);
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
-#include <crtdll/errno.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/errno.h>
#ifdef perror
void perror(const char *s);
#endif
-void
-perror(const char *s)
+void perror(const char *s)
{
fprintf(stderr, "%s: %s\n", s, _strerror(NULL));
#include <windows.h>
-#include <crtdll/io.h>
-#include <crtdll/errno.h>
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
-#include <crtdll/internal/file.h>
-
-FILE *
-_popen (const char *cm, const char *md) /* program name, pipe mode */
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
+
+
+FILE *_popen (const char *cm, const char *md) /* program name, pipe mode */
{
FILE *pf;
HANDLE hReadPipe, hWritePipe;
Boston, MA 02111-1307, USA. */
#include <stdarg.h>
-#include <crtdll/stdio.h>
-#include <crtdll/wchar.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/wchar.h>
/* Write formatted output to stdout from the format string FORMAT. */
/* VARARGS1 */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <windows.h>
-#include <crtdll/stdio.h>
-#include <crtdll/wchar.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/wchar.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
// putc can be a macro
#undef putc
+#undef putwc
-int putc(int c, FILE *fp)
+int putc(int c, FILE* fp)
{
-
-// valid stream macro should check that fp
-// is dword aligned
+// valid stream macro should check that fp is dword aligned
if (!__validfp (fp)) {
__set_errno(EINVAL);
return -1;
return EOF;
}
-wint_t putwc(wchar_t c, FILE *fp)
+//wint_t putwc(wint_t c, FILE* fp)
+//int putwc(wchar_t c, FILE* fp)
+int putwc(wint_t c, FILE* fp)
{
// might check on multi bytes if text mode
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
#undef putc
#undef putchar
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/io.h>
#include <windows.h>
-#include <crtdll/string.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/string.h>
#undef putchar
-int
-puts(const char *s)
+
+
+int puts(const char *s)
{
-
- int c;
- while ((c = *s++))
- putchar(c);
- return putchar('\n');
+ int c;
+
+ while ((c = *s++))
+ putchar(c);
+ return putchar('\n');
}
/* Copyright (C) 1991 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ * This file is part of the GNU C Library.
+ *
+ * The GNU C Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The GNU C Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+ * Cambridge, MA 02139, USA. */
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
/* Write the word (int) W to STREAM. */
-int
-_putw(int w,FILE *stream)
+int _putw(int w,FILE *stream)
{
/* Is there a better way? */
if (fwrite( &w, sizeof(w), 1, stream) < 1)
#include <windows.h>
+
int remove(const char *fn)
{
if (!DeleteFileA(fn))
return -1;
return 0;
}
-
#include <windows.h>
-#include <crtdll/stdio.h>
-#include <crtdll/io.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
int rename(const char *old_, const char *new_)
{
if ( old_ == NULL || new_ == NULL )
return -1;
+
if ( !MoveFileA(old_,new_) )
return -1;
return 0;
}
-
-
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/io.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
void rewind(FILE *f)
* NOTE Not tested.
*/
-#include <crtdll/internal/file.h>
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
#ifndef F_OK
#define F_OK 0x01
Cambridge, MA 02139, USA. */
#include <stdarg.h>
-#include <crtdll/stdio.h>
-#include <crtdll/wchar.h>
-#include <crtdll/alloc.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/wchar.h>
+#include <msvcrt/alloc.h>
/* The function `vscanf' is not defined in ISO C. Therefore we must
return done;
}
-
-
int
wscanf(const wchar_t *fmt, ...)
{
done = VSCANF (f, arg);
va_end (arg);
free(f);
+
return done;
}
-
-
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
-void
-setbuf(FILE *f, char *buf)
+void setbuf(FILE *f, char *buf)
{
if (buf)
setvbuf(f, buf, _IOFBF, BUFSIZ);
Boston, MA 02111-1307, USA. */
#include <stdarg.h>
-#include <crtdll/stdio.h>
-#include <crtdll/wchar.h>
-#include <crtdll/alloc.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/wchar.h>
+#include <msvcrt/alloc.h>
int __vsscanf (const char *s,const char *format,va_list arg);
return done;
}
-#ifdef USE_IN_LIBIO
-# undef _IO_sscanf
-/* This is for libg++. */
-strong_alias (sscanf, _IO_sscanf)
-#endif
-
-
-
-
-int
-swscanf(const wchar_t *str, const wchar_t *fmt, ...)
+int swscanf(const wchar_t *str, const wchar_t *fmt, ...)
{
va_list arg;
int done;
va_end (arg);
free(f);
- return done;
-
+ return done;
}
-
-
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
-//#include <crtdll/stdiohk.h>
-
-
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
FILE _iob[5] =
{
#include <windows.h>
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
char *_tempnam(const char *dir,const char *prefix )
{
- char *TempFileName = malloc(MAX_PATH);
- char *d;
- if ( dir == NULL )
- d = getenv("TMP");
- else
- d = (char *)dir;
+ char *TempFileName = malloc(MAX_PATH);
+ char *d;
- if ( GetTempFileNameA(d, prefix, 0, TempFileName ) == 0 ) {
- free(TempFileName);
- return NULL;
- }
-
- return TempFileName;
+ if ( dir == NULL )
+ d = getenv("TMP");
+ else
+ d = (char *)dir;
+
+#ifdef _MSVCRT_LIB_
+ if (GetTempFileNameA(d, prefix, 1, TempFileName) == 0) {
+#else
+ if (GetTempFileNameA(d, prefix, 0, TempFileName) == 0) {
+#endif /*_MSVCRT_LIB_*/
+ free(TempFileName);
+ return NULL;
+ }
+
+ return TempFileName;
}
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-//#include <crtdll/stubs.h>
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/errno.h>
-#include <crtdll/fcntl.h>
-//#include <crtdll/unistd.h>
-#include <crtdll/io.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/share.h>
-#if 0
-#ifndef __dj_include_stdio_h_
-#define _name_to_remove _tmpfname
-#endif
-#endif
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/fcntl.h>
+//#include <msvcrt/unistd.h>
+#include <msvcrt/io.h>
+#include <msvcrt/share.h>
+#include <msvcrt/internal/file.h>
+
FILE * __alloc_file(void);
#include <windows.h>
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
-
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
char * tmpnam(char *s)
{
char PathName[MAX_PATH];
static char static_buf[MAX_PATH];
- GetTempPath(MAX_PATH,PathName);
+
+ GetTempPathA(MAX_PATH, PathName);
GetTempFileNameA(PathName, "ARI",007,static_buf);
strcpy(s,static_buf);
- return s;
+
+ return s;
}
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/wchar.h>
-#include <crtdll/errno.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/wchar.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
-int
-ungetc(int c, FILE *f)
-{
+int ungetc(int c, FILE *f)
+{
if (!__validfp (f) || !OPEN4READING(f)) {
__set_errno (EINVAL);
return EOF;
if (c == EOF )
return EOF;
-
-
if ( f->_ptr == NULL || f->_base == NULL)
return EOF;
if (c == (wchar_t)EOF )
return EOF;
-
-
if ( f->_ptr == NULL || f->_base == NULL)
return EOF;
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/stdarg.h>
-#include <crtdll/malloc.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdarg.h>
+#include <msvcrt/malloc.h>
+#include <msvcrt/internal/file.h>
int _isnanl(double x);
int _isinfl(double x);
#include <stdarg.h>
-#include <crtdll/ctype.h>
-#include <crtdll/string.h>
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
-#include <crtdll/math.h>
-#include <crtdll/internal/ieee.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/string.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/math.h>
+#include <msvcrt/internal/ieee.h>
#define ZEROPAD 1 /* pad with zero */
Boston, MA 02111-1307, USA. */
-#include <crtdll/errno.h>
+#include <msvcrt/errno.h>
#include <limits.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/ctype.h>
#include <stdarg.h>
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
-#include <crtdll/wchar.h>
-#include <crtdll/malloc.h>
-#include <crtdll/internal/file.h>
-#include <crtdll/mbstring.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+#include <msvcrt/wchar.h>
+#include <msvcrt/malloc.h>
+#include <msvcrt/internal/file.h>
+#include <msvcrt/mbstring.h>
/* The internal entry points for `strtoX' take an extra flag argument
saying whether or not to parse locale-dependent number grouping. */
/* Those are flags in the conversion format. */
# define LONG 0x001 /* l: long or double */
-# define LONGDBL 0x002 /* L: long long or long double */
+# define LONGDBL 0x002 /* L: LONGLONG or long double */
# define SHORT 0x004 /* h: short */
# define SUPPRESS 0x008 /* *: suppress assignment */
# define POINTER 0x010 /* weird %p pointer (`fake hex') */
break;
case 'q':
case 'L':
- /* double's are long double's, and int's are long long int's. */
+ /* double's are long double's, and int's are LONGLONG int's. */
if (flags & TYPEMOD)
/* Signal illegal format element. */
conv_error ();
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
#include <stdarg.h>
-#include <crtdll/malloc.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/malloc.h>
+#include <msvcrt/internal/file.h>
int _isnanl(double x);
int _isinfl(double x);
int _isnan(double x);
int _isinf(double x);
-extern int putwc (wchar_t wc, FILE* fileWrite);
+int putwc(wint_t wc, FILE* fileWrite);
+//wint_t putwc (wint_t wc, FILE* fileWrite);
int
__vfwprintf(FILE *fp, const wchar_t *fmt0, va_list argp);
#include <stdarg.h>
-#include <crtdll/ctype.h>
-#include <crtdll/string.h>
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
-#include <crtdll/math.h>
-#include <crtdll/internal/ieee.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/string.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/math.h>
+#include <msvcrt/internal/ieee.h>
#define ZEROPAD 1 /* pad with zero */
#include <stdarg.h>
#undef __OPTIMIZE__ /* Avoid inline `vprintf' function. */
-#include <crtdll/stdio.h>
-#include <crtdll/wchar.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/wchar.h>
#undef vprintf
#undef vwprintf
Cambridge, MA 02139, USA. */
#include <stdarg.h>
-#include <crtdll/stdio.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
int __vfscanf (FILE *s, const char *format, va_list argptr);
/* Read formatted input from stdin according to the format
string in FORMAT, using the argument list in ARG. */
-int
-__vscanf (const char *format, va_list arg)
+int __vscanf (const char *format, va_list arg)
{
- return __vfscanf (stdin, format, arg);
+ return __vfscanf(stdin, format, arg);
}
//weak_alias (__vscanf, vscanf)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
#include <stdarg.h>
#include <limits.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/internal/file.h>
int
vsprintf(char *str, const char *fmt, va_list ap)
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <crtdll/errno.h>
-#include <stdarg.h>
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/stdarg.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
+#include <msvcrt/internal/stdio.h>
#undef vsscanf
-int __vfscanf (FILE *s, const char *format, va_list argptr);
-
/* Read formatted input from S according to the format
string FORMAT, using the argument list in ARG. */
-int
-__vsscanf (const char *s,const char *format,va_list arg)
+int __vsscanf(const char *s,const char *format,va_list arg)
{
FILE f;
memset ((void *) &f, 0, sizeof (f));
-
-
f._flag = _IOREAD;
f._ptr = (char *)s;
f._base = (char *)s;
f._bufsiz = strlen(s);
f._cnt = f._bufsiz;
-
return __vfscanf (&f, format, arg);
}
-
-//weak_alias (__vsscanf, vsscanf)
-
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/crttypes.h>
int
abs(int j)
--- /dev/null
+#include <windows.h>
+#include <msvcrt/stdlib.h>
+
+
+#undef alloca
+void *alloca(size_t s)
+{
+ register unsigned int as = s;
+
+// alloca(0) should not return the stack pointer
+ if ( s == 0 )
+ return NULL;
+
+
+ if ( (s & 0xfffffffc) != 0 )
+ as += 4;
+
+ as &= 0xfffffffc;
+
+ __asm__ __volatile__(
+ "mov %0, %%edx \n"
+// "popl %%ebp \n"
+ "leave \n"
+ "popl %%ecx \n"
+ "subl %%edx, %%esp \n"
+ "movl %%esp, %%eax \n"
+ "addl $20, %%eax \n"//4 bytes + 16 bytes = arguments
+ "push %%ecx \n"
+ "ret \n"
+ :
+ :"g" ( as)
+ );
+
+
+ return NULL;
+}
+
+void *_alloca(size_t s)
+{
+ register unsigned int as = s;
+
+// alloca(0) should not return the stack pointer
+ if ( s == 0 )
+ return NULL;
+
+
+ if ( (s & 0xfffffffc) != 0 )
+ as += 4;
+
+ as &= 0xfffffffc;
+
+ __asm__ __volatile__(
+ "mov %0, %%edx \n"
+// "popl %%ebp \n"
+ "leave \n"
+ "popl %%ecx \n"
+ "subl %%edx, %%esp \n"
+ "movl %%esp, %%eax \n"
+ "addl $20, %%eax \n"//4 bytes + 16 bytes = arguments
+ "push %%ecx \n"
+ "ret \n"
+ :
+ :"g" ( as)
+ );
+
+
+ return NULL;
+}
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdlib.h>
-#include <crtdll/float.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/float.h>
char *ecvtbuf (double, int, int *, int *, char *);
/* 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>
+#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 *);
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdlib.h>
-#include <crtdll/float.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/float.h>
char *fcvtbuf (double, int, int *, int *, char *);
/* 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>
+#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 *);
char *ecvtbuf (double, int, int *, int *, char *);
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/stdlib.h>
#include <windows.h>
+#include <msvcrt/stdlib.h>
#undef fullpath
-char *fullpath( char *absPath, const char *relPath, size_t maxLength )
+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* _fullpath(char* absPath, const char* relPath, size_t maxLength)
{
-
+ char* lpFilePart;
- char *lpFilePart;
- if ( GetFullPathName(relPath,maxLength,absPath,&lpFilePart) == 0 )
+ if (GetFullPathName(relPath,maxLength,absPath,&lpFilePart) == 0)
return NULL;
return absPath;
}
-
-
-
-
* 1998: Added ltoa Boudewijn Dekker
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/errno.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/internal/file.h>
-char *
-itoa(int value, char *string, int radix)
+#include <msvcrt/errno.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
+
+
+char* _itoa(int value, char* string, int radix)
{
char tmp[33];
char *tp = tmp;
return string;
}
-
-char *
-ltoa(long value, char *string, int radix)
+char* _ltoa(long value, char* string, int radix)
{
char tmp[33];
char *tp = tmp;
return string;
}
-char *
-_ultoa(unsigned long value, char *string, int radix)
+char* _ultoa(unsigned long value, char* string, int radix)
{
char tmp[33];
char *tp = tmp;
return 0;
}
-
while (v || tp == tmp)
{
i = v % radix;
string = (char *)malloc((tp-tmp)+1);
sp = string;
-
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
-/* $Id: itow.c,v 1.1 2000/12/22 23:17:03 ea Exp $
+/* $Id: itow.c,v 1.2 2002/11/24 18:42:18 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* 2000: derived from ./itoa.c by ea
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/errno.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/internal/file.h>
-wchar_t *
-_itow (int value, wchar_t *string, int radix)
-{
- wchar_t tmp [33];
- wchar_t * tp = tmp;
- int i;
- unsigned int 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+ (wchar_t) '0';
- }
- else
- {
- *tp++ = i + (wchar_t) 'a' - 10;
- }
- }
-
- if (string == 0)
- {
- string = (wchar_t *) malloc((tp-tmp) + (sign + 1) * sizeof(wchar_t));
- }
- sp = string;
-
- if (sign)
- {
- *sp++ = (wchar_t) '-';
- }
- while (tp > tmp)
- {
- *sp++ = *--tp;
- }
- *sp = (wchar_t) 0;
- return string;
-}
+#include <msvcrt/errno.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
-wchar_t *
-_ltow (long value, wchar_t *string, int radix)
+wchar_t* _itow(int value, wchar_t* string, int radix)
{
- wchar_t tmp [33];
- wchar_t * tp = tmp;
- long int i;
- unsigned long int 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 + (wchar_t) '0';
- }
- else
- {
- *tp++ = i + (wchar_t) 'a' - 10;
- }
- }
-
- if (string == 0)
- {
- string = (wchar_t *) malloc((tp - tmp) + (sign + 1) * sizeof(wchar_t));
- }
- sp = string;
-
- if (sign)
- {
- *sp++ = (wchar_t) '-';
- }
- while (tp > tmp)
- {
- *sp++ = *--tp;
- }
- *sp = (wchar_t) 0;
- return string;
+ wchar_t tmp [33];
+ wchar_t * tp = tmp;
+ int i;
+ unsigned int 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+ (wchar_t) '0';
+ } else {
+ *tp++ = i + (wchar_t) 'a' - 10;
+ }
+ }
+
+ if (string == 0) {
+ string = (wchar_t *) malloc((tp-tmp) + (sign + 1) * sizeof(wchar_t));
+ }
+ sp = string;
+
+ if (sign) {
+ *sp++ = (wchar_t) '-';
+ }
+ while (tp > tmp) {
+ *sp++ = *--tp;
+ }
+ *sp = (wchar_t) 0;
+ return string;
}
-wchar_t *
-_ultow (unsigned long value, wchar_t *string, int radix)
+wchar_t* _ltow(long value, wchar_t* string, int radix)
{
- wchar_t tmp [33];
- wchar_t * tp = tmp;
- long int i;
- unsigned long int 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 + (wchar_t) '0';
- }
- else
- {
- *tp++ = i + (wchar_t) 'a' - 10;
- }
- }
-
- if (string == 0)
- {
- string = (wchar_t *) malloc((tp - tmp) + sizeof(wchar_t));
- }
- sp = string;
-
-
- while (tp > tmp)
- {
- *sp++ = *--tp;
- }
- *sp = (wchar_t) 0;
- return string;
+ wchar_t tmp [33];
+ wchar_t * tp = tmp;
+ long int i;
+ unsigned long int 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 + (wchar_t) '0';
+ } else {
+ *tp++ = i + (wchar_t) 'a' - 10;
+ }
+ }
+
+ if (string == 0) {
+ string = (wchar_t *) malloc((tp - tmp) + (sign + 1) * sizeof(wchar_t));
+ }
+ sp = string;
+
+ if (sign) {
+ *sp++ = (wchar_t) '-';
+ }
+ while (tp > tmp) {
+ *sp++ = *--tp;
+ }
+ *sp = (wchar_t) 0;
+ return string;
}
-
-/* EOF */
+wchar_t* _ultow(unsigned long value, wchar_t* string, int radix)
+{
+ wchar_t tmp [33];
+ wchar_t * tp = tmp;
+ long int i;
+ unsigned long int 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 + (wchar_t) '0';
+ } else {
+ *tp++ = i + (wchar_t) 'a' - 10;
+ }
+ }
+
+ if (string == 0) {
+#ifdef _MSVCRT_LIB_
+ string = (wchar_t *)malloc(((tp-tmp)+1)*sizeof(wchar_t));
+#else
+ string = (wchar_t *) malloc((tp - tmp) + sizeof(wchar_t));
+#endif /*_MSVCRT_LIB_*/
+ }
+ sp = string;
+
+ while (tp > tmp) {
+ *sp++ = *--tp;
+ }
+ *sp = (wchar_t) 0;
+ return string;
+}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/crttypes.h>
long
labs(long j)
-/* $Id: makepath.c,v 1.7 2001/09/09 12:13:14 hbirr Exp $
+/* $Id: makepath.c,v 1.8 2002/11/24 18:42:18 robd Exp $
*/
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
+#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) && (*drive))
- {
+ if ((drive != NULL) && (*drive)) {
strcpy(path, drive);
strcat(path, ":");
+ } else {
+ (*path)=0;
}
- else
- (*path)=0;
- if (dir != NULL)
- {
+ if (dir != NULL) {
strcat(path, dir);
dir_len = strlen(dir);
if (dir_len && *(dir + dir_len - 1) != '\\')
strcat(path, "\\");
}
- if (fname != NULL)
- {
+ if (fname != NULL) {
strcat(path, fname);
- if (ext != NULL && *ext != 0)
- {
+ if (ext != NULL && *ext != 0) {
if (*ext != '.')
strcat(path, ".");
strcat(path, ext);
#include <windows.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdlib.h>
void* malloc(size_t _size)
{
return(HeapReAlloc(GetProcessHeap(),0,_ptr,_size));
}
-#undef alloca
-void *alloca(size_t s)
-{
- register unsigned int as = s;
-
-// alloca(0) should not return the stack pointer
- if ( s == 0 )
- return NULL;
-
-
- if ( (s & 0xfffffffc) != 0 )
- as += 4;
-
- as &= 0xfffffffc;
-
- __asm__ __volatile__(
- "mov %0, %%edx \n"
-// "popl %%ebp \n"
- "leave \n"
- "popl %%ecx \n"
- "subl %%edx, %%esp \n"
- "movl %%esp, %%eax \n"
- "addl $20, %%eax \n"//4 bytes + 16 bytes = arguments
- "push %%ecx \n"
- "ret \n"
- :
- :"g" ( as)
- );
-
-
- return NULL;
-}
-
-void *_alloca(size_t s)
-{
- register unsigned int as = s;
-
-// alloca(0) should not return the stack pointer
- if ( s == 0 )
- return NULL;
-
-
- if ( (s & 0xfffffffc) != 0 )
- as += 4;
-
- as &= 0xfffffffc;
-
- __asm__ __volatile__(
- "mov %0, %%edx \n"
-// "popl %%ebp \n"
- "leave \n"
- "popl %%ecx \n"
- "subl %%edx, %%esp \n"
- "movl %%esp, %%eax \n"
- "addl $20, %%eax \n"//4 bytes + 16 bytes = arguments
- "push %%ecx \n"
- "ret \n"
- :
- :"g" ( as)
- );
-
-
- return NULL;
-}
+++ /dev/null
-#include <crtdll/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;
-}
#include <windows.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdlib.h>
#undef _cpumode
unsigned char _cpumode = 0;
unsigned char *_cpumode_dll = &_cpumode;
+WINBOOL STDCALL Beep(DWORD dwFreq, DWORD dwDuration);
+VOID STDCALL Sleep(DWORD dwMilliseconds);
+UINT STDCALL SetErrorMode(UINT uMode);
+
void _seterrormode(int nMode)
{
SetErrorMode(nMode);
#include <windows.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
-int
-putenv(const char *val)
+int putenv(const char *val)
{
char buffer[1024];
return SetEnvironmentVariableA(buffer,epos+1);
}
-
-
-
-
-
-
* 03/04/99: Created
*/
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/crttypes.h>
unsigned int _rotl( unsigned int value, int shift )
{
-#include <crtdll/stdlib.h>
#include <windows.h>
-#include <crtdll/string.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
void _searchenv(const char *file,const char *var,char *path )
{
char *env = getenv(var);
-
char *x;
char *y;
char *FilePart;
+
+ DPRINT("_searchenv()\n");
+
x = strchr(env,'=');
if ( x != NULL ) {
*x = 0;
y = strchr(env,';');
}
return;
-
}
-#include <crtdll/stdlib.h>
-#include <crtdll/string.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext )
{
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/math.h>
-#include <crtdll/stdlib.h>
+
+#include <msvcrt/stdlib.h>
double
/* 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/internal/file.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/stdlib.h>
+
long
strtol(const char *nptr, char **endptr, int base)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdlib.h>
-#include <crtdll/ctype.h>
-//#include <crtdll/unconst.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/ctype.h>
+//#include <msvcrt/unconst.h>
static double powten[] =
{
- 1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L
+ 1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L,
+#ifdef __GNUC__
1e512L, 1e512L*1e512L, 1e2048L, 1e4096L
+#else
+ 1e256L, 1e256L, 1e256L, 1e256L
+#endif
};
long double
/* 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/internal/file.h>
-
+#include <msvcrt/ctype.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/stdlib.h>
/*
* Convert a string to an unsigned long integer.
-#include <crtdll/stdlib.h>
+#include <msvcrt/stdlib.h>
size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size)
{
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 <msvcrt/stdlib.h>
+#include <msvcrt/wchar.h>
-#include <crtdll/errno.h>
-#include <crtdll/wchar.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/wchar.h>
#ifndef EILSEQ
#define EILSEQ EINVAL
/* 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;
+typedef int mbstate_t;
+static mbstate_t mbstate_internal;
-extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */
+mbstate_t __no_r_state; /* Now defined in wcstombs.c. */
+//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */
size_t
__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps);
const wchar_t *run = *src;
if (ps == NULL)
- ps = &internal;
+ ps = &mbstate_internal;
if (dst == NULL)
/* The LEN parameter has to be ignored if we don't actually write
return written;
}
-//weak_alias (__wcsrtombs, wcsrtombs)
\ No newline at end of file
+//weak_alias (__wcsrtombs, wcsrtombs)
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
void *
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <msvcrt/string.h>
-#include <crtdll/string.h>
-
void *
memchr(const void *s, int c, size_t n)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#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;
+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;
}
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
+
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/string.h>
int
_memicmp(const void *s1, const void *s2, size_t n)
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
void * memmove(void *dest,const void *src,size_t count)
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
+
void * memset(void *src,int val,size_t count)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
-char *
-strcat(char *s, const char *append)
+
+char* strcat(char* s, const char* append)
{
- char *save = s;
+ char* save = s;
- for (; *s; ++s);
- while ((*s++ = *append++));
- return save;
+ for (; *s; ++s);
+ while ((*s++ = *append++));
+ return save;
}
/* 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 *strchr(const char *s, int c)
{
char cc = c;
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
-int
-strcmp(const char *s1, const char *s2)
+
+int strcmp(const char *s1, const char *s2)
{
while (*s1 == *s2)
{
#include <windows.h>
-#include <crtdll/string.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. */
{
return _stricmp(s1,s2);
}
+
#else
int strcoll (const char *s1,const char *s2)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-char* strcpy(char *to, const char *from);
+#include <msvcrt/string.h>
+
+#pragma function(strcpy)
char* strcpy(char *to, const char *from)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
-size_t
-strcspn(const char *s1, const char *s2)
+size_t strcspn(const char *s1, const char *s2)
{
const char *p, *spanp;
char c, sc;
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/string.h>
+#include <msvcrt/stdlib.h>
char *_strdup(const char *_s)
{
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/stdio.h>
-#include <crtdll/string.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/errno.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/errno.h>
char __syserr00[] = "No Error";
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
size_t
strlen(const char *str)
* Copyright 1997 Uwe Bonnes
*/
-#include <crtdll/string.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/string.h>
+#include <msvcrt/ctype.h>
char * _strlwr(char *x)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
char *
strncat(char *dst, const char *src, size_t n)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
int
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
char *
strncpy(char *dst, const char *src, size_t n)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/string.h>
+#include <msvcrt/ctype.h>
int _strnicmp(const char *s1, const char *s2, size_t n)
{
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
size_t
strnlen(const char *str, size_t count)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
char *
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
-//#include <crtdll/unconst.h>
+#include <msvcrt/string.h>
char *
strrchr(const char *s, int c)
-#include <crtdll/string.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/string.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/crttypes.h>
char* _strnset (char* szToFill, int szFill, size_t sizeMaxFill)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
size_t
strspn(const char *s1, const char *s2)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
char *
strspnp(const char *s1, const char *s2)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
-//#include <crtdll/unconst.h>
+#include <msvcrt/string.h>
-char *
-strstr(const char *s, const char *find)
+
+char *strstr(const char *s, const char *find)
{
char c, sc;
size_t len;
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
-char *
-strtok(char *s, const char *delim)
+char* strtok(char *s, const char *delim)
{
const char *spanp;
int c, sc;
-#include <crtdll/string.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/string.h>
+#include <msvcrt/ctype.h>
unsigned long strtoul(const char *cp,char **endp,unsigned int base)
{
*/
-#include <crtdll/string.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/string.h>
+#include <msvcrt/ctype.h>
char *_strupr(char *x)
{
#include <windows.h>
-#include <crtdll/string.h>
+#include <msvcrt/string.h>
#if 1
size_t strxfrm( char *dest, const char *src, size_t n )
{
+
+
}
#else
size_t strxfrm( char *dest, const char *src, size_t n )
{
-
int ret = LCMapStringA(LOCALE_USER_DEFAULT,LCMAP_LOWERCASE,
src, strlen(src),
dest, strlen(dest) );
-
if ( ret == 0 )
return -1;
return ret;
-/*
+/* $Id: fstat.c,v 1.11 2002/11/24 18:42:19 robd Exp $
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/sys/fstat.c
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <windows.h>
-#include <crtdll/sys/types.h>
-#include <crtdll/sys/stat.h>
-#include <crtdll/fcntl.h>
-#include <crtdll/string.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
+#include <windows.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/sys/stat.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/string.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
-int
-_fstat(int fd, struct stat *statbuf)
+int _fstat(int fd, struct stat* statbuf)
{
-
BY_HANDLE_FILE_INFORMATION FileInformation;
if (!statbuf)
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <crtdll/sys/timeb.h>
-#include <crtdll/time.h>
-#include <crtdll/errno.h>
-#include <crtdll/stdlib.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/sys/timeb.h>
+#include <msvcrt/time.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
+
+
// crtdll has void return type instead of int
-void
-_ftime (timebuf)
- struct timeb *timebuf;
+void _ftime(struct timeb* timebuf)
{
int save = errno;
struct tm *tp;
__set_errno (save);
return;
}
-
#include <windows.h>
-#include <crtdll/sys/types.h>
-#include <crtdll/sys/stat.h>
-#include <crtdll/fcntl.h>
-#include <crtdll/io.h>
-#include <crtdll/errno.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/sys/stat.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
int _stat( const char *path, struct stat *buffer )
{
- WIN32_FIND_DATA wfd;
- HANDLE fh;
+ HANDLE fh;
+ WIN32_FIND_DATA wfd;
+
fh = FindFirstFile (path,&wfd);
if ( fh == INVALID_HANDLE_VALUE )
{
-#include <crtdll/tchar.h>
+#include <msvcrt/tchar.h>
char * _strdec(const char *str1, const char *str2)
{
-#include <crtdll/tchar.h>
+#include <msvcrt/tchar.h>
char * _strinc(const char *str)
{
-#include <crtdll/tchar.h>
-#include <crtdll/sys/types.h>
-#include <crtdll/string.h>
+#include <msvcrt/tchar.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/string.h>
size_t _strncnt( const char *str, size_t max)
{
-#include <crtdll/tchar.h>
+#include <msvcrt/tchar.h>
int _strnextc(const char *str)
{
-#include <crtdll/tchar.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/tchar.h>
+#include <msvcrt/stdlib.h>
char * _strninc(const char *str, size_t inc)
{
-#include <crtdll/tchar.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/tchar.h>
+#include <msvcrt/stdlib.h>
char * _strspnp( const char * str1, const char * str2)
*/
#include <windows.h>
-#include <crtdll/time.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/time.h>
+#include <msvcrt/internal/file.h>
VOID STDCALL GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime );
** (guy@auspex.com).
*/
-
-
-
-#include <crtdll/fcntl.h>
-#include <crtdll/time.h>
-#include <crtdll/string.h>
-#include <crtdll/ctype.h>
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/time.h>
+#include <msvcrt/string.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
#include <windows.h>
#include "tzfile.h"
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
#include "posixrul.h"
+#ifdef __cplusplus
+#define CPP_CONST const
+#else
+#define CPP_CONST
+#endif
+
#define P(s) s
#define alloc_size_t size_t
#define qsort_size_t size_t
** manual page of what this "time zone abbreviation" means (doing this so
** that tzname[0] has the "normal" length of three characters).
*/
+
+#ifdef _MSVCRT_LIB_
+int _daylight;
+int _timezone;
+#else
int _daylight_dll;
int _timezone_dll;
+#endif /*_MSVCRT_LIB_*/
+
static char WILDABBR[] = " ";
/*
** Prototypes for static functions.
*/
-
+#if 0
static long detzcode P((const char * codep));
static const char * getzname P((const char * strp));
-static const char * getnum P((const char * strp, int * nump, int min,
- int max));
+static const char * getnum P((const char * strp, int * nump, int min, int max));
static const char * getsecs P((const char * strp, long * secsp));
static const char * getoffset P((const char * strp, long * offsetp));
static const char * getrule P((const char * strp, struct rule * rulep));
static void gmtload P((struct state * sp));
-static void gmtsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static void localsub P((const time_t * timep, long offset,
- struct tm * tmp));
+static void gmtsub P((const time_t * timep, long offset, struct tm * tmp));
+static void localsub P((const time_t * timep, long offset, struct tm * tmp));
static void normalize P((int * tensptr, int * unitsptr, int base));
static void settzname P((void));
-static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * const, const long, struct tm * const),
- long offset));
-static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * const, const long, struct tm * const),
- long offset, int * okayp));
-static void timesub P((const time_t * timep, long offset,
- const struct state * sp, struct tm * tmp));
-static int tmcomp P((const struct tm * atmp,
- const struct tm * btmp));
-static time_t transtime P((time_t janfirst, int year,
- const struct rule * rulep, long offset));
+static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset));
+static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset, int * okayp));
+static void timesub P((const time_t * timep, long offset, const struct state * sp, struct tm * tmp));
+static int tmcomp P((const struct tm * atmp, const struct tm * btmp));
+static time_t transtime P((time_t janfirst, int year, const struct rule * rulep, long offset));
static int tzload P((const char * name, struct state * sp));
-static int tzparse P((const char * name, struct state * sp,
- int lastditch));
+static int tzparse P((const char * name, struct state * sp, int lastditch));
static void tzsetwall(void);
+#else
+
+static const char * getnum(const char * strp, int * CPP_CONST nump, const int min, const int max);
+static void timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp);
+static time_t transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset);
+static void tzsetwall(void);
+
+#endif
+
#ifdef ALL_STATE
static struct state *lclptr;
static struct state *gmtptr;
};
static long
-detzcode(const char * const codep)
+detzcode(const char * CPP_CONST codep)
{
long result;
int i;
static void
settzname(void)
{
- const struct state * const sp = lclptr;
+ const struct state * CPP_CONST sp = lclptr;
int i;
_tzname[0] = WILDABBR;
#endif /* defined ALL_STATE */
for (i = 0; i < sp->typecnt; ++i)
{
- register const struct ttinfo * const ttisp = &sp->ttis[i];
+ register const struct ttinfo * CPP_CONST ttisp = &sp->ttis[i];
_tzname[ttisp->tt_isdst] =
(char *)&sp->chars[ttisp->tt_abbrind];
*/
for (i = 0; i < sp->timecnt; ++i)
{
- const struct ttinfo * const ttisp = &sp->ttis[sp->types[i]];
+ const struct ttinfo * CPP_CONST ttisp = &sp->ttis[sp->types[i]];
_tzname[ttisp->tt_isdst] = (char *)&sp->chars[ttisp->tt_abbrind];
}
}
static int
-tzload(const char *name, struct state * const sp)
+tzload(const char *name, struct state * CPP_CONST sp)
{
const char * p;
int i;
*/
static const char *
-getnum(const char *strp, int * const nump, const int min, const int max)
+getnum(const char *strp, int * CPP_CONST nump, const int min, const int max)
{
char c;
int num;
*/
static const char *
-getsecs(const char *strp, long * const secsp)
+getsecs(const char *strp, long * CPP_CONST secsp)
{
int num;
*/
static const char *
-getoffset(const char *strp, long * const offsetp)
+getoffset(const char *strp, long * CPP_CONST offsetp)
{
int neg;
*/
static const char *
-getrule(const char *strp, struct rule * const rulep)
+getrule(const char *strp, struct rule * CPP_CONST rulep)
{
if (*strp == 'J')
{
*/
static time_t
-transtime(const time_t janfirst, const int year, const struct rule * const rulep, const long offset)
+transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset)
{
int leapyear;
time_t value=0;
*/
static int
-tzparse(const char *name, struct state * const sp, const int lastditch)
+tzparse(const char *name, struct state * CPP_CONST sp, const int lastditch)
{
const char * stdname;
const char * dstname=0;
}
static void
-gmtload(struct state * const sp)
+gmtload(struct state * CPP_CONST sp)
{
if (tzload(GMT, sp) != 0)
(void) tzparse(GMT, sp, TRUE);
/*ARGSUSED*/
static void
-localsub(const time_t * const timep, const long offset, struct tm * const tmp)
+localsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp)
{
const struct state * sp;
const struct ttinfo * ttisp;
}
struct tm *
-localtime(const time_t * const timep)
+localtime(const time_t * CPP_CONST timep)
{
static struct tm tm;
*/
static void
-gmtsub(const time_t * const timep, const long offset, struct tm * const tmp)
+gmtsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp)
{
if (!gmt_is_set)
{
}
struct tm *
-gmtime(const time_t * const timep)
+gmtime(const time_t * CPP_CONST timep)
{
static struct tm tm;
}
static void
-timesub(const time_t * const timep, const long offset, const struct state * const sp, struct tm * const tmp)
+timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp)
{
const struct lsinfo * lp;
long days;
}
char *
-ctime(const time_t * const timep)
+ctime(const time_t * CPP_CONST timep)
{
return asctime(localtime(timep));
}
#endif /* !defined WRONG */
static void
-normalize(int * const tensptr, int * const unitsptr, const int base)
+normalize(int * CPP_CONST tensptr, int * CPP_CONST unitsptr, const int base)
{
if (*unitsptr >= base)
{
}
static int
-tmcomp(const struct tm * const atmp, const struct tm * const btmp)
+tmcomp(const struct tm * CPP_CONST atmp, const struct tm * CPP_CONST btmp)
{
int result;
}
static time_t
-time2(struct tm *tmp, void (*const funcp)(const time_t *const,const long,struct tm *), const long offset, int * const okayp)
+time2(struct tm *tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset, int * CPP_CONST okayp)
{
const struct state * sp;
int dir;
** If time_t is signed, then 0 is the median value,
** if time_t is unsigned, then 1 << bits is median.
*/
+#ifdef _MSVCRT_LIB_
+ t = (time_t) ((1 << bits) - 1);
+#else // TODO: FIXME: review which is correct
t = (time_t) 1 << bits;
+#endif /*_MSVCRT_LIB_*/
+
for ( ; ; )
{
(*funcp)(&t, offset, &mytm);
}
static time_t
-time1(struct tm * const tmp, void (*const funcp)(const time_t * const, const long, struct tm *), const long offset)
+time1(struct tm * CPP_CONST tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset)
{
time_t t;
const struct state * sp;
{
return time1(tmp, localsub, 0L);
}
-
-
-
-
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/time.h>
+#include <msvcrt/time.h>
double
difftime(time_t time1, time_t time0)
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/time.h>
-#include <crtdll/stdio.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/time.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
char *_strdate( const char *datestr )
{
-
time_t t;
struct tm *d;
char *dt = (char *)datestr;
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <crtdll/time.h>
-#include <crtdll/stdio.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/time.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
char *_strtime(char* buf)
{
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/crtdll/conio/time.c
+ * FILE: lib/crtdll/time/time.c
* PURPOSE: Get system time
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
*/
#include <windows.h>
-#include <crtdll/time.h>
-#include <crtdll/internal/file.h>
+#include <msvcrt/time.h>
+#include <msvcrt/internal/file.h>
VOID STDCALL GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime );
{
FILETIME SystemTime;
DWORD Remainder;
+ time_t tt;
GetSystemTimeAsFileTime(&SystemTime);
- return FileTimeToUnixTime( &SystemTime,&Remainder );
+ tt = FileTimeToUnixTime( &SystemTime,&Remainder );
+ if (t)
+ *t = tt;
+ return tt;
}
/***********************************************************************
+++ /dev/null
-*.d
-*.o
-*.sym
+++ /dev/null
-
-
-#include <crtdll/wchar.h>
-
-wchar_t * wcscat(wchar_t * dest,const wchar_t * src)
-{
-
- wchar_t *d = dest;
- for (; *dest !=0; dest++);
- while (*src != 0)
- {
- *dest = *src;
- dest++;
- src++;
- }
- *dest = 0;
- return d;
-}
-
+++ /dev/null
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-
-#include <crtdll/wchar.h>
-
-wchar_t* wcschr(const wchar_t* str, wchar_t ch)
-{
- while ((*str)!=0)
- {
- if ((*str)==ch)
- {
- return((wchar_t *)str);
- }
- str++;
- }
- return(NULL);
-}
+++ /dev/null
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-
-#include <crtdll/wchar.h>
-
-int wcscmp(const wchar_t* cs,const wchar_t * ct)
-{
- while (*cs == *ct)
- {
- if (*cs == 0)
- return 0;
- cs++;
- ct++;
- }
- return *cs - *ct;
-
-}
-
-#include <crtdll/wchar.h>
+#include <msvcrt/string.h>
int wcscoll(const wchar_t *a1,const wchar_t *a2)
{
+++ /dev/null
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-
-#include <crtdll/wchar.h>
-
-wchar_t * wcscpy(wchar_t * str1,const wchar_t * str2)
-{
- wchar_t *save = str1;
-
- for (; (*str1 = *str2); ++str2, ++str1);
- return save;
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-size_t wcscspn(const wchar_t *str,const wchar_t *reject)
-{
- wchar_t *s;
- wchar_t *t;
- s=(wchar_t *)str;
- do {
- t=(wchar_t *)reject;
- while (*t) {
- if (*t==*s)
- break;
- t++;
- }
- if (*t)
- break;
- s++;
- } while (*s);
- return s-str; /* nr of wchars */
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-#include <crtdll/errno.h>
-#include <crtdll/internal/file.h>
-
-
-wchar_t *_wcsdup(const wchar_t *ptr)
-{
- wchar_t *dup;
- dup = malloc((wcslen(ptr) + 1)*sizeof(wchar_t));
- if( dup == NULL ) {
- __set_errno(ENOMEM);
- return NULL;
- }
- wcscpy(dup,ptr);
- return dup;
-}
-
-
-
+++ /dev/null
-#include <crtdll/wchar.h>
-
-size_t wcsftime(wchar_t *str, size_t len, const wchar_t *fmt, const struct tm *tp )
-{
- return 0;
-}
\ No newline at end of file
+++ /dev/null
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-
-#include <crtdll/wchar.h>
-
-int _wcsicmp(const wchar_t* cs,const wchar_t * ct)
-{
- while (towlower(*cs) == towlower(*ct))
- {
- if (*cs == 0)
- return 0;
- cs++;
- ct++;
- }
- return towlower(*cs) - towlower(*ct);
-
-}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/wchar.h>
+#include <msvcrt/string.h>
size_t wcslen(const wchar_t * s)
{
return wcslen(s);
}
-
-
-
-
+++ /dev/null
-/*
- * 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 <crtdll/wchar.h>
-
-wchar_t * _wcslwr(wchar_t *x)
-{
- wchar_t *y=x;
-
- while (*y) {
- *y=towlower(*y);
- y++;
- }
- return x;
-}
+++ /dev/null
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/wchar.h>
-
-wchar_t *wcsncat(wchar_t *dst, const wchar_t *src, size_t n)
-{
- if (n != 0)
- {
- wchar_t *d = dst;
- const wchar_t *s = src;
-
- while (*d != 0)
- d++;
- do {
- if ((*d = *s++) == 0)
- break;
- d++;
- } while (--n != 0);
- *d = 0;
- }
- return dst;
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-int wcsncmp(const wchar_t * cs,const wchar_t * ct,size_t count)
-{
- while ((*cs) == (*ct) && count > 0)
- {
- if (*cs == 0)
- return 0;
- cs++;
- ct++;
- count--;
- }
- return (*cs) - (*ct);
-
-}
-
+++ /dev/null
-#include <crtdll/wchar.h>
-
-wchar_t * wcsncpy(wchar_t * dest,const wchar_t *src,size_t count)
-{
- int i;
-
- for (i=0;i<count;i++)
- {
- dest[i] = src[i];
- if (src[i] == 0)
- {
- return(dest);
- }
- }
- dest[i]=0;
- return(dest);
-}
-
-
-
-
+++ /dev/null
-#include <crtdll/wchar.h>
-
-int _wcsnicmp (const wchar_t *cs, const wchar_t *ct, size_t count)
-{
- if (count == 0)
- return 0;
- do {
- if (towupper(*cs) != towupper(*ct++))
- return towupper(*cs) - towupper(*--ct);
- if (*cs++ == 0)
- break;
- } while (--count != 0);
- return 0;
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-size_t _wcsnlen(const wchar_t * s, size_t count)
-{
-
- unsigned int len=0;
-
- while(s[len]!=0 && len < count) {
- len++;
- };
- return len;
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2)
-{
- const wchar_t *scanp;
- int c, sc;
-
- while ((c = *s1++) != 0)
- {
- for (scanp = s2; (sc = *scanp++) != 0;)
- if (sc == c) {
- return (wchar_t *)(--s1);
- }
- }
- return 0;
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-wchar_t* wcsrchr(const wchar_t* str, wchar_t ch)
-{
-
- wchar_t *sp=(wchar_t *)0;
- while (*str != 0)
- {
- if (*str == ch)
- sp = (wchar_t *)str;
- str++;
- }
- if (ch == 0)
- sp = (wchar_t *)str;
- return sp;
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-wchar_t * _wcsrev(wchar_t *s)
-{
- wchar_t *e;
- wchar_t a;
- e=s;
- while (*e)
- e++;
- while (s<e) {
- a=*s;
- *s=*e;
- *e=a;
- s++;
- e--;
- }
- return s;
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill)
-{
- wchar_t *t = wsToFill;
- int i = 0;
- while( *wsToFill != 0 && i < sizeMaxFill)
- {
- *wsToFill = wcFill;
- wsToFill++;
- i++;
-
- }
- return t;
-}
-
-wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcFill)
-{
- wchar_t *t = wsToFill;
- while( *wsToFill != 0 )
- {
- *wsToFill = wcFill;
- wsToFill++;
-
- }
- return t;
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-size_t wcsspn(const wchar_t *str,const wchar_t *accept)
-{
- wchar_t *s;
- wchar_t *t;
- s=(wchar_t *)str;
- do {
- t=(wchar_t *)accept;
- while (*t) {
- if (*t==*s)
- break;
- t++;
- }
- if (!*t)
- break;
- s++;
- } while (*s);
- return s-str; /* nr of wchars */
-}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-wchar_t *wcsstr(const wchar_t *s,const wchar_t *b)
-{
- wchar_t *x;
- wchar_t *y;
- wchar_t *c;
- x=(wchar_t *)s;
- while (*x) {
- if (*x==*b) {
- y=x;
- c=(wchar_t *)b;
- while (*y && *c && *y==*c) {
- c++;
- y++;
- }
- if (!*c)
- return x;
- }
- x++;
- }
- return NULL;
-}
-#include <crtdll/wchar.h>
+#include <msvcrt/string.h>
wchar_t *wcstok(wchar_t *s, const wchar_t *ct)
{
wchar_t *tok;
static wchar_t *last;
-
if (s == NULL && (s = last) == NULL)
return (NULL);
s++;
for (spanp = ct; (sc = *spanp) != 0;spanp++) {
if (c == sc)
- goto cont;
+ goto cont;
}
if (c == 0) { /* no non-ctiter characters */
last = NULL;
- return (NULL);
+ return (NULL);
}
tok = s - 2;
* Note that ct must have one NUL; we stop if we see that, too.
*/
for (;;) {
-
c = *s;
s+=2;
spanp = ct;
}
spanp+=2;
} while (sc != 0);
-
}
/* NOTREACHED */
}
+++ /dev/null
-#include <crtdll/wchar.h>
-
-wchar_t *_wcsupr(wchar_t *x)
-{
- wchar_t *y=x;
-
- while (*y) {
- *y=towupper(*y);
- y++;
- }
- return x;
-}
+++ /dev/null
-#include <crtdll/string.h>
-
-size_t wcsxfrm(wchar_t *dst,const wchar_t *src, size_t n)
-{
- size_t r = 0;
- int c;
-
- if (n != 0) {
- while ((c = *src++) != 0)
- {
- r++;
- if (--n == 0)
- {
- while (*src++ != 0)
- r++;
- break;
- }
- *dst++ = c;
- }
- *dst = 0;
- }
- return r;
-}
fmifs.coff
fmifs.dll
-fmifs.nostrip.dll
\ No newline at end of file
+fmifs.nostrip.dll
+*.o
+*.obj
+*.d
-# $Id: Makefile,v 1.25 2002/10/31 07:26:08 hbirr Exp $
+# $Id: Makefile,v 1.26 2002/11/24 18:42:20 robd Exp $
PATH_TO_TOP = ../..
TARGET_NAME = msvcrt
+TARGET_BASE = 0x78000000
+
TARGET_LFLAGS = -nostartfiles
-TARGET_SDKLIBS = kernel32.a ntdll.a
+TARGET_SDKLIBS = kernel32.a
+#TARGET_SDKLIBS = kernel32.a ntdll.a
TARGET_GCCLIBS = gcc
-TARGET_BASE = 0x78000000
-
-TARGET_CFLAGS = -D__MSVCRT__
+TARGET_CFLAGS = -D_MSVCRT_LIB_
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CLEAN = \
- conio/*.o ctype/*.o direct/*.o except/*.o float/*.o io/*.o \
- locale/*.o math/*.o mbstring/*.o misc/*.o process/*.o search/*.o \
- setjmp/*.o signal/*.o stdio/*.o stdlib/*.o string/*.o sys_stat/*.o \
- time/*.o wstring/*.o
+ conio/*.o \
+ ctype/*.o \
+ direct/*.o \
+ except/*.o \
+ float/*.o \
+ io/*.o \
+ locale/*.o \
+ math/*.o \
+ mbstring/*.o \
+ misc/*.o \
+ process/*.o \
+ search/*.o \
+ setjmp/*.o \
+ signal/*.o \
+ stdio/*.o \
+ stdlib/*.o \
+ string/*.o \
+ sys_stat/*.o \
+ time/*.o \
+ wstring/*.o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
-OBJECTS_CONIO = \
+CONIO_OBJECTS = \
conio/cgets.o \
conio/cprintf.o \
conio/cputs.o \
conio/putch.o \
conio/ungetch.o
-OBJECTS_CTYPE = \
+CTYPE_OBJECTS = \
+ ctype/ctype.o \
ctype/isalnum.o \
ctype/isalpha.o \
ctype/isascii.o \
ctype/iscsym.o \
ctype/isctype.o
-OBJECTS_DIRECT = \
+DIRECT_OBJECTS = \
direct/chdir.o \
direct/chdrive.o \
direct/getcwd.o \
direct/getdfree.o \
direct/getdrive.o \
direct/mkdir.o \
- direct/rmdir.o
-
-OBJECTS_EXCEPT = \
+ direct/rmdir.o \
+ direct/wchdir.o \
+ direct/wgetcwd.o \
+ direct/wgetdcwd.o \
+ direct/wmkdir.o \
+ direct/wrmdir.o
+
+EXCEPT_OBJECTS = \
except/seh.o \
except/abnorter.o \
except/exhand2.o \
except/unwind.o \
except/xcptfil.o
-OBJECTS_FLOAT = \
+FLOAT_OBJECTS = \
float/chgsign.o \
float/clearfp.o \
float/cntrlfp.o \
float/scalb.o \
float/statfp.o
-OBJECTS_IO = \
+IO_OBJECTS = \
io/access.o \
io/chmod.o \
io/chsize.o \
io/dup2.o \
io/eof.o \
io/filelen.o \
+ io/fileleni.o \
io/find.o \
io/fmode.o \
io/isatty.o \
io/locking.o \
io/lseek.o \
+ io/lseeki64.o \
io/mktemp.o \
io/open.o \
io/pipe.o \
io/setmode.o \
io/sopen.o \
io/tell.o \
+ io/telli64.o \
io/umask.o \
io/unlink.o \
io/utime.o \
- io/write.o
-
-OBJECTS_LOCALE = \
+ io/waccess.o \
+ io/wchmod.o \
+ io/wcreate.o \
+ io/wfind.o \
+ io/wmktemp.o \
+ io/wopen.o \
+ io/write.o \
+ io/wunlink.o \
+ io/wutime.o
+
+LOCALE_OBJECTS = \
locale/locale.o
-OBJECTS_MATH = \
+MATH_OBJECTS = \
math/acos.o \
math/adjust.o \
math/asin.o \
math/tan.o \
math/tanh.o
-OBJECTS_MBSTRING = \
+MBSTRING_OBJECTS = \
mbstring/hanzen.o \
mbstring/ischira.o \
mbstring/iskana.o \
mbstring/mbstrlen.o \
mbstring/mbsupr.o
-OBJECTS_MISC = \
+MISC_OBJECTS = \
misc/amsg.o \
misc/assert.o \
+ misc/crtmain.o \
misc/dllmain.o \
+ misc/environ.o \
misc/getargs.o \
misc/initterm.o \
misc/purecall.o \
misc/tls.o
-OBJECTS_PROCESS = \
+PROCESS_OBJECTS = \
process/_cwait.o \
process/_system.o \
process/dll.o \
process/thread.o \
process/threadid.o
-OBJECTS_SEARCH = \
+SEARCH_OBJECTS = \
search/lfind.o \
search/lsearch.o
-OBJECTS_SETJMP = \
+SETJMP_OBJECTS = \
setjmp/setjmp.o
-OBJECTS_SIGNAL = \
+SIGNAL_OBJECTS = \
signal/signal.o
-OBJECTS_STDIO = \
+STDIO_OBJECTS = \
stdio/allocfil.o \
stdio/clearerr.o \
stdio/fclose.o \
stdio/fgetchar.o \
stdio/fgetpos.o \
stdio/fgets.o \
+ stdio/fgetws.o \
stdio/filbuf.o \
stdio/fileno.o \
stdio/flsbuf.o \
stdio/vprintf.o \
stdio/vscanf.o \
stdio/vsprintf.o \
- stdio/vsscanf.o
+ stdio/vsscanf.o \
+ stdio/wfdopen.o \
+ stdio/wrename.o \
+ stdio/wtempnam.o \
+ stdio/wtmpnam.o
-OBJECTS_STDLIB = \
+STDLIB_OBJECTS = \
stdlib/_exit.o \
stdlib/abort.o \
stdlib/abs.o \
stdlib/ldiv.o \
stdlib/makepath.o \
stdlib/malloc.o \
+ stdlib/mbstowcs.o \
+ stdlib/mbtowc.o \
stdlib/obsol.o \
stdlib/putenv.o \
stdlib/qsort.o \
stdlib/swab.o \
stdlib/wcstod.o \
stdlib/wcstol.o \
+ stdlib/wcstombs.o \
stdlib/wcstoul.o \
+ stdlib/wctomb.o \
+ stdlib/wfulpath.o \
+ stdlib/witoa.o \
+ stdlib/witow.o \
+ stdlib/wsenv.o \
+ stdlib/wsplitp.o \
+ stdlib/wmakpath.o \
stdlib/wtoi.o \
stdlib/wtoi64.o
-OBJECTS_STRING = \
+STRING_OBJECTS = \
string/memccpy.o \
string/memchr.o \
string/memcmp.o \
string/strlwr.o \
string/strncat.o \
string/strncmp.o \
+ string/strncoll.o \
string/strncpy.o \
string/strnicmp.o \
string/strnlen.o \
string/strupr.o \
string/strxfrm.o
-OBJECTS_SYS_STAT = \
+SYS_STAT_OBJECTS = \
sys_stat/fstat.o \
+ sys_stat/fstati64.o \
sys_stat/futime.o \
- sys_stat/stat.o
+ sys_stat/stat.o \
+ sys_stat/wstat.o
-OBJECTS_TIME = \
+TIME_OBJECTS = \
time/clock.o \
time/ctime.o \
time/difftime.o \
time/strdate.o \
time/strftime.o \
time/strtime.o \
- time/time.o
+ time/time.o \
+ time/wctime.o \
+ time/wstrdate.o \
+ time/wstrtime.o
+
-OBJECTS_WSTRING = \
+WSTRING_OBJECTS = \
wstring/wcscat.o \
wstring/wcschr.o \
wstring/wcscmp.o \
wstring/wcsxfrm.o
OBJECTS = \
- $(OBJECTS_CONIO) \
- $(OBJECTS_CTYPE) \
- $(OBJECTS_DIRECT) \
- $(OBJECTS_EXCEPT) \
- $(OBJECTS_FLOAT) \
- $(OBJECTS_IO) \
- $(OBJECTS_LOCALE) \
- $(OBJECTS_MATH) \
- $(OBJECTS_MBSTRING) \
- $(OBJECTS_MISC) \
- $(OBJECTS_PROCESS) \
- $(OBJECTS_SEARCH) \
- $(OBJECTS_SETJMP) \
- $(OBJECTS_SIGNAL) \
- $(OBJECTS_STDIO) \
- $(OBJECTS_STDLIB) \
- $(OBJECTS_STRING) \
- $(OBJECTS_SYS_STAT) \
- $(OBJECTS_TIME) \
- $(OBJECTS_WSTRING)
+ $(CONIO_OBJECTS) \
+ $(CTYPE_OBJECTS) \
+ $(DIRECT_OBJECTS) \
+ $(EXCEPT_OBJECTS) \
+ $(FLOAT_OBJECTS) \
+ $(IO_OBJECTS) \
+ $(LOCALE_OBJECTS) \
+ $(MATH_OBJECTS) \
+ $(MBSTRING_OBJECTS) \
+ $(MISC_OBJECTS) \
+ $(PROCESS_OBJECTS) \
+ $(SEARCH_OBJECTS) \
+ $(SETJMP_OBJECTS) \
+ $(SIGNAL_OBJECTS) \
+ $(STDIO_OBJECTS) \
+ $(STDLIB_OBJECTS) \
+ $(STRING_OBJECTS) \
+ $(SYS_STAT_OBJECTS) \
+ $(TIME_OBJECTS) \
+ $(WSTRING_OBJECTS)
$(TARGET_NAME).o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).o
#include <msvcrt/conio.h>
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
+#include <msvcrt/internal/stdio.h>
int _cscanf(char *fmt, ...)
{
- int cnt;
- va_list ap;
+ int cnt;
- //fixme cscanf should scan the console's keyboard
- va_start(ap, fmt);
- cnt = __vscanf(fmt, ap);
- va_end(ap);
-
- return cnt;
-}
+ va_list ap;
+ //fixme cscanf should scan the console's keyboard
+ va_start(ap, fmt);
+ cnt = __vscanf(fmt, ap);
+ va_end(ap);
+ return cnt;
+}
int _getch(void)
{
- DWORD NumberOfCharsRead = 0;
- char c;
-
- if (char_avail)
- {
- c = ungot_char;
- char_avail = 0;
- }
- else
- {
- ReadConsoleA(_get_osfhandle(stdin->_file),
- &c,
- 1,
- &NumberOfCharsRead,
- NULL);
+ DWORD NumberOfCharsRead = 0;
+ char c;
+ if (char_avail) {
+ c = ungot_char;
+ char_avail = 0;
+ } else {
+ ReadConsoleA(_get_osfhandle(stdin->_file),
+ &c,
+ 1,
+ &NumberOfCharsRead,
+ NULL);
}
- if (c == 10)
- c = 13;
- putchar(c);
-
- return c;
+ if (c == 10)
+ c = 13;
+ putchar(c);
+ return c;
}
#if 0
int _kbhit(void)
{
- INPUT_RECORD InputRecord;
+ //INPUT_RECORD InputRecord;
DWORD NumberRead=0;
if (char_avail)
return(1);
- else
- {
+ else {
//FIXME PeekConsoleInput might do DeviceIo
//PeekConsoleInput((HANDLE)stdin->_file,&InputRecord,1,&NumberRead);
return NumberRead;
{
DWORD NumberOfCharsWritten;
- if (WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL))
+ if (WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL)) {
return -1;
-
+ }
return NumberOfCharsWritten;
}
--- /dev/null
+/* 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 */
+};
+
+/* EOF */
{
return __isascii(c);
}
-
-
-
-
-
-
-
-
/* 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 */
-};
+
+extern unsigned short _ctype[];
unsigned short *_pctype = _ctype + 1;
unsigned short *_pwctype = _ctype + 1;
+
unsigned short **__p__pctype(void)
{
return &_pctype;
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/ctype/isspace.c
- * PURPOSE: Checks for a whitespace characters
+ * PURPOSE: Test for a space character
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
#include <msvcrt/direct.h>
-int _chdir( const char *_path )
+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;
+ if (_path[1] == ':')
+ _chdrive(tolower(_path[0] - 'a')+1);
+ if (!SetCurrentDirectoryA((char*)_path))
+ return -1;
+ return 0;
}
#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);
- }
+int _chdrive(int drive)
+{
+ char d[3];
- return 0;
+ 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;
}
#include <msvcrt/stdlib.h>
-char *_getcwd( char *buffer, int maxlen )
+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;
- }
+ char *cwd;
+ int len;
- 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;
+ if (buffer == NULL) {
+ cwd = malloc(MAX_PATH);
+ len = MAX_PATH;
+ } else {
+ cwd = buffer;
+ len = maxlen;
+ }
+ if (GetCurrentDirectoryA(len, cwd) == 0) {
+ return NULL;
+ }
+ return cwd;
}
#include <windows.h>
#include <msvcrt/direct.h>
-char* _getdcwd (int nDrive, char* caBuffer, int nBufLen)
+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;
-}
+ int i =0;
+ int dr = _getdrive();
-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;
+ 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;
}
#include <msvcrt/direct.h>
-unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace)
+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;
+ char RootPathName[10];
- 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;
+ 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;
}
extern int cur_drive;
-int _getdrive( void )
+int _getdrive(void)
{
- char Buffer[MAX_PATH];
+ char Buffer[MAX_PATH];
- if ( cur_drive == 0 ) {
- GetCurrentDirectoryA(MAX_PATH,Buffer);
- cur_drive = toupper(Buffer[0] - '@');
- }
-
- return cur_drive;
+ 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
+ return 5; // drive A and C
}
#include <msvcrt/direct.h>
-int _mkdir( const char *_path )
+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;
+ if (!CreateDirectoryA(_path, NULL))
+ return -1;
+ return 0;
}
#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 )
+int _rmdir(const char* _path)
{
- if (!RemoveDirectoryW(_path))
- return -1;
- return 0;
+ if (!RemoveDirectoryA(_path))
+ return -1;
+ return 0;
}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/direct.h>
+
+
+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;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/direct.h>
+#include <msvcrt/stdlib.h>
+
+
+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;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/direct.h>
+
+
+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;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/direct.h>
+
+
+int _wmkdir(const wchar_t* _path)
+{
+ if (!CreateDirectoryW(_path, NULL))
+ return -1;
+ return 0;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/direct.h>
+
+int _wrmdir(const wchar_t* _path)
+{
+ if (!RemoveDirectoryW(_path))
+ return -1;
+ return 0;
+}
#include <windows.h>
+
+#ifdef __GNUC__
+
int _abnormal_termination(void)
{
printf("Abnormal Termination\n");
// return AbnormalTermination();
}
+
+#else
+#endif
#include <windows.h>
+#ifdef __GNUC__
+#else
+#endif
+ULONG DbgPrint(PCH Format,...)
+{
+ return 0;
+}
+
VOID STDCALL
MsvcrtDebug(ULONG Value)
{
- DbgPrint("MsvcrtDebug 0x%.08x\n", Value);
+ //DbgPrint("MsvcrtDebug 0x%.08x\n", Value);
}
EXCEPTION_DISPOSITION
struct _CONTEXT *ContextRecord,
void *DispatcherContext)
{
- printf("_except_handler2()\n");
+ //printf("_except_handler2()\n");
+ return 0;
}
return 0;
}
+// not exported by NTDLL
void __setusermatherr(int (* handler)(struct _exception *))
{
#define _FPIEEE_RECORD void
int _fpieee_flt(
- unsigned long exception_code,
+ unsigned long exception_code,
struct _EXCEPTION_POINTERS *ExceptionPointer,
int (* handler)(_FPIEEE_RECORD *)
)
{
- return 0;
+ return 0;
}
void __cdecl
_global_unwind2(PEXCEPTION_REGISTRATION RegistrationFrame)
{
+#ifdef __GNUC__
RtlUnwind(RegistrationFrame, &&__ret_label, NULL, 0);
__ret_label:
// return is important
return;
+#else
+#endif
}
unsigned int _clearfp (void)
{
unsigned short __res = _statusfp();
-
+#ifdef __GNUC__
__asm__ __volatile__ (
"fclex \n\t"
);
-
+#else
+#endif /*__GNUC__*/
return __res;
}
unsigned int _control87(unsigned int unNew, unsigned int unMask)
{
register unsigned int __res;
-
+#ifdef __GNUC__
__asm__ __volatile__ (
"pushl %%eax \n\t" /* make room on stack */
"fstcw (%%esp) \n\t"
"popl %%edx \n\t"
:"=r" (__res):"r" (unNew),"r" (unMask): "ax", "dx", "cx");
-
+#else
+#endif /*__GNUC__*/
return __res;
}
double _logb (double __x)
{
- register double __value, __junk;
+ register double __value;
+#ifdef __GNUC__
+ register double __junk;
__asm __volatile__
("fxtract\n\t"
: "=t" (__junk), "=u" (__value) : "0" (__x));
-
+#else
+#endif /*__GNUC__*/
return __value;
}
{
register unsigned short __res;
-
+#ifdef __GNUC__
__asm__ __volatile__ (
"fstsw %0 \n\t"
// "movzwl %ax, %eax"
:"=a" (__res)
);
+#else
+#endif /*__GNUC__*/
return __res;
}
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
-#ifndef F_OK
- #define F_OK 0x01
-#endif
-#ifndef R_OK
- #define R_OK 0x02
-#endif
-#ifndef W_OK
- #define W_OK 0x04
-#endif
-#ifndef X_OK
- #define X_OK 0x08
-#endif
-#ifndef D_OK
- #define D_OK 0x10
-#endif
int _access( const char *_path, int _amode )
{
- DWORD Attributes = GetFileAttributesA(_path);
- DPRINT("_access('%s', %x)\n", _path, _amode);
-
- if ( Attributes == -1 ) {
- __set_errno(ENOENT);
- return -1;
- }
-
- if ( (_amode & W_OK) == W_OK ) {
- if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY ) {
- __set_errno(EACCES);
- return -1;
- }
- }
- if ( (_amode & D_OK) == D_OK ) {
- if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) {
- __set_errno(EACCES);
- return -1;
- }
- }
-
- return 0;
-}
-
-int _waccess( const wchar_t *_path, int _amode )
-{
- DWORD Attributes = GetFileAttributesW(_path);
-
- if ( Attributes == -1 ) {
- __set_errno(ENOENT);
- return -1;
- }
-
- if ( (_amode & W_OK) == W_OK ) {
- if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY ) {
- __set_errno(EACCES);
- return -1;
- }
- }
- if ( (_amode & D_OK) == D_OK ) {
- if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) {
- __set_errno(EACCES);
- return -1;
- }
- }
-
- return 0;
+ DWORD Attributes = GetFileAttributesA(_path);
+ DPRINT("_access('%s', %x)\n", _path, _amode);
+
+ if (Attributes == -1) {
+ __set_errno(ENOENT);
+ return -1;
+ }
+ if ((_amode & W_OK) == W_OK) {
+ if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) {
+ __set_errno(EACCES);
+ return -1;
+ }
+ }
+ if ((_amode & D_OK) == D_OK) {
+ if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
+ __set_errno(EACCES);
+ return -1;
+ }
+ }
+ return 0;
}
#define mode_t int
-int _chmod(const char *filename, mode_t mode)
-{
- DWORD FileAttributes = 0;
- DPRINT("_chmod('%s', %x)\n", filename, mode);
-
- FileAttributes = GetFileAttributesA(filename);
- if ( FileAttributes == -1 )
- return -1;
-
- if ( mode == 0 )
- return -1;
-
- if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
- FileAttributes &= FILE_ATTRIBUTE_READONLY;
- else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE))
- FileAttributes &= FILE_ATTRIBUTE_NORMAL;
- else
- FileAttributes &= FILE_ATTRIBUTE_NORMAL;
-
- if (SetFileAttributesA(filename, FileAttributes) == FALSE)
- return -1;
-
- return 1;
-}
-int _wchmod(const wchar_t *filename, mode_t mode)
+int _chmod(const char* filename, mode_t mode)
{
- DWORD FileAttributes = 0;
- DPRINT("_wchmod('%S', %x)\n", filename, mode);
+ DWORD FileAttributes = 0;
+ DPRINT("_chmod('%s', %x)\n", filename, mode);
- FileAttributes = GetFileAttributesW(filename);
- if ( FileAttributes == -1 )
- return -1;
+ FileAttributes = GetFileAttributesA(filename);
+ if ( FileAttributes == -1 )
+ return -1;
- if ( mode == 0 )
- return -1;
+ if ( mode == 0 )
+ return -1;
- if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
- FileAttributes &= FILE_ATTRIBUTE_READONLY;
- else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE))
- FileAttributes &= FILE_ATTRIBUTE_NORMAL;
- else
- FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+ if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
+ FileAttributes &= FILE_ATTRIBUTE_READONLY;
+ else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE))
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+ else
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
- if (SetFileAttributesW(filename, FileAttributes) == FALSE)
- return -1;
+ if (SetFileAttributesA(filename, FileAttributes) == FALSE)
+ return -1;
- return 1;
+ return 1;
}
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
-int _commode = _IOCOMMIT;
-
-
-int *__p__commode(void)
-{
- return &_commode;
-}
int _commit(int _fd)
{
- if (! FlushFileBuffers(_get_osfhandle(_fd)) )
- {
+ if (! FlushFileBuffers(_get_osfhandle(_fd)) ) {
__set_errno(EBADF);
return -1;
}
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
-int _creat(const char *filename, int mode)
-{
- DPRINT("_creat('%s', mode %x)\n", filename, mode);
- return _open(filename,_O_CREAT|_O_TRUNC,mode);
-}
-int _wcreat(const wchar_t *filename, int mode)
+int _creat(const char* filename, int mode)
{
- DPRINT("_wcreat('%S', mode %x)\n", filename, mode);
- return _wopen(filename,_O_CREAT|_O_TRUNC,mode);
+ DPRINT("_creat('%s', mode %x)\n", filename, mode);
+ return _open(filename,_O_CREAT|_O_TRUNC,mode);
}
#include <windows.h>
#include <msvcrt/io.h>
-long _filelength(int _fd)
-{
- return GetFileSize(_get_osfhandle(_fd),NULL);
-}
-__int64 _filelengthi64(int _fd)
+long _filelength(int _fd)
{
- long lo_length, hi_length;
-
- lo_length = GetFileSize(_get_osfhandle(_fd), &hi_length);
-
- return((((__int64)hi_length) << 32) + lo_length);
+ return GetFileSize(_get_osfhandle(_fd), NULL);
}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+
+
+__int64 _filelengthi64(int _fd)
+{
+ long lo_length, hi_length;
+
+ lo_length = GetFileSize(_get_osfhandle(_fd), &hi_length);
+ return((((__int64)hi_length) << 32) + lo_length);
+}
int _findclose(int handle)
{
- // check no wildcards or invalid handle
- if (handle == 0 || handle == -1)
- return 0;
- return FindClose((void *)handle);
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+ return FindClose((void*)handle);
}
-int _findfirst(const char *_name, struct _finddata_t *result)
+int _findfirst(const char* _name, struct _finddata_t* result)
{
- WIN32_FIND_DATAA FindFileData;
- char dir[MAX_PATH];
- long hFindFile;
- int len = 0;
-
- if ( _name == NULL || _name[0] == 0 )
- {
- len = GetCurrentDirectoryA(MAX_PATH-4,dir);
- if (dir[len-1] != '\\')
- {
- dir[len] = '\\';
- dir[len+1] = 0;
- }
- strcat(dir,"*.*");
+ WIN32_FIND_DATAA FindFileData;
+ char dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
+
+ if (_name == NULL || _name[0] == 0) {
+ len = GetCurrentDirectoryA(MAX_PATH-4,dir);
+ if (dir[len-1] != '\\') {
+ dir[len] = '\\';
+ dir[len+1] = 0;
+ }
+ strcat(dir,"*.*");
+ } else {
+ strcpy(dir,_name);
}
- else
- strcpy(dir,_name);
- hFindFile = (long)FindFirstFileA( dir, &FindFileData );
- if (hFindFile == -1)
- {
- memset(result,0,sizeof(struct _finddata_t));
- return -1;
+ hFindFile = (long)FindFirstFileA(dir, &FindFileData);
+ if (hFindFile == -1) {
+ memset(result,0,sizeof(struct _finddata_t));
+ return -1;
}
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
- result->size = FindFileData.nFileSizeLow;
- strncpy(result->name,FindFileData.cFileName,MAX_PATH);
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ strncpy(result->name,FindFileData.cFileName,MAX_PATH);
- // if no wildcard the find file handle can be closed right away
- // a return value of 0 can flag this.
+ // if no wildcard the find file handle can be closed right away
+ // a return value of 0 can flag this.
- if (!strchr(dir,'*') && !strchr(dir,'?'))
- {
- _findclose(hFindFile);
- return 0;
+ if (!strchr(dir,'*') && !strchr(dir,'?')) {
+ _findclose(hFindFile);
+ return 0;
}
- return hFindFile;
+ return hFindFile;
}
-int _findfirsti64(const char *_name, struct _finddatai64_t *result)
+int _findnext(int handle, struct _finddata_t* result)
{
- WIN32_FIND_DATAA FindFileData;
- char dir[MAX_PATH];
- long hFindFile;
- int len = 0;
-
- if ( _name == NULL || _name[0] == 0 )
- {
- len = GetCurrentDirectoryA(MAX_PATH-4,dir);
- if (dir[len-1] != '\\')
- {
- dir[len] = '\\';
- dir[len+1] = 0;
- }
- strcat(dir, "*.*");
- }
- else
- strcpy(dir, _name);
-
- hFindFile = (long)FindFirstFileA(dir, &FindFileData);
- if (hFindFile == -1)
- {
- memset(result,0,sizeof(struct _finddatai64_t));
- return -1;
- }
-
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
- result->size =
- (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
- strncpy(result->name,FindFileData.cFileName,MAX_PATH);
-
- // if no wildcard the find file handle can be closed right away
- // a return value of 0 can flag this.
+ WIN32_FIND_DATAA FindFileData;
- if (!strchr(dir,'*') && !strchr(dir,'?'))
- {
- _findclose(hFindFile);
- return 0;
- }
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
- return hFindFile;
-}
+ if (!FindNextFileA((void*)handle, &FindFileData))
+ return -1;
-int _findnext(int handle, struct _finddata_t *result)
-{
- WIN32_FIND_DATAA FindFileData;
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ strncpy(result->name,FindFileData.cFileName, MAX_PATH);
- // check no wildcards or invalid handle
- if (handle == 0 || handle == -1)
return 0;
-
- if (!FindNextFileA((void *)handle, &FindFileData))
- return -1;
-
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
- result->size = FindFileData.nFileSizeLow;
- strncpy(result->name,FindFileData.cFileName, MAX_PATH);
-
- return 0;
}
-int _findnexti64(int handle, struct _finddatai64_t *result)
-{
- WIN32_FIND_DATAA FindFileData;
-
- // check no wildcards or invalid handle
- if (handle == 0 || handle == -1)
- return 0;
-
- if (!FindNextFileA((void *)handle, &FindFileData))
- return -1;
-
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
- result->size =
- (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
- strncpy(result->name,FindFileData.cFileName,MAX_PATH);
-
- return 0;
-}
-
-int _wfindfirst(const wchar_t *_name, struct _wfinddata_t *result)
-{
- WIN32_FIND_DATAW FindFileData;
- wchar_t dir[MAX_PATH];
- long hFindFile;
- int len = 0;
-
- if ( _name == NULL || _name[0] == 0 )
- {
- len = GetCurrentDirectoryW(MAX_PATH-4, dir);
- if (dir[len-1] != L'\\')
- {
- dir[len] = L'\\';
- dir[len+1] = 0;
- }
- wcscat(dir, L"*.*");
- }
- else
- wcscpy(dir, _name);
-
- hFindFile = (long)FindFirstFileW(dir, &FindFileData);
- if (hFindFile == -1)
- {
- memset(result,0,sizeof(struct _wfinddata_t));
- return -1;
- }
-
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
- result->size = FindFileData.nFileSizeLow;
- wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
-
- // if no wildcard the find file handle can be closed right away
- // a return value of 0 can flag this.
-
- if (!wcschr(dir, L'*') && !wcschr(dir, L'?'))
- {
- _findclose(hFindFile);
- return 0;
- }
-
- return hFindFile;
-}
-
-int _wfindfirsti64(const wchar_t *_name, struct _wfinddatai64_t *result)
-{
- WIN32_FIND_DATAW FindFileData;
- wchar_t dir[MAX_PATH];
- long hFindFile;
- int len = 0;
-
- if (_name == NULL || _name[0] == 0)
- {
- len = GetCurrentDirectoryW(MAX_PATH-4,dir);
- if (dir[len-1] != L'\\')
- {
- dir[len] = L'\\';
- dir[len+1] = 0;
- }
- wcscat(dir, L"*.*");
- }
- else
- wcscpy(dir, _name);
-
- hFindFile = (long)FindFirstFileW(dir, &FindFileData);
- if (hFindFile == -1)
- {
- memset(result,0,sizeof(struct _wfinddatai64_t));
- return -1;
- }
-
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
- result->size =
- (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
- wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
-
- // if no wildcard the find file handle can be closed right away
- // a return value of 0 can flag this.
-
- if (!wcschr(dir,L'*') && !wcschr(dir,L'?'))
- {
- _findclose(hFindFile);
- return 0;
- }
-
- return hFindFile;
-}
-
-int _wfindnext(int handle, struct _wfinddata_t *result)
-{
- WIN32_FIND_DATAW FindFileData;
-
- // check no wildcards or invalid handle
- if (handle == 0 || handle == -1)
- return 0;
-
- if (!FindNextFileW((void *)handle, &FindFileData))
- return -1;
-
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
- result->size = FindFileData.nFileSizeLow;
- wcsncpy(result->name,FindFileData.cFileName, MAX_PATH);
-
- return 0;
-}
-
-int _wfindnexti64(int handle, struct _wfinddatai64_t *result)
-{
- WIN32_FIND_DATAW FindFileData;
-
- // check no wildcards or invalid handle
- if (handle == 0 || handle == -1)
- return 0;
-
- if (!FindNextFileW((void *)handle, &FindFileData))
- return -1;
-
- result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
- result->size =
- (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
- wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
-
- return 0;
-}
long _lseek(int _fildes, long _offset, int _whence)
{
- return (SetFilePointer((HANDLE)filehnd(_fildes), _offset, NULL, _whence));
-}
-
-__int64 _lseeki64(int _fildes, __int64 _offset, int _whence)
-{
- ULONG lo_pos, hi_pos;
-
- lo_pos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, &hi_pos, _whence);
- return((((__int64)hi_pos) << 32) + lo_pos);
+ return (SetFilePointer((HANDLE)filehnd(_fildes), _offset, NULL, _whence));
}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
+
+
+BOOL STDCALL SetFilePointerEx(
+ HANDLE hFile, // handle to file
+ LARGE_INTEGER liDistanceToMove, // bytes to move pointer
+ PLARGE_INTEGER lpNewFilePointer, // new file pointer
+ DWORD dwMoveMethod // starting point
+);
+
+__int64 _lseeki64(int _fildes, __int64 _offset, int _whence)
+{
+#if 0
+ __int64 new_pos;
+ LARGE_INTEGER offset = _offset;
+
+// if (invalid_filehnd(_fildes)) {
+// errno = EBADF;
+// return -1L;
+// }
+ if (SetFilePointerEx((HANDLE)filehnd(_fildes), offset, &new_pos, _whence)) {
+ } else {
+ //errno = EINVAL;
+ return -1L;
+ }
+ return new_pos;
+#else
+ ULONG lo_pos, hi_pos;
+ //DWORD lo_pos;
+
+ lo_pos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, &hi_pos, _whence);
+ return((((__int64)hi_pos) << 32) + lo_pos);
+#endif
+}
+/*
+long _lseek ( int handle, long offset, int origin );
+__int64 _lseeki64( int handle, __int64 offset, int origin );
+
+BOOL SetFilePointerEx(
+ HANDLE hFile, // handle to file
+ LARGE_INTEGER liDistanceToMove, // bytes to move pointer
+ PLARGE_INTEGER lpNewFilePointer, // new file pointer
+ DWORD dwMoveMethod // starting point
+);
+DWORD SetFilePointer(
+ HANDLE hFile, // handle to file
+ LONG lDistanceToMove, // bytes to move pointer
+ PLONG lpDistanceToMoveHigh, // bytes to move pointer
+ DWORD dwMoveMethod // starting point
+);
+ */
/*
* COPYRIGHT: See COPYING in the top level directory
- * Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/io/mktemp.c
* PURPOSE: Makes a temp file based on a template
* PROGRAMER: DJ Delorie
- Boudewijn Dekker
+ Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Appropriated for the Reactos Kernel
*/
#include <msvcrt/msvcrtdbg.h>
-char* _mktemp (char *_template)
+char* _mktemp(char* _template)
{
static int count = 0;
char *cp, *dp;
for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) {
int c = count++;
for (i = 0; i < xcount; i++, c >>= 5)
- cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];
+ cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];
if (_access(_template,0) == -1)
- return _template;
- }
- }
-
- /* Failure: truncate the template and return NULL. */
- *_template = 0;
- return 0;
-}
-
-wchar_t* _wmktemp (wchar_t *_template)
-{
- static int count = 0;
- wchar_t *cp, *dp;
- int i, len, xcount, loopcnt;
-
- DPRINT("_wmktemp('%S')\n", _template);
- len = wcslen (_template);
- cp = _template + len;
-
- xcount = 0;
- while (xcount < 6 && cp > _template && cp[-1] == L'X')
- xcount++, cp--;
-
- if (xcount) {
- dp = cp;
- while (dp > _template && dp[-1] != L'/' && dp[-1] != L'\\' && dp[-1] != L':')
- dp--;
-
- /* Keep the first characters of the template, but turn the rest into
- Xs. */
- while (cp > dp + 8 - xcount) {
- *--cp = L'X';
- xcount = (xcount >= 6) ? 6 : 1 + xcount;
- }
-
- /* If dots occur too early -- squash them. */
- while (dp < cp) {
- if (*dp == L'.') *dp = L'a';
- dp++;
- }
-
- /* Try to add ".tmp" to the filename. Truncate unused Xs. */
- if (cp + xcount + 3 < _template + len)
- wcscpy (cp + xcount, L".tmp");
- else
- cp[xcount] = 0;
-
- /* This loop can run up to 2<<(5*6) times, or about 10^9 times. */
- for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) {
- int c = count++;
- for (i = 0; i < xcount; i++, c >>= 5)
- cp[i] = L"abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];
- if (_waccess(_template,0) == -1)
- return _template;
+ return _template;
}
}
-/* $Id: open.c,v 1.11 2002/11/18 03:19:42 robd Exp $
+/* $Id: open.c,v 1.12 2002/11/24 18:42:22 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
typedef struct _fileno_modes_type
{
- HANDLE hFile;
- int mode;
- int fd;
+ HANDLE hFile;
+ int mode;
+ int fd;
} fileno_modes_type;
-fileno_modes_type *fileno_modes = NULL;
+static fileno_modes_type *fileno_modes = NULL;
int maxfno = 0;
return (!((p)->_flag&_IOSTRG) && (fileno_modes[(p)->_file].mode&O_TEXT));
}
-
-int _open(const char *_path, int _oflag,...)
+int _open(const char* _path, int _oflag,...)
{
#if !defined(NDEBUG) && defined(DBG)
va_list arg;
pmode = va_arg(arg, int);
#endif
- DPRINT("_open('%s', %x, (%x))\n", _path, _oflag, pmode);
+// DPRINT("_open('%s', %x, (%x))\n", _path, _oflag, pmode);
if (( _oflag & S_IREAD ) == S_IREAD)
dwShareMode = FILE_SHARE_READ;
dwShareMode |= FILE_SHARE_READ;
if (( _oflag & S_IWRITE ) == S_IWRITE )
- dwShareMode |= FILE_SHARE_WRITE;
+ dwShareMode |= FILE_SHARE_WRITE;
if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) )
dwCreationDistribution |= CREATE_NEW;
else if (( _oflag & O_TRUNC ) == O_TRUNC ) {
if (( _oflag & O_CREAT ) == O_CREAT )
- dwCreationDistribution |= CREATE_ALWAYS;
+ dwCreationDistribution |= CREATE_ALWAYS;
else if (( _oflag & O_RDONLY ) != O_RDONLY )
- dwCreationDistribution |= TRUNCATE_EXISTING;
+ dwCreationDistribution |= TRUNCATE_EXISTING;
}
else if (( _oflag & _O_APPEND ) == _O_APPEND )
dwCreationDistribution |= OPEN_EXISTING;
dwCreationDistribution |= OPEN_EXISTING;
if (( _oflag & _O_RANDOM ) == _O_RANDOM )
- dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
+ dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
if (( _oflag & _O_SEQUENTIAL ) == _O_SEQUENTIAL )
dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
sa.bInheritHandle = FALSE;
hFile = CreateFileA(_path,
- dwDesiredAccess,
- dwShareMode,
- &sa,
- dwCreationDistribution,
- dwFlagsAndAttributes,
- NULL);
+ dwDesiredAccess,
+ dwShareMode,
+ &sa,
+ dwCreationDistribution,
+ dwFlagsAndAttributes,
+ NULL);
if (hFile == (HANDLE)-1)
{
dwLastError = GetLastError();
if (dwLastError == ERROR_ALREADY_EXISTS)
{
- DPRINT("ERROR_ALREADY_EXISTS\n");
- __set_errno(EEXIST);
+ DPRINT("ERROR_ALREADY_EXISTS\n");
+ __set_errno(EEXIST);
}
else
{
- DPRINT("%x\n", dwLastError);
+ DPRINT("%x\n", dwLastError);
__set_errno(ENOFILE);
}
return -1;
DPRINT("OK\n");
if (!(_oflag & (_O_TEXT|_O_BINARY)))
{
- _oflag |= _fmode;
+ _oflag |= _fmode;
}
return __fileno_alloc(hFile,_oflag);
}
-int _wopen(const wchar_t *_path, int _oflag,...)
-{
-#if !defined(NDEBUG) && defined(DBG)
- va_list arg;
- int pmode;
-#endif
- HANDLE hFile;
- DWORD dwDesiredAccess = 0;
- DWORD dwShareMode = 0;
- DWORD dwCreationDistribution = 0;
- DWORD dwFlagsAndAttributes = 0;
- SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
-
-#if !defined(NDEBUG) && defined(DBG)
- va_start(arg, _oflag);
- pmode = va_arg(arg, int);
-#endif
-
- DPRINT("_wopen('%S', %x, (%x))\n", _path, _oflag, pmode);
-
- if (( _oflag & S_IREAD ) == S_IREAD)
- dwShareMode = FILE_SHARE_READ;
- else if ( ( _oflag & S_IWRITE) == S_IWRITE ) {
- dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
- }
-
- /*
- *
- * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
- * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
- *
- * _O_APPEND Moves file pointer to end of file before every write operation.
- */
- if (( _oflag & _O_RDWR ) == _O_RDWR )
- dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA |
- FILE_WRITE_DATA | FILE_READ_ATTRIBUTES |
- FILE_WRITE_ATTRIBUTES;
- else if (( _oflag & O_RDONLY ) == O_RDONLY )
- dwDesiredAccess |= GENERIC_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES
- | FILE_WRITE_ATTRIBUTES;
- else if (( _oflag & _O_WRONLY ) == _O_WRONLY )
- dwDesiredAccess |= GENERIC_WRITE | FILE_WRITE_DATA |
- FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES;
-
- if (( _oflag & S_IREAD ) == S_IREAD )
- dwShareMode |= FILE_SHARE_READ;
-
- if (( _oflag & S_IWRITE ) == S_IWRITE )
- dwShareMode |= FILE_SHARE_WRITE;
-
- if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) )
- dwCreationDistribution |= CREATE_NEW;
-
- else if (( _oflag & O_TRUNC ) == O_TRUNC ) {
- if (( _oflag & O_CREAT ) == O_CREAT )
- dwCreationDistribution |= CREATE_ALWAYS;
- else if (( _oflag & O_RDONLY ) != O_RDONLY )
- dwCreationDistribution |= TRUNCATE_EXISTING;
- }
- else if (( _oflag & _O_APPEND ) == _O_APPEND )
- dwCreationDistribution |= OPEN_EXISTING;
- else if (( _oflag & _O_CREAT ) == _O_CREAT )
- dwCreationDistribution |= OPEN_ALWAYS;
- else
- dwCreationDistribution |= OPEN_EXISTING;
-
- if (( _oflag & _O_RANDOM ) == _O_RANDOM )
- dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
- if (( _oflag & _O_SEQUENTIAL ) == _O_SEQUENTIAL )
- dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
-
- if (( _oflag & _O_TEMPORARY ) == _O_TEMPORARY )
- dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
-
- if (( _oflag & _O_SHORT_LIVED ) == _O_SHORT_LIVED )
- dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
-
- if (_oflag & _O_NOINHERIT)
- sa.bInheritHandle = FALSE;
-
- hFile = CreateFileW(_path,
- dwDesiredAccess,
- dwShareMode,
- &sa,
- dwCreationDistribution,
- dwFlagsAndAttributes,
- NULL);
- if (hFile == (HANDLE)-1)
- return -1;
- return __fileno_alloc(hFile,_oflag);
-}
-
-
int
__fileno_alloc(HANDLE hFile, int mode)
{
int i;
/* Check for bogus values */
if (hFile < 0)
- return -1;
+ return -1;
for(i=5;i<maxfno;i++) {
- if (fileno_modes[i].fd == -1 ) {
- fileno_modes[i].fd = i;
- fileno_modes[i].mode = mode;
- fileno_modes[i].hFile = hFile;
- return i;
- }
+ if (fileno_modes[i].fd == -1 ) {
+ fileno_modes[i].fd = i;
+ fileno_modes[i].mode = mode;
+ fileno_modes[i].hFile = hFile;
+ return i;
+ }
}
/* See if we need to expand the tables. Check this BEFORE it might fail,
{
int oldcount = maxfno;
fileno_modes_type *old_fileno_modes = fileno_modes;
- maxfno += 255;
+ maxfno += 255;
fileno_modes = (fileno_modes_type *)malloc(maxfno * sizeof(fileno_modes_type));
if ( old_fileno_modes != NULL )
{
- memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type));
+ memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type));
free ( old_fileno_modes );
}
memset(fileno_modes + oldcount, -1, (maxfno-oldcount)*sizeof(fileno_modes_type));
void *filehnd(int fileno)
{
- if ( fileno < 0 || fileno>= maxfno || fileno_modes[fileno].fd == -1)
- {
- return (void *)-1;
- }
- return fileno_modes[fileno].hFile;
+ if ( fileno < 0 || fileno>= maxfno || fileno_modes[fileno].fd == -1)
+ {
+ return (void *)-1;
+ }
+ return fileno_modes[fileno].hFile;
+}
+
+int __fileno_setmode(int _fd, int _newmode)
+{
+ int m;
+ if ( _fd < 0 || _fd >= maxfno )
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+
+ m = fileno_modes[_fd].mode;
+ fileno_modes[_fd].mode = _newmode;
+ return m;
+}
+
+int __fileno_getmode(int _fd)
+{
+ if ( _fd < 0 || _fd >= maxfno )
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+ return fileno_modes[_fd].mode;
+
+}
+
+int __fileno_close(int _fd)
+{
+ if ( _fd < 0 || _fd >= maxfno )
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+
+ fileno_modes[_fd].fd = -1;
+ fileno_modes[_fd].hFile = (HANDLE)-1;
+ return 0;
+}
+
+int _open_osfhandle (void *osfhandle, int flags )
+{
+ return __fileno_alloc((HANDLE)osfhandle, flags);
+}
+
+void *_get_osfhandle( int fileno )
+{
+ return filehnd(fileno);
}
int __fileno_dup2( int handle1, int handle2 )
}
hProcess = GetCurrentProcess();
result = DuplicateHandle(hProcess,
- fileno_modes[handle1].hFile,
- hProcess,
- &fileno_modes[handle2].hFile,
- 0,
- TRUE,
- DUPLICATE_SAME_ACCESS);
+ fileno_modes[handle1].hFile,
+ hProcess,
+ &fileno_modes[handle2].hFile,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS);
if (result)
{
fileno_modes[handle2].fd = handle2;
switch (handle2)
{
case 0:
- SetStdHandle(STD_INPUT_HANDLE, fileno_modes[handle2].hFile);
- break;
- case 1:
- SetStdHandle(STD_OUTPUT_HANDLE, fileno_modes[handle2].hFile);
- break;
- case 2:
- SetStdHandle(STD_ERROR_HANDLE, fileno_modes[handle2].hFile);
- break;
- case 3:
- SetStdHandle(STD_AUX_HANDLE, fileno_modes[handle2].hFile);
- break;
- case 4:
- SetStdHandle(STD_AUX_HANDLE, fileno_modes[handle2].hFile);
- break;
+ SetStdHandle(STD_INPUT_HANDLE, fileno_modes[handle2].hFile);
+ break;
+ case 1:
+ SetStdHandle(STD_OUTPUT_HANDLE, fileno_modes[handle2].hFile);
+ break;
+ case 2:
+ SetStdHandle(STD_ERROR_HANDLE, fileno_modes[handle2].hFile);
+ break;
+ case 3:
+ SetStdHandle(STD_AUX_HANDLE, fileno_modes[handle2].hFile);
+ break;
+ case 4:
+ SetStdHandle(STD_AUX_HANDLE, fileno_modes[handle2].hFile);
+ break;
}
return handle1;
}
else
{
- __set_errno(EMFILE); // Is this the correct error no.?
+ __set_errno(EMFILE); // Is this the correct error no.?
return -1;
}
}
-int __fileno_setmode(int _fd, int _newmode)
-{
- int m;
- if ( _fd < 0 || _fd >= maxfno )
- {
- __set_errno(EBADF);
- return -1;
- }
-
- m = fileno_modes[_fd].mode;
- fileno_modes[_fd].mode = _newmode;
- return m;
-}
-
-int __fileno_getmode(int _fd)
-{
- if ( _fd < 0 || _fd >= maxfno )
- {
- __set_errno(EBADF);
- return -1;
- }
- return fileno_modes[_fd].mode;
-}
+void* malloc(size_t sizeObject);
-int __fileno_close(int _fd)
-{
- if ( _fd < 0 || _fd >= maxfno )
- {
- __set_errno(EBADF);
- return -1;
- }
-
- fileno_modes[_fd].fd = -1;
- fileno_modes[_fd].hFile = (HANDLE)-1;
- return 0;
-}
-
-int _open_osfhandle (void *osfhandle, int flags )
-{
- return __fileno_alloc((HANDLE)osfhandle, flags);
-}
-
-void *_get_osfhandle( int fileno )
-{
- return filehnd(fileno);
-}
-
-void __fileno_init(void)
+BOOL __fileno_init(void)
{
ULONG count = 0, i;
HANDLE *pFile;
while(count >= maxfno)
maxfno += 255;
- fileno_modes = (fileno_modes_type*)malloc(sizeof(fileno_modes_type) * maxfno);
+ {
+ // why was this here ???? - robd.
+ //int result;
+ //result = malloc(50);
+
+ }
+ //fileno_modes = (fileno_modes_type*)malloc(sizeof(fileno_modes_type) * maxfno);
+ fileno_modes = malloc(sizeof(fileno_modes_type) * maxfno);
+ if (fileno_modes == NULL) {
+ return FALSE;
+ }
memset(fileno_modes, -1, sizeof(fileno_modes_type) * maxfno);
if (count)
for (i = 0; i < count; i++)
{
if (*pFile != INVALID_HANDLE_VALUE)
- {
+ {
fileno_modes[i].fd = i;
fileno_modes[i].mode = ((*pmode << 8) & (_O_TEXT|_O_BINARY)) | (*pmode & _O_ACCMODE);
fileno_modes[i].hFile = *pFile;
- }
+ }
pFile++;
pmode++;
}
fileno_modes[4].hFile = GetStdHandle(STD_PRINTER_HANDLE);
fileno_modes[4].mode = _O_WRONLY|_O_TEXT;
}
-}
+ return TRUE;
+}
-/* $Id: read.c,v 1.8 2002/09/08 10:22:50 chorns Exp $
+/* $Id: read.c,v 1.9 2002/11/24 18:42:22 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
/* text mode */
if (_rbyte && istext)
{
+ int found_cr = 0;
int cr = 0;
DWORD count = _rbyte;
/* repeat for all bytes in the buffer */
for(; count; bufp++, count--)
{
+#if 1
+ /* carriage return */
+ if (*bufp == '\r') {
+ found_cr = 1;
+ if (cr != 0) {
+ *(bufp - cr) = *bufp;
+ }
+ continue;
+ }
+ if (found_cr) {
+ found_cr = 0;
+ if (*bufp == '\n') {
+ cr++;
+ *(bufp - cr) = *bufp;
+ } else {
+ }
+ } else if (cr != 0) {
+ *(bufp - cr) = *bufp;
+ }
+#else
/* carriage return */
- if (*bufp == '\r')
+ if (*bufp == '\r') {
cr++;
+ }
/* shift characters back, to ignore carriage returns */
- else if (cr != 0)
+ else if (cr != 0) {
*(bufp - cr) = *bufp;
-
+ }
+#endif
}
-
/* ignore the carriage returns */
_rbyte -= cr;
}
-
DPRINT("%d\n", _rbyte);
return _rbyte;
}
-/* $Id: setmode.c,v 1.7 2002/11/18 03:19:42 robd Exp $
+/* $Id: setmode.c,v 1.8 2002/11/24 18:42:22 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
int _setmode(int _fd, int _newmode)
{
- DPRINT("_setmod(fd %d, newmode %x)\n", _fd, _newmode);
- return __fileno_setmode(_fd, _newmode);
+ DPRINT("_setmod(fd %d, newmode %x)\n", _fd, _newmode);
+ return __fileno_setmode(_fd, _newmode);
}
{
return _open((path), (access)|(shflag), (mode));
}
-
-int _wsopen(wchar_t *path, int access, int shflag, int mode)
-{
- return _wopen((path), (access)|(shflag), (mode));
-}
off_t _tell(int _file)
{
- return _lseek(_file, 0, SEEK_CUR);
-}
-
-__int64 _telli64(int _file)
-{
- return _lseeki64(_file, 0, SEEK_CUR);
+ return _lseek(_file, 0, SEEK_CUR);
}
--- /dev/null
+#include <msvcrt/errno.h>
+#include <msvcrt/io.h>
+
+
+__int64 _telli64(int _file)
+{
+ return _lseeki64(_file, 0, SEEK_CUR);
+}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <crtdll/sys/stat.h>
+#include <msvcrt/sys/stat.h>
unsigned _unMode_dll = 022;
#include <msvcrt/msvcrtdbg.h>
-int _unlink(const char *filename)
+int _unlink(const char* filename)
{
- int result = 0;
- DPRINT("_unlink('%s')\n", filename);
- if (!DeleteFileA(filename))
- result = -1;
- DPRINT("%d\n", result);
- return result;
-}
-
-int _wunlink(const wchar_t *filename)
-{
- DPRINT("_wunlink('%S')\n", filename);
- if (!DeleteFileW(filename))
- return -1;
- return 0;
+ int result = 0;
+ DPRINT("_unlink('%s')\n", filename);
+ if (!DeleteFileA(filename))
+ result = -1;
+ DPRINT("%d\n", result);
+ return result;
}
#include <msvcrt/sys/utime.h>
#include <msvcrt/internal/file.h>
-int _utime(const char* filename, struct _utimbuf* buf)
-{
- int fn;
- int ret;
-
- fn = _open(filename, _O_RDWR);
- if (fn == -1)
- {
- __set_errno(EBADF);
- return -1;
- }
- ret = _futime(fn,buf);
- if (_close(fn) < 0)
- return -1;
- return ret;
-}
-int _wutime(const wchar_t* filename, struct _utimbuf* buf)
+int _utime(const char* filename, struct _utimbuf* buf)
{
- int fn;
- int ret;
+ int fn;
+ int ret;
- fn = _wopen(filename, _O_RDWR);
- if (fn == -1)
- {
- __set_errno(EBADF);
- return -1;
+ fn = _open(filename, _O_RDWR);
+ if (fn == -1) {
+ __set_errno(EBADF);
+ return -1;
}
- ret = _futime(fn,buf);
- if (_close(fn) < 0)
- return -1;
- return ret;
+ ret = _futime(fn, buf);
+ if (_close(fn) < 0)
+ return -1;
+ return ret;
}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+
+int _waccess(const wchar_t *_path, int _amode)
+{
+ DWORD Attributes = GetFileAttributesW(_path);
+
+ if (Attributes == -1) {
+ __set_errno(ENOENT);
+ return -1;
+ }
+ if ((_amode & W_OK) == W_OK) {
+ if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) {
+ __set_errno(EACCES);
+ return -1;
+ }
+ }
+ if ((_amode & D_OK) == D_OK) {
+ if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
+ __set_errno(EACCES);
+ return -1;
+ }
+ }
+ return 0;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+#define mode_t int
+
+
+int _wchmod(const wchar_t* filename, mode_t mode)
+{
+ DWORD FileAttributes = 0;
+ DPRINT("_wchmod('%S', %x)\n", filename, mode);
+
+ FileAttributes = GetFileAttributesW(filename);
+ if ( FileAttributes == -1 )
+ return -1;
+
+ if ( mode == 0 )
+ return -1;
+
+ if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
+ FileAttributes &= FILE_ATTRIBUTE_READONLY;
+ else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE))
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+ else
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+
+ if (SetFileAttributesW(filename, FileAttributes) == FALSE)
+ return -1;
+
+ return 1;
+}
--- /dev/null
+#include <msvcrt/io.h>
+#include <msvcrt/fcntl.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+
+int _wcreat(const wchar_t* filename, int mode)
+{
+ DPRINT("_wcreat('%S', mode %x)\n", filename, mode);
+ return _wopen(filename,_O_CREAT|_O_TRUNC,mode);
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
+
+
+int _wfindfirst(const wchar_t* _name, struct _wfinddata_t* result)
+{
+ WIN32_FIND_DATAW FindFileData;
+ wchar_t dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
+
+ if ( _name == NULL || _name[0] == 0 ) {
+ len = GetCurrentDirectoryW(MAX_PATH-4, dir);
+ if (dir[len-1] != L'\\') {
+ dir[len] = L'\\';
+ dir[len+1] = 0;
+ }
+ wcscat(dir, L"*.*");
+ } else {
+ wcscpy(dir, _name);
+ }
+
+ hFindFile = (long)FindFirstFileW(dir, &FindFileData);
+ if (hFindFile == -1) {
+ memset(result,0,sizeof(struct _wfinddata_t));
+ return -1;
+ }
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
+
+ // if no wildcard the find file handle can be closed right away
+ // a return value of 0 can flag this.
+ if (!wcschr(dir, L'*') && !wcschr(dir, L'?')) {
+ _findclose(hFindFile);
+ return 0;
+ }
+
+ return hFindFile;
+}
+
+int _findfirsti64(const char *_name, struct _finddatai64_t *result)
+{
+ WIN32_FIND_DATAA FindFileData;
+ char dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
+
+ if ( _name == NULL || _name[0] == 0 )
+ {
+ len = GetCurrentDirectoryA(MAX_PATH-4,dir);
+ if (dir[len-1] != '\\')
+ {
+ dir[len] = '\\';
+ dir[len+1] = 0;
+ }
+ strcat(dir, "*.*");
+ }
+ else
+ strcpy(dir, _name);
+
+ hFindFile = (long)FindFirstFileA(dir, &FindFileData);
+ if (hFindFile == -1)
+ {
+ memset(result,0,sizeof(struct _finddatai64_t));
+ return -1;
+ }
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size =
+ (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
+ strncpy(result->name,FindFileData.cFileName,MAX_PATH);
+
+ // if no wildcard the find file handle can be closed right away
+ // a return value of 0 can flag this.
+
+ if (!strchr(dir,'*') && !strchr(dir,'?')) {
+ _findclose(hFindFile);
+ return 0;
+ }
+ return hFindFile;
+}
+
+int _findnexti64(int handle, struct _finddatai64_t *result)
+{
+ WIN32_FIND_DATAA FindFileData;
+
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+
+ if (!FindNextFileA((void *)handle, &FindFileData))
+ return -1;
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size =
+ (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
+ strncpy(result->name,FindFileData.cFileName,MAX_PATH);
+
+ return 0;
+}
+
+int _wfindfirsti64(const wchar_t *_name, struct _wfinddatai64_t *result)
+{
+ WIN32_FIND_DATAW FindFileData;
+ wchar_t dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
+
+ if (_name == NULL || _name[0] == 0)
+ {
+ len = GetCurrentDirectoryW(MAX_PATH-4,dir);
+ if (dir[len-1] != L'\\')
+ {
+ dir[len] = L'\\';
+ dir[len+1] = 0;
+ }
+ wcscat(dir, L"*.*");
+ }
+ else
+ wcscpy(dir, _name);
+
+ hFindFile = (long)FindFirstFileW(dir, &FindFileData);
+ if (hFindFile == -1)
+ {
+ memset(result,0,sizeof(struct _wfinddatai64_t));
+ return -1;
+ }
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size =
+ (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
+ wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
+
+ // if no wildcard the find file handle can be closed right away
+ // a return value of 0 can flag this.
+
+ if (!wcschr(dir,L'*') && !wcschr(dir,L'?'))
+ {
+ _findclose(hFindFile);
+ return 0;
+ }
+
+ return hFindFile;
+}
+
+int _wfindnext(int handle, struct _wfinddata_t *result)
+{
+ WIN32_FIND_DATAW FindFileData;
+
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+
+ if (!FindNextFileW((void *)handle, &FindFileData))
+ return -1;
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ wcsncpy(result->name,FindFileData.cFileName, MAX_PATH);
+
+ return 0;
+}
+
+int _wfindnexti64(int handle, struct _wfinddatai64_t *result)
+{
+ WIN32_FIND_DATAW FindFileData;
+
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+
+ if (!FindNextFileW((void *)handle, &FindFileData))
+ return -1;
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size =
+ (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
+ wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
+
+ return 0;
+}
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/io/mktemp.c
+ * PURPOSE: Makes a temp file based on a template
+ * PROGRAMER: DJ Delorie
+ Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Appropriated for the Reactos Kernel
+ */
+
+/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+#include <msvcrt/io.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+
+wchar_t* _wmktemp (wchar_t *_template)
+{
+ static int count = 0;
+ wchar_t *cp, *dp;
+ int i, len, xcount, loopcnt;
+
+ DPRINT("_wmktemp('%S')\n", _template);
+ len = wcslen (_template);
+ cp = _template + len;
+
+ xcount = 0;
+ while (xcount < 6 && cp > _template && cp[-1] == L'X')
+ xcount++, cp--;
+
+ if (xcount) {
+ dp = cp;
+ while (dp > _template && dp[-1] != L'/' && dp[-1] != L'\\' && dp[-1] != L':')
+ dp--;
+
+ /* Keep the first characters of the template, but turn the rest into
+ Xs. */
+ while (cp > dp + 8 - xcount) {
+ *--cp = L'X';
+ xcount = (xcount >= 6) ? 6 : 1 + xcount;
+ }
+
+ /* If dots occur too early -- squash them. */
+ while (dp < cp) {
+ if (*dp == L'.') *dp = L'a';
+ dp++;
+ }
+
+ /* Try to add ".tmp" to the filename. Truncate unused Xs. */
+ if (cp + xcount + 3 < _template + len)
+ wcscpy (cp + xcount, L".tmp");
+ else
+ cp[xcount] = 0;
+
+ /* This loop can run up to 2<<(5*6) times, or about 10^9 times. */
+ for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) {
+ int c = count++;
+ for (i = 0; i < xcount; i++, c >>= 5)
+ cp[i] = L"abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];
+ if (_waccess(_template,0) == -1)
+ return _template;
+ }
+ }
+
+ /* Failure: truncate the template and return NULL. */
+ *_template = 0;
+ return 0;
+}
--- /dev/null
+/* $Id: wopen.c,v 1.1 2002/11/24 18:42:22 robd Exp $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/io/open.c
+ * PURPOSE: Opens a file and translates handles to fileno
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+
+// rember to interlock the allocation of fileno when making this thread safe
+// possibly store extra information at the handle
+
+#include <windows.h>
+#if !defined(NDEBUG) && defined(DBG)
+#include <msvcrt/stdarg.h>
+#endif
+#include <msvcrt/io.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/sys/stat.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
+#include <msvcrt/string.h>
+#include <msvcrt/share.h>
+#include <msvcrt/errno.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+
+int _wopen(const wchar_t* _path, int _oflag, ...)
+{
+#if !defined(NDEBUG) && defined(DBG)
+ va_list arg;
+ int pmode;
+#endif
+ HANDLE hFile;
+ DWORD dwDesiredAccess = 0;
+ DWORD dwShareMode = 0;
+ DWORD dwCreationDistribution = 0;
+ DWORD dwFlagsAndAttributes = 0;
+ SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
+
+#if !defined(NDEBUG) && defined(DBG)
+ va_start(arg, _oflag);
+ pmode = va_arg(arg, int);
+#endif
+
+// DPRINT("_wopen('%S', %x, (%x))\n", _path, _oflag, pmode);
+
+ if (( _oflag & S_IREAD ) == S_IREAD)
+ dwShareMode = FILE_SHARE_READ;
+ else if ( ( _oflag & S_IWRITE) == S_IWRITE ) {
+ dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ }
+
+ /*
+ *
+ * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
+ * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
+ *
+ * _O_APPEND Moves file pointer to end of file before every write operation.
+ */
+ if (( _oflag & _O_RDWR ) == _O_RDWR )
+ dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA |
+ FILE_WRITE_DATA | FILE_READ_ATTRIBUTES |
+ FILE_WRITE_ATTRIBUTES;
+ else if (( _oflag & O_RDONLY ) == O_RDONLY )
+ dwDesiredAccess |= GENERIC_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES |
+ FILE_WRITE_ATTRIBUTES;
+ else if (( _oflag & _O_WRONLY ) == _O_WRONLY )
+ dwDesiredAccess |= GENERIC_WRITE | FILE_WRITE_DATA |
+ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES;
+
+ if (( _oflag & S_IREAD ) == S_IREAD )
+ dwShareMode |= FILE_SHARE_READ;
+
+ if (( _oflag & S_IWRITE ) == S_IWRITE )
+ dwShareMode |= FILE_SHARE_WRITE;
+
+ if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) )
+ dwCreationDistribution |= CREATE_NEW;
+
+ else if (( _oflag & O_TRUNC ) == O_TRUNC ) {
+ if (( _oflag & O_CREAT ) == O_CREAT )
+ dwCreationDistribution |= CREATE_ALWAYS;
+ else if (( _oflag & O_RDONLY ) != O_RDONLY )
+ dwCreationDistribution |= TRUNCATE_EXISTING;
+ }
+ else if (( _oflag & _O_APPEND ) == _O_APPEND )
+ dwCreationDistribution |= OPEN_EXISTING;
+ else if (( _oflag & _O_CREAT ) == _O_CREAT )
+ dwCreationDistribution |= OPEN_ALWAYS;
+ else
+ dwCreationDistribution |= OPEN_EXISTING;
+
+ if (( _oflag & _O_RANDOM ) == _O_RANDOM )
+ dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
+ if (( _oflag & _O_SEQUENTIAL ) == _O_SEQUENTIAL )
+ dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
+
+ if (( _oflag & _O_TEMPORARY ) == _O_TEMPORARY )
+ dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
+
+ if (( _oflag & _O_SHORT_LIVED ) == _O_SHORT_LIVED )
+ dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
+
+ if (_oflag & _O_NOINHERIT)
+ sa.bInheritHandle = FALSE;
+
+ hFile = CreateFileW(_path,
+ dwDesiredAccess,
+ dwShareMode,
+ &sa,
+ dwCreationDistribution,
+ dwFlagsAndAttributes,
+ NULL);
+ if (hFile == (HANDLE)-1)
+ return -1;
+ return __fileno_alloc(hFile,_oflag);
+}
+
+int _wsopen(wchar_t *path, int access, int shflag, int mode)
+{
+ return _wopen((path), (access)|(shflag), (mode));
+}
*/
#include <windows.h>
#include <msvcrt/io.h>
+#include <msvcrt/stdlib.h>
#include <msvcrt/internal/file.h>
#define NDEBUG
size_t _write(int _fd, const void *_buf, size_t _nbyte)
{
char *tmp, *in, *out;
- int count, result;
+ int result;
+ unsigned int count;
DWORD wbyte;
DPRINT("_write(fd %d, buf %x, nbyte %d)\n", _fd, _buf, _nbyte);
result = -1;
break;
}
- if (wbyte < BUFSIZE - count)
+ if (wbyte < (BUFSIZE - count))
{
result = in - (char*)_buf;
break;
{
if(!WriteFile(_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL))
{
+ DWORD error = GetLastError();
+ if (error != ERROR_SUCCESS) {
+ PTSTR msg;
+ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
+ 0, error, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (PTSTR)&msg, 0, NULL))
+ printf("_write(fd %d, buf %x, nbyte %d) - %s\n", _fd, _buf, _nbyte, msg);
+ else
+ printf("_write(fd %d, buf %x, nbyte %d) - unknown error: %d\n", _fd, _buf, _nbyte, msg, error);
+ LocalFree(msg);
+ }
+/*
+DWORD FormatMessage(
+ DWORD dwFlags, // source and processing options
+ LPCVOID lpSource, // message source
+ DWORD dwMessageId, // message identifier
+ DWORD dwLanguageId, // language identifier
+ LPTSTR lpBuffer, // message buffer
+ DWORD nSize, // maximum size of message buffer
+ va_list *Arguments // array of message inserts
+);
+ */
return -1;
}
return wbyte;
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/io/unlink.c
+ * PURPOSE: Deletes a file
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+#include <windows.h>
+#include <msvcrt/io.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+
+int _wunlink(const wchar_t* filename)
+{
+ DPRINT("_wunlink('%S')\n", filename);
+ if (!DeleteFileW(filename))
+ return -1;
+ return 0;
+}
--- /dev/null
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/sys/utime.h>
+#include <msvcrt/internal/file.h>
+
+
+int _wutime(const wchar_t* filename, struct _utimbuf* buf)
+{
+ int fn;
+ int ret;
+
+ fn = _wopen(filename, _O_RDWR);
+ if (fn == -1) {
+ __set_errno(EBADF);
+ return -1;
+ }
+ ret = _futime(fn, buf);
+ if (_close(fn) < 0)
+ return -1;
+ return ret;
+}
double atan (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fld1\n\t"
"fpatan"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_atan(__x);
+#endif /*__GNUC__*/
return __value;
}
double atan2 (double __y, double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fpatan\n\t"
"fld %%st(0)"
: "=t" (__value) : "0" (__x), "u" (__y));
-
+#else
+ __value = linkme_atan2(__x, __y);
+#endif /*__GNUC__*/
return __value;
}
double ceil (double __x)
{
register double __value;
+#ifdef __GNUC__
__volatile unsigned short int __cw, __cwtmp;
__asm __volatile ("fnstcw %0" : "=m" (__cw));
__asm __volatile ("fldcw %0" : : "m" (__cwtmp));
__asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
__asm __volatile ("fldcw %0" : : "m" (__cw));
-
+#else
+ __value = linkme_ceil(__x);
+#endif /*__GNUC__*/
return __value;
}
double cos (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fcos"
: "=t" (__value): "0" (__x));
-
+#else
+ __value = linkme_cos(__x);
+#endif /*__GNUC__*/
return __value;
}
double exp (double __x)
{
+#ifdef __GNUC__
register double __value, __exponent;
__asm __volatile__
("fldl2e # e^x = 2^(x * log2(e))\n\t"
: "=t" (__value) : "0" (__value), "u" (__exponent));
return __value;
+#else
+ return linkme_exp(__x);
+#endif /*__GNUC__*/
}
double fabs (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fabs"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_fabs(__x);
+#endif /*__GNUC__*/
return __value;
}
double floor (double __x)
{
register double __value;
+#ifdef __GNUC__
__volatile unsigned short int __cw, __cwtmp;
__asm __volatile ("fnstcw %0" : "=m" (__cw));
__asm __volatile ("fldcw %0" : : "m" (__cwtmp));
__asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
__asm __volatile ("fldcw %0" : : "m" (__cw));
-
+#else
+ __value = linkme_floor(__x);
+#endif /*__GNUC__*/
return __value;
}
double fmod (double __x, double __y)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("1: fprem\n\t"
"fstsw %%ax\n\t"
"sahf\n\t"
"jp 1b"
: "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc");
-
+#else
+ __value = linkme_fmod(__x, __y);
+#endif /*__GNUC__*/
return __value;
}
#ifdef TEST
-#include <crtdll/stdio.h>
+#include <msvcrt/stdio.h>
int
main(void)
-#include <crtdll/math.h>
+#include <msvcrt/math.h>
double _jn(int n, double x)
{
double ldexp (double __x, int __y)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fscale"
: "=t" (__value) : "0" (__x), "u" ((double) __y));
-
+#else
+ __value = linkme_ldexp(__x, __y);
+#endif /*__GNUC__*/
return __value;
}
double log (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fldln2\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_log(__x);
+#endif /*__GNUC__*/
return __value;
}
double log10 (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fldlg2\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_log10(__x);
+#endif /*__GNUC__*/
return __value;
}
--- /dev/null
+#include <msvcrt/math.h>
+
+#pragma function(fmod,sqrt)
+#pragma function(log,log10,pow,exp)
+#pragma function(tan,atan,atan2,tanh)
+#pragma function(cos,acos,cosh)
+#pragma function(sin,asin,sinh)
+
+
+double linkme_ceil(double __x)
+{
+ return ceil(__x);
+}
+
+double linkme_fabs(double __x)
+{
+ return fabs(__x);
+}
+
+double linkme_floor(double __x)
+{
+ return floor(__x);
+}
+
+double linkme_ldexp(double __x, int __y)
+{
+ return ldexp(__x, __y);
+}
+
+double linkme_log2(double __x)
+{
+ //return log2(__x);
+ return 0;
+}
+
+double linkme_fmod(double __x, double __y)
+{
+ return fmod(__x, __y);
+}
+
+double linkme_sqrt(double __x)
+{
+ return sqrt(__x);
+}
+
+double linkme_log(double __x)
+{
+ return log(__x);
+}
+
+double linkme_log10(double __x)
+{
+ return log10(__x);
+}
+
+double linkme_pow(double __x, double __y)
+{
+ return pow(__x, __y);
+}
+
+double linkme_exp(double __x)
+{
+ return exp(__x);
+}
+
+double linkme_tan(double __x)
+{
+ return tan(__x);
+}
+
+double linkme_atan(double __x)
+{
+ return atan(__x);
+}
+
+double linkme_atan2(double __x, double __y)
+{
+ return atan2(__x, __y);
+}
+
+double linkme_tanh(double __x)
+{
+ return tanh(__x);
+}
+
+double linkme_cos(double __x)
+{
+ return cos(__x);
+}
+
+double linkme_acos(double __x)
+{
+ return acos(__x);
+}
+
+double linkme_cosh(double __x)
+{
+ return cosh(__x);
+}
+
+double linkme_sin(double __x)
+{
+ return sin(__x);
+}
+
+double linkme_asin(double __x)
+{
+ return asin(__x);
+}
+
+double linkme_sinh(double __x)
+{
+ return sinh(__x);
+}
+/*
+linkme_log2
+linkme_floor
+_linkme_ldexp
+_linkme_pow
+ */
double __log2 (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fld1\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
-
+#else
+ //__value = linkme_log2(__x);
+ __value = 0;
+#endif /*__GNUC__*/
return __value;
}
double pow (double __x, double __y)
{
- register double __value, __exponent;
+ register double __value;
+#ifdef __GNUC__
+ register double __exponent;
long __p = (long) __y;
if (__x == 0.0 && __y > 0.0)
__asm __volatile__
("fscale"
: "=t" (__value) : "0" (__value), "u" (__exponent));
-
+#else
+ __value = linkme_pow(__x, __y);
+#endif /*__GNUC__*/
return __value;
}
double sin (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fsin"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_sin(__x);
+#endif /*__GNUC__*/
return __value;
}
double sqrt (double __x)
{
register double __value;
+#ifdef __GNUC__
__asm __volatile__
("fsqrt"
: "=t" (__value) : "0" (__x));
-
+#else
+ __value = linkme_sqrt(__x);
+#endif /*__GNUC__*/
return __value;
}
double tan (double __x)
{
register double __value;
+#ifdef __GNUC__
register double __value2 __attribute__ ((unused));
__asm __volatile__
("fptan"
: "=t" (__value2), "=u" (__value) : "0" (__x));
-
+#else
+ __value = linkme_tan(__x);
+#endif /*__GNUC__*/
return __value;
}
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbctype.h>
-#include <crtdll/ctype.h>
+#include <msvcrt/mbctype.h>
+#include <msvcrt/ctype.h>
int _ismbbalpha(unsigned char c)
{
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/msvcrt/mbstring/mbbtype.c
+ * FILE: lib/crtdll/mbstring/mbbtype.c
* PURPOSE: Determines the type of a multibyte character
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
-#include <crtdll/mbstring.h>
-#include <crtdll/mbctype.h>
+#include <msvcrt/mbstring.h>
+#include <msvcrt/mbctype.h>
int _mbbtype(unsigned char c , int type)
{
- if (type == 1)
- {
- if ((c >= 0x40 && c <= 0x7e) || (c >= 0x80 && c <= 0xfc))
- {
- return _MBC_TRAIL;
+ if ( type == 1 ) {
+ if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) )
+ {
+ return _MBC_TRAIL;
+ }
+ else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
+ ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
+ return _MBC_ILLEGAL;
+ else
+ return 0;
+
}
- else if ((c >= 0x20 && c >= 0x7E) || (c >= 0xA1 && c <= 0xDF) ||
- (c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xFC))
- return _MBC_ILLEGAL;
- else
- return 0;
- }
- else
- {
- if ((c >= 0x20 && c <= 0x7E) || (c >= 0xA1 && c <= 0xDF ))
- return _MBC_SINGLE;
- else if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xFC))
- return _MBC_LEAD;
- else if ((c >= 0x20 && c >= 0x7E) || (c >= 0xA1 && c <= 0xDF) ||
- (c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xFC))
- return _MBC_ILLEGAL;
- else
- return 0;
- }
- return 0;
+ else {
+ if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) {
+ return _MBC_SINGLE;
+ }
+ else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) )
+ return _MBC_LEAD;
+ else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
+ ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
+ return _MBC_ILLEGAL;
+ else
+ return 0;
+
+ }
+
+
+ return 0;
}
int _mbsbtype( const unsigned char *str, size_t n )
{
- if (str == NULL)
- return -1;
- return _mbbtype(*(str+n),1);
+ if ( str == NULL )
+ return -1;
+ return _mbbtype(*(str+n),1);
}
-
#include <msvcrt/mbstring.h>
#include <msvcrt/stdlib.h>
return -1;
return l;
}
-
-
-
unsigned int _mbctolower(unsigned int c)
{
- if ((c & 0xFF00) != 0)
- {
- // true multibyte case conversion needed
- if (_ismbclower(c))
- return c + CASE_DIFF;
- }
- else
+ if ((c & 0xFF00) != 0) {
+ // true multibyte case conversion needed
+ if (_ismbclower(c))
+ return c + CASE_DIFF;
+ } else {
return _mbbtolower(c);
-
- return 0;
+ }
+ return 0;
}
unsigned char * _mbslwr(unsigned char *x)
{
- unsigned char *y=x;
+ unsigned char *y=x;
- while (*y)
- {
- if (!_ismbblead(*y))
- {
- *y = tolower(*y);
- }
- else
- {
- *y=_mbctolower(*(unsigned short *)y);
- y++;
- }
+ while (*y) {
+ if (!_ismbblead(*y)) {
+ *y = tolower(*y);
+ } else {
+ *y=_mbctolower(*(unsigned short *)y);
+ y++;
+ }
}
- return x;
+ return x;
}
* 28/12/98: Created
*/
+#include <msvcrt/stdlib.h>
#include <msvcrt/stdio.h>
int _aexit_rtn(int exitcode)
{
- _exit(exitcode);
+ _exit(exitcode);
+ return 0;
}
-void _amsg_exit (int errnum)
+void _amsg_exit(int errnum)
{
- fprintf(stderr, "runtime error - %s\n", __rt_err_msg[errnum]);
- _aexit_rtn(-1);
+ fprintf(stderr, "runtime error - %s\n", __rt_err_msg[errnum]);
+ _aexit_rtn(-1);
}
-/* EOF */
--- /dev/null
+/* $Id: crtmain.c,v 1.1 2002/11/24 18:42:23 robd Exp $
+ *
+ * ReactOS MSVCRT.DLL Compatibility Library
+ */
+#include <windows.h>
+//#include <msvcrt/stdlib.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+#ifndef __GNUC__
+
+/* GLOBAL VARIABLES *******************************************************/
+
+int _fltused;
+//int _allmul;
+
+/* FUNCTIONS **************************************************************/
+
+
+int __cdecl _allmul(void)
+{
+ return 0;
+}
+
+int __cdecl _allshl(void)
+{
+ return 0;
+}
+
+#if 1
+
+void __cdecl _chkesp(int value1, int value2)
+{
+}
+
+#else
+
+int __cdecl _chkesp(int value)
+{
+ return value;
+}
+
+#endif
+
+int __cdecl _alloca_probe(void)
+{
+ return 0;
+}
+/*
+BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved);
+
+int STDCALL _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
+{
+ BOOL result;
+
+ //__fileno_init();
+ //result = DllMain(hInst, ul_reason_for_call, lpReserved);
+
+ result = DllMain(hInst, DLL_PROCESS_ATTACH, lpReserved);
+
+
+ return (result ? 1 : 0);
+}
+ */
+/*
+int
+STDCALL
+_abnormal_termination(void)
+{
+ return 0;
+}
+
+int
+STDCALL
+_setjmp(void)
+{
+ return 0;
+}
+ */
+int
+STDCALL
+_except_handler3(void)
+{
+ return 0;
+}
+
+int
+STDCALL
+_local_unwind2(void)
+{
+ return 0;
+}
+
+int
+STDCALL
+_spawnlp(int a, const char* b, const char* args, ...)
+{
+ return 0;
+}
+
+#else /*__GNUC__*/
+
+int
+_spawnlp(int a, const char* b, const char* args, ...)
+{
+ return 0;
+}
+
+#endif /*__GNUC__*/
+
+
+/* EOF */
-/* $Id: dllmain.c,v 1.16 2002/09/08 10:22:53 chorns Exp $
+/* $Id: dllmain.c,v 1.17 2002/11/24 18:42:23 robd Exp $
+ *
+ * dllmain.c
*
* ReactOS MSVCRT.DLL Compatibility Library
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warrenties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $Revision: 1.17 $
+ * $Author: robd $
+ * $Date: 2002/11/24 18:42:23 $
+ *
*/
-#include <windows.h>
+#include <windows.h>
#include <msvcrt/internal/tls.h>
#include <msvcrt/stdlib.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
-static int nAttachCount = 0;
-unsigned int _osver = 0;
-unsigned int _winminor = 0;
-unsigned int _winmajor = 0;
-unsigned int _winver = 0;
+/* EXTERNAL PROTOTYPES ********************************************************/
-char *_acmdln = NULL; /* pointer to ascii command line */
-#undef _environ
-char **_environ = NULL; /* pointer to environment block */
-char ***_environ_dll = &_environ;/* pointer to environment block */
+//void __fileno_init(void);
+extern BOOL __fileno_init(void);
+extern int BlockEnvToEnviron(void);
-char **__initenv = NULL;
+extern unsigned int _osver;
+extern unsigned int _winminor;
+extern unsigned int _winmajor;
+extern unsigned int _winver;
-char *_pgmptr = NULL; /* pointer to program name */
+extern char* _acmdln; /* pointer to ascii command line */
+#undef _environ
+extern char** _environ; /* pointer to environment block */
-int __app_type = 0; //_UNKNOWN_APP; /* application type */
-int __mb_cur_max = 1;
+/* LIBRARY GLOBAL VARIABLES ***************************************************/
-HANDLE hHeap = NULL; /* handle for heap */
+static int nAttachCount = 0;
+HANDLE hHeap = NULL; /* handle for heap */
-/* FUNCTIONS **************************************************************/
-int BlockEnvToEnviron()
-{
- char * ptr, * ptr2;
- int i, len;
-
- DPRINT("BlockEnvToEnviron()\n");
-
- if (_environ)
- {
- FreeEnvironmentStringsA(_environ[0]);
- free(_environ);
- _environ = NULL;
- }
- ptr2 = ptr = (char*)GetEnvironmentStringsA();
- if (ptr == NULL)
- {
- DPRINT("GetEnvironmentStringsA() returnd NULL\n");
- return -1;
- }
- len = 0;
- while (*ptr2)
- {
- len++;
- while (*ptr2++);
- }
- _environ = malloc((len + 1) * sizeof(char*));
- if (_environ == NULL)
- {
- FreeEnvironmentStringsA(ptr);
- return -1;
- }
- for (i = 0; i < len && *ptr; i++)
- {
- _environ[i] = ptr;
- while (*ptr++);
- }
- _environ[i] = NULL;
- return 0;
-}
+/* LIBRARY ENTRY POINT ********************************************************/
-BOOL __stdcall
-DllMain(PVOID hinstDll,
- ULONG dwReason,
- PVOID reserved)
+BOOL
+STDCALL
+DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
{
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH://1
- /* initialize version info */
- DPRINT("Attach %d\n", nAttachCount);
- _osver = GetVersion();
- _winmajor = (_osver >> 8) & 0xFF;
- _winminor = _osver & 0xFF;
- _winver = (_winmajor << 8) + _winminor;
- _osver = (_osver >> 16) & 0xFFFF;
-
- if (hHeap == NULL || hHeap == INVALID_HANDLE_VALUE)
- {
- hHeap = HeapCreate(0, 0, 0);
- if (hHeap == NULL || hHeap == INVALID_HANDLE_VALUE)
- {
- return FALSE;
- }
- }
- if (nAttachCount==0)
- {
- __fileno_init();
- }
-
- /* create tls stuff */
- if (!CreateThreadData())
- return FALSE;
-
- _acmdln = (char *)GetCommandLineA();
-
- /* FIXME: This crashes all applications */
- if (BlockEnvToEnviron() < 0)
- return FALSE;
-
- /* FIXME: more initializations... */
-
- nAttachCount++;
- DPRINT("Attach done\n");
- break;
-
- case DLL_THREAD_ATTACH://2
- break;
-
- case DLL_THREAD_DETACH://4
- FreeThreadData(NULL);
- break;
-
- case DLL_PROCESS_DETACH://0
- DPRINT("Detach %d\n", nAttachCount);
- if (nAttachCount > 0)
- {
- nAttachCount--;
-
- /* FIXME: more cleanup... */
- _fcloseall();
-
- /* destroy tls stuff */
- DestroyThreadData();
-
- /* destroy heap */
- if (nAttachCount == 0)
- {
-
- if (_environ)
- {
- FreeEnvironmentStringsA(_environ[0]);
- free(_environ);
- _environ = NULL;
- }
-#if 1
- HeapDestroy(hHeap);
- hHeap = NULL;
+ switch (dwReason)
+ {
+ case DLL_PROCESS_ATTACH://1
+#if 0
+#else
+ /* initialize version info */
+ DPRINT("Attach %d\n", nAttachCount);
+ _osver = GetVersion();
+ _winmajor = (_osver >> 8) & 0xFF;
+ _winminor = _osver & 0xFF;
+ _winver = (_winmajor << 8) + _winminor;
+ _osver = (_osver >> 16) & 0xFFFF;
+ if (hHeap == NULL || hHeap == INVALID_HANDLE_VALUE)
+ {
+ hHeap = HeapCreate(0, 100000, 0);
+ if (hHeap == NULL || hHeap == INVALID_HANDLE_VALUE)
+ {
+ return FALSE;
+ }
+ }
+ if (nAttachCount==0)
+ {
+ if (!__fileno_init()) {
+ HeapDestroy(hHeap);
+ hHeap = NULL;
+ return FALSE;
+ }
+ }
+
+ /* create tls stuff */
+ if (!CreateThreadData())
+ return FALSE;
+
+ _acmdln = (char *)GetCommandLineA();
+
+ /* FIXME: This crashes all applications */
+ if (BlockEnvToEnviron() < 0)
+ return FALSE;
+
+ /* FIXME: more initializations... */
+
+ nAttachCount++;
+ DPRINT("Attach done\n");
#endif
- }
- DPRINT("Detach done\n");
- }
- break;
- }
+ break;
- return TRUE;
-}
+ case DLL_THREAD_ATTACH://2
+ break;
+ case DLL_THREAD_DETACH://4
+ FreeThreadData(NULL);
+ break;
+ case DLL_PROCESS_DETACH://0
+ DPRINT("Detach %d\n", nAttachCount);
+ if (nAttachCount > 0)
+ {
+ nAttachCount--;
-void __set_app_type(int app_type)
-{
- __app_type = app_type;
-}
+ /* FIXME: more cleanup... */
+ _fcloseall();
+ /* destroy tls stuff */
+ DestroyThreadData();
-char **__p__acmdln(void)
-{
- return &_acmdln;
-}
-
-char ***__p__environ(void)
-{
- return _environ_dll;
-}
+ /* destroy heap */
+ if (nAttachCount == 0)
+ {
-char ***__p___initenv(void)
-{
- return &__initenv;
-}
-
-int *__p___mb_cur_max(void)
-{
- return &__mb_cur_max;
-}
-
-unsigned int *__p__osver(void)
-{
- return &_osver;
-}
-
-char **__p__pgmptr(void)
-{
- return &_pgmptr;
-}
-
-unsigned int *__p__winmajor(void)
-{
- return &_winmajor;
-}
-
-unsigned int *__p__winminor(void)
-{
- return &_winminor;
-}
+ if (_environ)
+ {
+ FreeEnvironmentStringsA(_environ[0]);
+ free(_environ);
+ _environ = NULL;
+ }
+#if 1
+ HeapDestroy(hHeap);
+ hHeap = NULL;
+#endif
+ }
+ DPRINT("Detach done\n");
+ }
+ break;
+ }
-unsigned int *__p__winver(void)
-{
- return &_winver;
+ return TRUE;
}
-
-
/* EOF */
--- /dev/null
+/* $Id: environ.c,v 1.1 2002/11/24 18:42:23 robd Exp $
+ *
+ * dllmain.c
+ *
+ * ReactOS MSVCRT.DLL Compatibility Library
+ */
+
+#include <windows.h>
+#include <msvcrt/internal/tls.h>
+#include <msvcrt/stdlib.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+
+unsigned int _osver = 0;
+unsigned int _winminor = 0;
+unsigned int _winmajor = 0;
+unsigned int _winver = 0;
+
+char *_acmdln = NULL; /* pointer to ascii command line */
+#undef _environ
+char **_environ = NULL; /* pointer to environment block */
+char ***_environ_dll = &_environ;/* pointer to environment block */
+char **__initenv = NULL;
+char *_pgmptr = NULL; /* pointer to program name */
+int __app_type = 0; //_UNKNOWN_APP; /* application type */
+int __mb_cur_max = 1;
+
+int _commode = _IOCOMMIT;
+
+
+int *__p__commode(void) // not exported by NTDLL
+{
+ return &_commode;
+}
+
+int BlockEnvToEnviron(void)
+{
+ char * ptr, * ptr2;
+ int i, len;
+
+ DPRINT("BlockEnvToEnviron()\n");
+
+ if (_environ) {
+ FreeEnvironmentStringsA(_environ[0]);
+ free(_environ);
+ _environ = NULL;
+ }
+ ptr2 = ptr = (char*)GetEnvironmentStringsA();
+ if (ptr == NULL) {
+ DPRINT("GetEnvironmentStringsA() returnd NULL\n");
+ return -1;
+ }
+ len = 0;
+ while (*ptr2) {
+ len++;
+ while (*ptr2++);
+ }
+ _environ = malloc((len + 1) * sizeof(char*));
+ if (_environ == NULL) {
+ FreeEnvironmentStringsA(ptr);
+ return -1;
+ }
+ for (i = 0; i < len && *ptr; i++) {
+ _environ[i] = ptr;
+ while (*ptr++);
+ }
+ _environ[i] = NULL;
+ return 0;
+}
+
+void __set_app_type(int app_type)
+{
+ __app_type = app_type;
+}
+
+char **__p__acmdln(void)
+{
+ return &_acmdln;
+}
+
+char ***__p__environ(void)
+{
+ return _environ_dll;
+}
+
+char ***__p___initenv(void)
+{
+ return &__initenv;
+}
+
+int *__p___mb_cur_max(void)
+{
+ return &__mb_cur_max;
+}
+
+unsigned int *__p__osver(void)
+{
+ return &_osver;
+}
+
+char **__p__pgmptr(void)
+{
+ return &_pgmptr;
+}
+
+unsigned int *__p__winmajor(void)
+{
+ return &_winmajor;
+}
+
+unsigned int *__p__winminor(void)
+{
+ return &_winminor;
+}
+
+unsigned int *__p__winver(void)
+{
+ return &_winver;
+}
+
+/* EOF */
#include <msvcrt/stdlib.h>
#include <msvcrt/string.h>
-extern char *_acmdln;
-extern char *_pgmptr;
+
+extern char*_acmdln;
+extern char*_pgmptr;
#undef _environ
-extern char **_environ;
+extern char**_environ;
#undef __argv
#undef __argc
-char **__argv = NULL;
-int __argc = 0;
+char**__argv = NULL;
+int __argc = 0;
extern HANDLE hHeap;
char* strndup(char* name, int len)
{
- char *s = malloc(len + 1);
- if (s != NULL)
- {
- strncpy(s, name, len);
- }
- return s;
+ char *s = malloc(len + 1);
+ if (s != NULL) {
+ strncpy(s, name, len);
+ }
+ return s;
}
-
+
#define SIZE (4096 / sizeof(char*))
-int add(char *name)
+int add(char* name)
{
- char** _new;
- if ((__argc % SIZE) == 0)
- {
- _new = malloc(sizeof(char*) * (__argc + SIZE));
- if (_new == NULL)
- {
- return -1;
- }
- if (__argv)
- {
- memcpy(_new, __argv, sizeof(char*) * __argc);
- free(__argv);
- }
- __argv = _new;
- }
- __argv[__argc++] = name;
+ char** _new;
+ if ((__argc % SIZE) == 0) {
+ _new = malloc(sizeof(char*) * (__argc + SIZE));
+ if (_new == NULL) {
+ return -1;
+ }
+ if (__argv) {
+ memcpy(_new, __argv, sizeof(char*) * __argc);
+ free(__argv);
+ }
+ __argv = _new;
+ }
+ __argv[__argc++] = name;
+ return 0;
}
int expand(char* name)
{
- char *s;
- WIN32_FIND_DATA fd;
- HANDLE hFile;
- BOOLEAN first = TRUE;
- char buffer[256];
- int pos;
-
- s = strpbrk(name, "*?");
- if (s)
- {
- hFile = FindFirstFile(name, &fd);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- while(s != name && *s != '/' && *s != '\\')
- s--;
- pos = s - name;
- if (*s == '/' || *s == '\\')
- pos++;
- strncpy(buffer, name, pos);
- do
- {
- if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- strcpy(&buffer[pos], fd.cFileName);
- if (add(strdup(buffer)) < 0)
- {
- FindClose(hFile);
- return -1;
- }
- first = FALSE;
- }
- }
- while(FindNextFile(hFile, &fd));
- FindClose(hFile);
- }
- }
- if (first)
- {
- if (add(name) < 0)
- return -1;
- }
- else
- free(name);
- return 0;
+ char* s;
+ WIN32_FIND_DATA fd;
+ HANDLE hFile;
+ BOOLEAN first = TRUE;
+ char buffer[256];
+ int pos;
+
+ s = strpbrk(name, "*?");
+ if (s) {
+ hFile = FindFirstFile(name, &fd);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ while(s != name && *s != '/' && *s != '\\')
+ s--;
+ pos = s - name;
+ if (*s == '/' || *s == '\\')
+ pos++;
+ strncpy(buffer, name, pos);
+ do {
+ if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+ strcpy(&buffer[pos], fd.cFileName);
+ if (add(strdup(buffer)) < 0) {
+ FindClose(hFile);
+ return -1;
+ }
+ first = FALSE;
+ }
+ }
+ while(FindNextFile(hFile, &fd));
+ FindClose(hFile);
+ }
+ }
+ if (first) {
+ if (add(name) < 0)
+ return -1;
+ }
+ else
+ free(name);
+ return 0;
}
-int __getmainargs(int *argc,char ***argv,char ***env,int flag)
+int __getmainargs(int* argc, char*** argv, char*** env, int flag)
{
- int i,afterlastspace;
-
- /* missing threading init */
-
- i=0;
- afterlastspace=0;
-
- while (_acmdln[i])
- {
- if (_acmdln[i]==' ')
- {
- expand(strndup(_acmdln + afterlastspace, i - afterlastspace));
- i++;
- while (_acmdln[i]==' ')
- i++;
- afterlastspace=i;
- }
- else
- {
- i++;
- }
- }
-
- if (_acmdln[afterlastspace] != 0)
- {
- expand(strndup(_acmdln+afterlastspace, i - afterlastspace));
- }
-
- HeapValidate(hHeap,0,NULL);
-
- *argc = __argc;
- *argv = __argv;
- *env = _environ;
-
- _pgmptr = strdup((char *)argv[0]);
-
- return 0;
+ int i, afterlastspace;
+
+ /* missing threading init */
+
+ i = 0;
+ afterlastspace = 0;
+
+ while (_acmdln[i]) {
+ if (_acmdln[i] == ' ') {
+ expand(strndup(_acmdln + afterlastspace, i - afterlastspace));
+ i++;
+ while (_acmdln[i]==' ')
+ i++;
+ afterlastspace=i;
+ } else {
+ i++;
+ }
+ }
+
+ if (_acmdln[afterlastspace] != 0) {
+ expand(strndup(_acmdln+afterlastspace, i - afterlastspace));
+ }
+ HeapValidate(hHeap, 0, NULL);
+ *argc = __argc;
+ *argv = __argv;
+ *env = _environ;
+ _pgmptr = strdup((char*)argv[0]);
+ return 0;
}
-
-int *__p___argc(void)
+int* __p___argc(void)
{
- return &__argc;
+ return &__argc;
}
-char ***__p___argv(void)
+char*** __p___argv(void)
{
- return &__argv;
+ return &__argv;
}
#if 0
int _chkstk(void)
{
- return 0;
+ return 0;
}
#endif
#include <msvcrt/stdlib.h>
-void
-_initterm(void (* fStart[])(void),
- void (* fEnd[])(void))
+void _initterm(void (*fStart[])(void), void (*fEnd[])(void))
{
int i = 0;
typedef int (* _onexit_t)(void);
-_onexit_t
-__dllonexit(_onexit_t func,
- void (** fStart[])(void),
- void (** fEnd[])(void))
+_onexit_t __dllonexit(_onexit_t func, void (** fStart[])(void), void (** fEnd[])(void))
{
}
-_onexit_t
-_onexit(_onexit_t x)
+_onexit_t _onexit(_onexit_t x)
{
- return x;
+ return x;
}
void _purecall(void)
{
- _amsg_exit(_RT_PUREVIRT);
+ _amsg_exit(_RT_PUREVIRT);
}
/* tls.c */
#include <windows.h>
+#include <msvcrt/stdlib.h>
#include <msvcrt/internal/tls.h>
#include <msvcrt/internal/rterror.h>
-; $Id: msvcrt.def,v 1.15 2001/10/03 02:15:55 ekohl Exp $
+; $Id: msvcrt.def,v 1.16 2002/11/24 18:42:20 robd Exp $
;
; ReactOS MSVCRT Compatibility Library
;
fgetpos
fgets
fgetwc
-; fgetws
+fgetws
floor
fmod
fopen
fputc
fputs
fputwc
-; fputws
+fputws
fread
free
freopen
getenv
gets
getwc
-; getwchar
+getwchar
gmtime
is_wctype
isalnum
longjmp
malloc
mblen
-; mbstowcs
-; mbtowc
+mbstowcs
+mbtowc
memchr
memcmp
memcpy
wcstod
wcstok
wcstol
-; wcstombs
+wcstombs
wcstoul
wcsxfrm
-; wctomb
+wctomb
wprintf
wscanf
DWORD ExitCode;
nAction = 0;
- if (WaitForSingleObject((void *)hProc,INFINITE) != WAIT_OBJECT_0)
- {
+ if (WaitForSingleObject((void *)hProc,INFINITE) != WAIT_OBJECT_0) {
__set_errno(ECHILD);
return -1;
}
-/* $Id: _system.c,v 1.4 2002/09/08 10:22:53 chorns Exp $
+/* $Id: _system.c,v 1.5 2002/11/24 18:42:23 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
// system should return 0 if command is null and the shell is found
- if (command == NULL)
- {
+ if (command == NULL) {
if (szComSpec == NULL)
return 0;
else
char *char_base = (char *)base;
int i;
- for (i=0;i<*nelp;i++)
- {
+ for (i = 0; i < *nelp; i++) {
if (compar(key,char_base) == 0)
return char_base;
char_base += width;
if (ret_find != NULL)
return ret_find;
+#ifdef __GNUC__
memcpy(base + (*nelp*width), key, width);
+#else
+ memcpy((int*)base + (*nelp*width), key, width);
+#endif
(*nelp)++;
return base;
}
//push ebp generated by the compiler
//mov ebp, esp
+#ifdef __GNUC__
__asm__ __volatile__ (
"movl 8(%ebp),%edi\n\t" /* get jmp_buf */
"movl 12(%ebp),%eax\n\t" /* store retval in j->eax */
"iret\n\t" /* actually jump to new cs:eip loading flags */
);
+#else
+#endif /*__GNUC__*/
return value; // dummy return never reached
}
+#ifdef __GNUC__
int _setjmp( jmp_buf env )
{
//push ebp generated by the compiler
//mov ebp, esp
-
__asm__ __volatile__ (
"pushl %edi\n\t"
"movl 8(%ebp),%edi\n\t"
"popl %edi\n\t"
);
-
return 0;
}
+
+#else
+#endif /*__GNUC__*/
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
-FILE * __alloc_file(void);
+FILE* __alloc_file(void);
-FILE *_fdopen(int handle, char *mode)
+
+FILE* _fdopen(int handle, char* mode)
{
- FILE *file;
+ FILE* file;
int rw;
if (handle == 0)
return file;
}
-
-FILE *_wfdopen(int handle, wchar_t *mode)
-{
- FILE *file;
- int rw;
-
- if (handle == 0)
- return stdin;
-
- if (handle == 1)
- return stdout;
-
- if (handle == 2)
- return stderr;
-
- if (handle == 3)
- return stdaux;
-
- if (handle == 4)
- return stdprn;
-
- file = __alloc_file();
- if (file == NULL)
- return NULL;
- file->_file = handle;
-
- rw = (mode[1] == L'+') || (mode[1] && (mode[2] == L'+'));
-
- if (*mode == L'a')
- _lseek(handle, 0, SEEK_END);
-
- file->_cnt = 0;
- file->_file = handle;
- file->_bufsiz = 0;
-
-// The mode of the stream must be compatible with the mode of the file descriptor.
-// this should be checked.
-
- if (rw)
- file->_flag = _IOREAD | _IOWRT;
- else if (*mode == L'r')
- file->_flag = _IOREAD;
- else
- file->_flag = _IOWRT;
-
- file->_base = file->_ptr = NULL;
-
- return file;
-}
int ferror(FILE *stream);
#endif
+//int *_errno(void)
+//{
+// return(&GetThreadData()->terrno);
+//}
+//int __set_errno(int error)
+//{
+// PTHREADDATA ThreadData;
+// ThreadData = GetThreadData();
+// if (ThreadData)
+// ThreadData->terrno = error;
+// return(error);
+//}
+int *_errno(void);
+
int ferror(FILE *stream)
{
- return stream->_flag & _IOERR;
+// return stream->_flag & _IOERR;
+ return *_errno();
}
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/crtdll/stdio/fgetc.c
+ * FILE: lib/msvcrt/stdio/fgetc.c
* PURPOSE: Get a character string from stdin
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
+/* $Id: fgetchar.c,v 1.5 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * fgetchar.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#include <msvcrt/stdio.h>
#include <msvcrt/conio.h>
int _fgetchar(void)
{
- return _getch();
+ return getc(stdin);
}
-int _fgetwchar(void)
+wint_t _fgetwchar(void)
{
- return _getch();
+ return getwc(stdin);
}
+/* $Id: fgets.c,v 1.5 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * fgets.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * 28/12/1998: Appropriated for Reactos
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
-char *
-fgets(char *s, int n, FILE *f)
+
+char* fgets(char* s, int n, FILE* f)
{
- int c=0;
- char *cs;
+ int c = 0;
+ char* cs;
cs = s;
- while (--n>0 && (c = getc(f)) != EOF)
- {
+ while (--n>0 && (c = getc(f)) != EOF) {
*cs++ = c;
if (c == '\n')
break;
--- /dev/null
+/* $Id: fgetws.c,v 1.1 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * fgets.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * 28/12/1998: Appropriated for Reactos
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
+
+
+//#include <msvcrt/ctype.h>
+#ifndef WEOF
+#define WEOF (wchar_t)(0xFFFF)
+#endif
+
+wchar_t* fgetws(wchar_t* s, int n, FILE* f)
+{
+ wchar_t c = 0;
+ wchar_t* cs;
+
+ cs = s;
+ //while (--n > 0 && (c = getwc(f)) != WEOF) {
+ while (n > 0) {
+ c = getwc(f);
+ if (c == WEOF)
+ break;
+ n--;
+ *cs++ = c;
+ if (c == L'\n')
+ break;
+ }
+ if (c == WEOF && cs == s) {
+ return NULL;
+ }
+ *cs++ = L'\0';
+ return s;
+}
}
// convert the carriage return line feed pairs
-
+/*
int _readcnv(int fn, void *buf, size_t siz )
{
char *bufp = (char *)buf;
}
return n + cr;
}
-
+ */
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
+
int cntcr(char *bufp, int bufsiz);
int convert(char *endp, int bufsiz,int n);
int _writecnv(int fn, void *buf, size_t bufsiz);
-int
-_flsbuf(int c, FILE *f)
+
+int _flsbuf(int c, FILE *f)
{
char *base;
int n, rn;
char c1;
int size;
-
-
if (!OPEN4WRITING(f)) {
- __set_errno (EINVAL);
+ __set_errno(EINVAL);
return EOF;
}
-// no file associated with buffer
-// this is a memory stream
-
- if ( fileno(f) == -1 )
+ // no file associated with buffer, this is a memory stream
+ if (fileno(f) == -1) {
return c;
+ }
/* if the buffer is not yet allocated, allocate it */
- if ((base = f->_base) == NULL && (f->_flag & _IONBF) == 0)
- {
+ if ((base = f->_base) == NULL && (f->_flag & _IONBF) == 0) {
size = 4096;
- if ((f->_base = base = malloc (size)) == NULL)
- {
+ if ((f->_base = base = malloc (size)) == NULL) {
f->_flag |= _IONBF;
f->_flag &= ~(_IOFBF|_IOLBF);
- }
- else
- {
+ } else {
f->_flag |= _IOMYBUF;
f->_cnt = f->_bufsiz = size;
f->_ptr = base;
rn = 0;
- if (f == stdout && isatty (fileno (stdout)))
- f->_flag |= _IOLBF;
+ if (f == stdout && isatty (fileno (stdout))) {
+ f->_flag |= _IOLBF;
+ }
}
}
- if (f->_flag & _IOLBF)
- {
+ if (f->_flag & _IOLBF) {
/* in line-buffering mode we get here on each character */
*f->_ptr++ = c;
rn = f->_ptr - base;
- if (c == '\n' || rn >= f->_bufsiz)
- {
+ if (c == '\n' || rn >= f->_bufsiz) {
/* time for real flush */
f->_ptr = base;
f->_cnt = 0;
- }
- else
- {
+ } else {
/* we got here because _cnt is wrong, so fix it */
- /* Negative _cnt causes all output functions
- to call _flsbuf for each character, thus realizing line-buffering */
+ /* Negative _cnt causes all output functions to call */
+ /* _flsbuf for each character, thus realizing line-buffering */
f->_cnt = -rn;
return c;
}
- }
- else if (f->_flag & _IONBF)
- {
+ } else if (f->_flag & _IONBF) {
c1 = c;
rn = 1;
base = &c1;
f->_cnt = 0;
- }
- else /* _IOFBF */
- {
+ } else { /* _IOFBF */
rn = f->_ptr - base;
f->_ptr = base;
if ( (f->_flag & _IOAHEAD) == _IOAHEAD )
f->_cnt = f->_bufsiz;
f->_flag &= ~_IOAHEAD;
}
-
-
-
f->_flag &= ~_IODIRTY;
- while (rn > 0)
- {
+ while (rn > 0) {
n = _write(fileno(f), base, rn);
- if (n <= 0)
- {
+ if (n <= 0) {
f->_flag |= _IOERR;
return EOF;
}
rn -= n;
base += n;
}
-
-
- if ((f->_flag&(_IOLBF|_IONBF)) == 0)
- {
+ if ((f->_flag&(_IOLBF|_IONBF)) == 0) {
f->_cnt--;
*f->_ptr++ = c;
}
return c;
}
-wint_t _flswbuf(wchar_t c,FILE *fp)
+wint_t _flswbuf(wchar_t c, FILE *fp)
{
- return (wint_t )_flsbuf((int)c,fp);
-}
+ int result;
+ result = _flsbuf((int)c, fp);
+ if (result == EOF)
+ return WEOF;
+ return (wint_t)result;
+}
int _writecnv(int fn, void *buf, size_t siz)
{
- char *bufp = (char *)buf;
+ char *bufp = (char*)buf;
int bufsiz = siz;
-
- char *tmp;
+ char *tmp;
int cr1 = 0;
int cr2 = 0;
-
int n;
-
cr1 = cntcr(bufp,bufsiz);
-
tmp = malloc(cr1);
memcpy(tmp,bufp+bufsiz-cr1,cr1);
cr2 = cntcr(tmp,cr1);
-
convert(bufp,bufsiz-cr2,cr1-cr2);
n = _write(fn, bufp, bufsiz + cr1);
-
convert(tmp,cr1,cr2);
n += _write(fn, tmp, cr1 + cr2);
free(tmp);
return n;
-
-
}
int convert(char *endp, int bufsiz,int n)
{
endp = endp + bufsiz + n;
while (bufsiz > 0) {
- *endp = *(endp - n);
+ *endp = *(endp - n);
if (*endp == '\n') {
*endp--;
n--;
}
return n;
}
+
int cntcr(char *bufp, int bufsiz)
{
- int cr = 0;
+ int cr = 0;
+
while (bufsiz > 0) {
- if (*bufp == '\n')
+ if (*bufp == '\n') {
cr++;
+ }
bufp++;
bufsiz--;
}
-
return cr;
}
+/* $Id: fopen.c,v 1.7 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * fopen.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * 28/12/1998: Appropriated for Reactos
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/sys/types.h>
#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
//#include <msvcrt/internal/file.h>
#undef _fmode
extern unsigned int _fmode;
-FILE * __alloc_file(void);
+FILE* __alloc_file(void);
+
+//extern int _fmode;
FILE* fopen(const char *file, const char *mode)
{
FILE *f;
int fd, rw, oflags = 0;
- char tbchar;
if (file == 0)
return 0;
if (f == NULL)
return NULL;
- rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+'));
-
- switch (*mode)
- {
- case 'a':
+ rw = (strchr(mode, '+') == NULL) ? 0 : 1;
+ if (strchr(mode, 'a'))
oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
- break;
- case 'r':
+ if (strchr(mode, 'r'))
oflags = rw ? O_RDWR : O_RDONLY;
- break;
- case 'w':
+ if (strchr(mode, 'w'))
oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
- break;
- default:
- return (NULL);
- }
- if (mode[1] == '+')
- tbchar = mode[2];
- else
- tbchar = mode[1];
- if (tbchar == 't')
+ if (strchr(mode, 't'))
oflags |= O_TEXT;
- else if (tbchar == 'b')
+ else if (strchr(mode, 'b'))
oflags |= O_BINARY;
else
oflags |= (_fmode & (O_TEXT|O_BINARY));
if (fd < 0)
return NULL;
-// ms crtdll ensures that writes will end up at the end of file in append mode
+// msvcrt ensures that writes will end up at the end of file in append mode
// we just move the file pointer to the end of file initially
- if (*mode == 'a')
+
+ if (strchr(mode, 'a'))
lseek(fd, 0, SEEK_END);
f->_cnt = 0;
f->_bufsiz = 0;
if (rw)
f->_flag = _IOREAD | _IOWRT;
- else if (*mode == 'r')
+ else if (strchr(mode, 'r'))
f->_flag = _IOREAD;
else
f->_flag = _IOWRT;
+ if (strchr(mode, 't'))
+ f->_flag |= _IOTEXT;
+ else if (strchr(mode, 'b'))
+ f->_flag |= _IOBINARY;
+ else if (_fmode & O_BINARY)
+ f->_flag |= _IOBINARY;
+
f->_base = f->_ptr = NULL;
return f;
}
{
FILE *f;
int fd, rw, oflags = 0;
- wchar_t tbchar;
if (file == 0)
return 0;
if (f == NULL)
return NULL;
- rw = (mode[1] == L'+') || (mode[1] && (mode[2] == L'+'));
-
- switch (*mode)
- {
- case L'a':
+ rw = (wcschr(mode, L'+') == NULL) ? 0 : 1;
+ if (wcschr(mode, L'a'))
oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
- break;
- case L'r':
+ if (wcschr(mode, L'r'))
oflags = rw ? O_RDWR : O_RDONLY;
- break;
- case L'w':
+ if (wcschr(mode, L'w'))
oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
- break;
- default:
- return (NULL);
- }
- if (mode[1] == L'+')
- tbchar = mode[2];
- else
- tbchar = mode[1];
- if (tbchar == L't')
+ if (wcschr(mode, L't'))
oflags |= O_TEXT;
- else if (tbchar == L'b')
+ else if (wcschr(mode, L'b'))
oflags |= O_BINARY;
else
oflags |= (_fmode & (O_TEXT|O_BINARY));
if (fd < 0)
return NULL;
-// ms crtdll ensures that writes will end up at the end of file in append mode
+// msvcrt ensures that writes will end up at the end of file in append mode
// we just move the file pointer to the end of file initially
- if (*mode == L'a')
+ if (wcschr(mode, 'a'))
lseek(fd, 0, SEEK_END);
f->_cnt = 0;
f->_bufsiz = 0;
if (rw)
f->_flag = _IOREAD | _IOWRT;
- else if (*mode == L'r')
+ else if (wcschr(mode, L'r'))
f->_flag = _IOREAD;
else
f->_flag = _IOWRT;
+ if (wcschr(mode, L't'))
+ f->_flag |= _IOTEXT;
+ else if (wcschr(mode, L'b'))
+ f->_flag |= _IOBINARY;
+ else if (_fmode & O_BINARY)
+ f->_flag |= _IOBINARY;
+
f->_base = f->_ptr = NULL;
return f;
}
+/* $Id: fputchar.c,v 1.4 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * fputchar.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#include <msvcrt/stdio.h>
-#include <msvcrt/conio.h>
int _fputchar(int c)
{
- return _putch(c);
+ return putc(c, stdout);
}
int _fputwchar(wchar_t c)
{
- //return _putch(c);
- return 0;
+ return putwc(c, stdout);
}
+/* $Id: fputs.c,v 1.5 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * fputs.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * 28/12/1998: Appropriated for Reactos
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+
#include <windows.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
return(r);
}
+
+int
+fputws(const wchar_t* s, FILE* f)
+{
+ int r = 0;
+ int unbuffered;
+ wchar_t c;
+ wchar_t localbuf[BUFSIZ];
+
+ unbuffered = f->_flag & _IONBF;
+ if (unbuffered)
+ {
+ f->_flag &= ~_IONBF;
+ f->_ptr = f->_base = localbuf;
+ f->_bufsiz = BUFSIZ;
+ }
+
+ while ((c = *s++))
+ r = putwc(c, f);
+
+ if (unbuffered)
+ {
+ fflush(f);
+ f->_flag |= _IONBF;
+ f->_base = NULL;
+ f->_bufsiz = 0;
+ f->_cnt = 0;
+ }
+ return(r);
+}
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/crtdll/conio/kbhit.c
+ * FILE: lib/msvcrt/stdio/fsopen.c
* PURPOSE: Checks for keyboard hits
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
if (fd < 0)
return NULL;
-// ms crtdll ensures that writes will end up at the end of file in append mode
+// msvcrt ensures that writes will end up at the end of file in append mode
// we just move the file pointer to the end of file initially
if (*mode == 'a')
lseek(fd, 0, SEEK_END);
if (fd < 0)
return NULL;
-// ms crtdll ensures that writes will end up at the end of file in append mode
+// msvcrt ensures that writes will end up at the end of file in append mode
// we just move the file pointer to the end of file initially
if (*mode == L'a')
lseek(fd, 0, SEEK_END);
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
-// not exported by msvcrt
+
+// not exported by msvcrt or crtdll
__file_rec *__file_rec_list;
-void
-_fwalk(void (*func)(FILE *))
+void _fwalk(void (*func)(FILE *))
{
__file_rec *fr;
int i;
+/* $Id: getc.c,v 1.5 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * getc.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#include <windows.h>
#include <msvcrt/stdio.h>
#include <msvcrt/wchar.h>
//getc can be a macro
#undef getc
+#undef getwc
+
+#ifndef MB_CUR_MAX
+#define MB_CUR_MAX 10
+#endif
int getc(FILE *fp)
{
- int c = -1;
+ int c = -1;
// check for invalid stream
if ( !__validfp (fp) ) {
if ( !OPEN4READING(fp) ) {
__set_errno(EINVAL);
- return -1;
+ return EOF;
}
if(fp->_cnt > 0) {
fp->_cnt--;
c = (int)*fp->_ptr++;
- }
- else {
+ } else {
c = _filbuf(fp);
}
return c;
wint_t getwc(FILE *fp)
{
- int c = -1;
+ wint_t c = -1;
- // check for invalid stream
- if (!__validfp(fp))
- {
- __set_errno(EINVAL);
- return EOF;
+ // check for invalid stream
+ if (!__validfp(fp)) {
+ __set_errno(EINVAL);
+ return WEOF;
}
- // check for read access on stream
- if (!OPEN4READING(fp))
- {
- __set_errno(EINVAL);
- return -1;
+ // check for read access on stream
+//#define OPEN4READING(f) ((((f)->_flag & _IOREAD) == _IOREAD ) )
+ if (!OPEN4READING(fp)) {
+ __set_errno(EINVAL);
+ return WEOF;
}
- // might check on multi bytes if text mode
+ // might check on multi bytes if text mode
+ if (fp->_flag & _IOBINARY) {
- if (fp->_cnt > 0)
- {
- fp->_cnt -= sizeof(wchar_t);
- c = (wint_t )*((wchar_t *)(fp->_ptr))++;
- }
- else
- {
- c = _filwbuf(fp);
- }
- return c;
-}
+ if (fp->_cnt > 0) {
+ fp->_cnt -= sizeof(wchar_t);
+ c = (wint_t)*((wchar_t*)(fp->_ptr))++;
+ } else {
+ c = _filwbuf(fp);
+ }
+
+ } else {
+ BOOL get_bytes = 0;
+ int mb_cnt = 0;
+ int found_cr = 0;
+ //int count;
+ char mbchar[MB_CUR_MAX];
+ do {
+ if (fp->_cnt > 0) {
+ fp->_cnt--;
+ mbchar[mb_cnt] = *fp->_ptr++;
+ } else {
+ mbchar[mb_cnt] = _filbuf(fp);
+ }
+/*
+ // convert cr/lf pairs into a single lf.
+ if (mbchar[mb_cnt] == '\r') {
+ //found_cr = 1;
+ if (fp->_cnt > 0) {
+ fp->_cnt--;
+ mbchar[mb_cnt+1] = *fp->_ptr++;
+ } else {
+ mbchar[mb_cnt+1] = _filbuf(fp);
+ }
+ if (mbchar[mb_cnt+1] == '\n') {
+ mbchar[mb_cnt] = '\n';
+ } else {
+ ++mb_cnt;
+ }
+ }
+ */
+
+ if (isleadbyte(mbchar[mb_cnt])) {
+ get_bytes = 1;
+ } else {
+ get_bytes = 0;
+ }
+
+ if (_ismbblead(mbchar[mb_cnt])) {
+ }
+
+ ++mb_cnt;
+ //}
+ } while (get_bytes);
+
+ // Convert a multibyte character to a corresponding wide character.
+ mb_cnt = mbtowc(&c, mbchar, mb_cnt);
+ if (mb_cnt == -1) {
+ fp->_flag |= _IOERR;
+ return WEOF;
+ }
+ }
+ return c;
+}
+// MultiByteToWideChar
+// WideCharToMultiByte
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+/* $Id: getchar.c,v 1.4 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * getchar.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * 28/12/1998: Appropriated for Reactos
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
#undef getchar
+#undef getwchar
+
int
getchar(void)
{
return getc(stdin);
}
+
+wint_t
+getwchar(void)
+{
+ return getwc(stdin);
+}
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/crtdll/stdio/gets.c
- * PURPOSE: Get a character string from stdin
- * PROGRAMER: DJ Delorie
- * UPDATE HISTORY:
- * 28/12/98: Appropriated for Reactos
+/* $Id: gets.c,v 1.4 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * gets.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ * 28/12/1998: Appropriated for Reactos
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+
#include <msvcrt/stdio.h>
-char *gets(char *s)
+char* gets(char* s)
{
- int c;
- char *cs;
+ int c;
+ char* cs;
+
+ cs = s;
+ while ((c = getc(stdin)) != '\n' && c != EOF)
+ *cs++ = c;
+ if (c == EOF && cs == s)
+ return NULL;
+ *cs++ = '\0';
+ return s;
+}
- cs = s;
- while ((c = getchar()) != '\n' && c != EOF)
- *cs++ = c;
- if (c == EOF && cs==s)
- return NULL;
- *cs++ = '\0';
- return s;
+#ifndef WEOF
+#define WEOF (wchar_t)(0xFFFF)
+#endif
+
+// Get a line from the stdin stream.
+wchar_t* _getws(wchar_t* s)
+{
+ wchar_t c;
+ wchar_t* cs;
+
+ cs = s;
+ while ((c = getwc(stdin)) != L'\n' && c != WEOF)
+ *cs++ = c;
+ if (c == WEOF && cs == s)
+ return NULL;
+ *cs++ = L'\0';
+ return s;
}
#if 0
#include <msvcrt/stdio.h>
+
/* Read a word (int) from STREAM. */
int _getw(FILE *stream)
{
int w;
/* Is there a better way? */
- if (fread( &w, sizeof(w), 1, stream) != 1)
+ if (fread( &w, sizeof(w), 1, stream) != 1) {
+ // EOF is a legitimate integer value so users must
+ // check feof or ferror to verify an EOF return.
return(EOF);
+ }
return(w);
}
+
+/* $Id: putc.c,v 1.5 2002/11/24 18:42:24 robd Exp $
+ *
+ * ReactOS msvcrt library
+ *
+ * putc.c
+ *
+ * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
+ *
+ * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+
#include <windows.h>
#include <msvcrt/stdio.h>
#include <msvcrt/wchar.h>
// putc can be a macro
#undef putc
+#undef putwc
+
+#ifndef MB_CUR_MAX_CONST
+#define MB_CUR_MAX_CONST 10
+#endif
int putc(int c, FILE *fp)
{
-
-// valid stream macro should check that fp
-// is dword aligned
- if (!__validfp (fp)) {
- __set_errno(EINVAL);
- return -1;
- }
-// check for write access on fp
-
- if ( !OPEN4WRITING(fp) ) {
- __set_errno(EINVAL);
- return -1;
- }
-
- fp->_flag |= _IODIRTY;
- if (fp->_cnt > 0 ) {
- fp->_cnt--;
- *(fp)->_ptr++ = (unsigned char)c;
- return (int)(unsigned char)c;
- }
- else {
- return _flsbuf((unsigned char)c,fp);
- }
- return EOF;
+ // valid stream macro should check that fp is dword aligned
+ if (!__validfp(fp)) {
+ __set_errno(EINVAL);
+ return EOF;
+ }
+ // check for write access on fp
+ if (!OPEN4WRITING(fp)) {
+ __set_errno(EINVAL);
+ return EOF;
+ }
+ fp->_flag |= _IODIRTY;
+ if (fp->_cnt > 0) {
+ fp->_cnt--;
+ *(fp)->_ptr++ = (unsigned char)c;
+ return (int)(unsigned char)c;
+ } else {
+ return _flsbuf((unsigned char)c, fp);
+ }
+ return EOF;
}
-wint_t putwc(wint_t c, FILE *fp)
+//wint_t putwc(wint_t c, FILE *fp)
+int putwc(wint_t c, FILE *fp)
{
-// valid stream macro should check that fp
-// is dword aligned
- if (!__validfp (fp)) {
- __set_errno(EINVAL);
- return -1;
- }
-// check for write access on fp
-
- if ( !OPEN4WRITING(fp) ) {
- __set_errno(EINVAL);
- return -1;
- }
- // might check on multi bytes if text mode
+ int i;
+ int mb_cnt;
+ char mbchar[MB_CUR_MAX_CONST];
- fp->_flag |= _IODIRTY;
+ // valid stream macro should check that fp is dword aligned
+ if (!__validfp(fp)) {
+ __set_errno(EINVAL);
+ return WEOF;
+ }
+ // check for write access on fp
+ if (!OPEN4WRITING(fp)) {
+ __set_errno(EINVAL);
+ return WEOF;
+ }
+ // might check on multi bytes if text mode
+ if (fp->_flag & _IOBINARY) {
+ //if (1) {
+ fp->_flag |= _IODIRTY;
if (fp->_cnt > 0 ) {
- fp->_cnt-= sizeof(wchar_t);
- *((wchar_t *)(fp->_ptr))++ = c;
- return (wint_t)c;
+ fp->_cnt -= sizeof(wchar_t);
+ //*((wchar_t*)(fp->_ptr))++ = c;
+ *((wchar_t*)(fp->_ptr)) = c;
+ ++((wchar_t*)(fp->_ptr));
+ return (wint_t)c;
+ } else {
+ return _flswbuf(c, fp);
}
- else
- return _flswbuf(c,fp);
-
- return -1;
-
+ } else {
+ // Convert wide character to the corresponding multibyte character.
+ mb_cnt = wctomb(mbchar, (wchar_t)c);
+ if (mb_cnt == -1) {
+ fp->_flag |= _IOERR;
+ return WEOF;
+ }
+ if (mb_cnt > MB_CUR_MAX_CONST) {
+ // BARF();
+ }
+ for (i = 0; i < mb_cnt; i++) {
+ fp->_flag |= _IODIRTY;
+#if 0
+ // convert lf's into a cr/lf pair.
+ if (mbchar[i] == '\n') {
+ if (fp->_cnt > 0) {
+ fp->_cnt--;
+ *(fp)->_ptr++ = (unsigned char)'\r';
+ } else {
+ if (_flsbuf((unsigned char)'\r', fp) == EOF) {
+ return WEOF;
+ }
+ }
+ }
+#endif
+ if (fp->_cnt > 0) {
+ fp->_cnt--;
+ *(fp)->_ptr++ = (unsigned char)mbchar[i];
+ } else {
+ if (_flsbuf((unsigned char)mbchar[i], fp) == EOF) {
+ return WEOF;
+ }
+ }
+ }
+ return c;
+ }
+ return WEOF;
}
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/crtdll/conio/getch.c
+ * FILE: lib/msvcrt/stdio/putchar.c
* PURPOSE: Writes a character to stdout
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
#undef putc
#undef putchar
+#undef putwc
+#undef putwchar
int putchar(int c)
{
#include <msvcrt/string.h>
#undef putchar
-int
-puts(const char *s)
+#undef putwchar
+
+
+int puts(const char *s)
{
-
- int c;
- while ((c = *s++))
- putchar(c);
- return putchar('\n');
+ int c;
+ while ((c = *s++)) {
+ putchar(c);
+ }
+ return putchar('\n');
}
-int
-_putws(const wchar_t *s)
+int _putws(const wchar_t *s)
{
-
- wint_t c;
- while ((c = *s++))
- putwchar(c);
- return putwchar(L'\n');
-
+ wint_t c;
+
+ while ((c = *s++)) {
+ putwchar(c);
+ }
+ return putwchar(L'\n');
}
#include <msvcrt/io.h>
-int rename(const char *old_, const char *new_)
+int rename(const char* old_, const char* new_)
{
- if (old_ == NULL || new_ == NULL)
- return -1;
+ if (old_ == NULL || new_ == NULL)
+ return -1;
- if (!MoveFileA(old_,new_))
- return -1;
+ if (!MoveFileA(old_, new_))
+ return -1;
- return 0;
+ return 0;
}
-
-int _wrename(const wchar_t *old_, const wchar_t *new_)
-{
- if (old_ == NULL || new_ == NULL)
- return -1;
-
- if (!MoveFileW(old_,new_))
- return -1;
-
- return 0;
-}
-
#include <msvcrt/stdlib.h>
-char *_tempnam(const char *dir,const char *prefix )
+char* _tempnam(const char* dir,const char* prefix)
{
- char *TempFileName = malloc(MAX_PATH);
- char *d;
-
- if (dir == NULL)
- d = getenv("TMP");
- else
- d = (char *)dir;
-
- if (GetTempFileNameA(d, prefix, 1, TempFileName) == 0)
- {
- free(TempFileName);
- return NULL;
- }
-
- return TempFileName;
-}
-
-wchar_t *_wtempnam(const wchar_t *dir,const wchar_t *prefix)
-{
- wchar_t *TempFileName = malloc(MAX_PATH);
- wchar_t *d;
-
- if (dir == NULL)
- d = _wgetenv(L"TMP");
- else
- d = (wchar_t *)dir;
-
- if (GetTempFileNameW(d, prefix, 1, TempFileName) == 0)
- {
- free(TempFileName);
- return NULL;
+ char* TempFileName = malloc(MAX_PATH);
+ char* d;
+
+ if (dir == NULL)
+ d = getenv("TMP");
+ else
+ d = (char*)dir;
+
+#ifdef _MSVCRT_LIB_ // TODO: check on difference?
+ if (GetTempFileNameA(d, prefix, 1, TempFileName) == 0) {
+#else// TODO: FIXME: review which is correct
+ if (GetTempFileNameA(d, prefix, 0, TempFileName) == 0) {
+#endif /*_MSVCRT_LIB_*/
+
+ free(TempFileName);
+ return NULL;
}
- return TempFileName;
+ return TempFileName;
}
#include <msvcrt/internal/file.h>
-FILE * __alloc_file(void);
+FILE * __alloc_file(void);
FILE *
tmpfile(void)
// errno = 0;
temp_fd = _open(temp_name, 0, SH_DENYRW);
// if ( errno == ENOENT )
-// break;
+// break;
} while (temp_fd == -1 && (temp_name = tmpnam(0)) != 0);
if (temp_name == 0)
#include <msvcrt/string.h>
-char *tmpnam(char *s)
+char* tmpnam(char* s)
{
- char PathName[MAX_PATH];
- static char static_buf[MAX_PATH];
+ char PathName[MAX_PATH];
+ static char static_buf[MAX_PATH];
- GetTempPathA(MAX_PATH, PathName);
- GetTempFileNameA(PathName, "ARI", 007, static_buf);
- strcpy(s, static_buf);
+ GetTempPathA(MAX_PATH, PathName);
+ GetTempFileNameA(PathName, "ARI", 007, static_buf);
+ strcpy(s,static_buf);
- return s;
-}
-
-wchar_t *_wtmpnam(wchar_t *s)
-{
- wchar_t PathName[MAX_PATH];
- static wchar_t static_buf[MAX_PATH];
-
- GetTempPathW(MAX_PATH, PathName);
- GetTempFileNameW(PathName, L"ARI", 007, static_buf);
- wcscpy(s, static_buf);
-
- return s;
+ return s;
}
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
+
int ungetc(int c, FILE *f)
{
- if (!__validfp (f) || !OPEN4READING(f))
- {
+ if (!__validfp (f) || !OPEN4READING(f)) {
__set_errno (EINVAL);
return EOF;
}
wint_t
ungetwc(wchar_t c, FILE *f)
{
- if (!__validfp (f) || !OPEN4READING(f))
- {
+ if (!__validfp (f) || !OPEN4READING(f)) {
__set_errno(EINVAL);
return EOF;
}
}
-static int do_div(long long *n,int base)
+static int do_div(LONGLONG *n,int base)
{
- int __res = ((unsigned long long) *n) % (unsigned) base;
- *n = ((unsigned long long) *n) / (unsigned) base;
+ int __res = ((ULONGLONG) *n) % (unsigned) base;
+ *n = ((ULONGLONG) *n) / (unsigned) base;
return __res;
}
-static int number(FILE * f, long long num, int base, int size, int precision ,int type)
+static int number(FILE * f, LONGLONG num, int base, int size, int precision ,int type)
{
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int __vfprintf(FILE *f, const char *fmt, va_list args)
{
int len;
- unsigned long long num;
+ ULONGLONG num;
int i, base;
long double _ldouble;
double _double;
}
if (qualifier == 'I')
- num = va_arg(args, unsigned long long);
+ num = va_arg(args, ULONGLONG);
else if (qualifier == 'l')
num = va_arg(args, unsigned long);
else if (qualifier == 'h') {
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <stdarg.h>
+//#include <stdarg.h>
+#include <msvcrt/stdarg.h> // robd
+#include <msvcrt/crttypes.h> // robd
+
#include <msvcrt/errno.h>
#include <limits.h>
#include <msvcrt/ctype.h>
unsigned long int __strtoul_internal (const char *__nptr, char **__endptr, int __base, int __group);
-
-#ifdef __GNUC__
-#define HAVE_LONGLONG
-#define LONGLONG long long
-#else
-#define LONGLONG long
-#endif
+#include <msvcrt/crttypes.h> // robd
+//#ifdef __GNUC__
+//#define HAVE_LONGLONG
+//#define LONGLONG LONGLONG
+//#else
+//#define LONGLONG long
+//#endif
/* Those are flags in the conversion format. */
# define LONG 0x001 /* l: long or double */
-# define LONGDBL 0x002 /* L: long long or long double */
+# define LONGDBL 0x002 /* L: LONGLONG or long double */
# define SHORT 0x004 /* h: short */
# define SUPPRESS 0x008 /* *: suppress assignment */
# define POINTER 0x010 /* weird %p pointer (`fake hex') */
char *old = wp;
wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax;
wp = (char *) malloc (wpmax);
- if (old != NULL)
- {
+ if (old != NULL) {
memcpy (wp, old, wpsize);
free(old);
}
/* Integral holding variables. */
union
{
- long long int q;
- unsigned long long int uq;
+ LONGLONG int q;
+ ULONGLONG int uq;
long int l;
unsigned long int ul;
} num;
break;
case 'q':
case 'L':
- /* double's are long double's, and int's are long long int's. */
+ /* double's are long double's, and int's are LONGLONG int's. */
if (flags & TYPEMOD)
/* Signal illegal format element. */
conv_error ();
if (! number_signed)
{
if (flags & LONGDBL) {
- *ARG (unsigned LONGLONG int *) = num.uq;
+ *ARG (ULONGLONG int *) = num.uq;
}
else if (flags & LONG)
*ARG (unsigned long int *) = num.ul;
static double powten[] =
{
1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L,
+#ifdef __GNUC__
1e512L, 1e512L*1e512L, 1e2048L, 1e4096L
+#else
+ 1e256L, 1e256L, 1e256L, 1e256L
+#endif
};
long double __strtold_internal (const char *s,char **sret, int __group)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <stdarg.h>
+
+//#include <stdarg.h>
+#include <msvcrt/stdarg.h> // robd
+#include <msvcrt/crttypes.h> // robd
+
#include <msvcrt/stdio.h>
#include <msvcrt/malloc.h>
#include <msvcrt/internal/file.h>
}
-static int do_div(long long *n,int base)
+static int do_div(LONGLONG *n,int base)
{
- int __res = ((unsigned long long) *n) % (unsigned) base;
- *n = ((unsigned long long) *n) / (unsigned) base;
+ int __res = ((ULONGLONG) *n) % (unsigned) base;
+ *n = ((ULONGLONG) *n) / (unsigned) base;
return __res;
}
-static int number(FILE * f, long long num, int base, int size, int precision ,int type)
+static int number(FILE * f, LONGLONG num, int base, int size, int precision ,int type)
{
wchar_t c,sign,tmp[66];
const wchar_t *digits=L"0123456789abcdefghijklmnopqrstuvwxyz";
int __vfwprintf(FILE *f, const wchar_t *fmt, va_list args)
{
int len;
- unsigned long long num;
+ ULONGLONG num;
int i, base;
long double _ldouble;
double _double;
}
if (qualifier == L'I')
- num = va_arg(args, unsigned long long);
+ num = va_arg(args, ULONGLONG);
else if (qualifier == L'l')
num = va_arg(args, unsigned long);
else if (qualifier == L'h') {
--- /dev/null
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
+
+FILE* __alloc_file(void);
+
+
+FILE* _wfdopen(int handle, wchar_t* mode)
+{
+ FILE* file;
+ int rw;
+
+ if (handle == 0)
+ return stdin;
+
+ if (handle == 1)
+ return stdout;
+
+ if (handle == 2)
+ return stderr;
+
+ if (handle == 3)
+ return stdaux;
+
+ if (handle == 4)
+ return stdprn;
+
+ file = __alloc_file();
+ if (file == NULL)
+ return NULL;
+ file->_file = handle;
+
+ rw = (mode[1] == L'+') || (mode[1] && (mode[2] == L'+'));
+
+ if (*mode == L'a')
+ _lseek(handle, 0, SEEK_END);
+
+ file->_cnt = 0;
+ file->_file = handle;
+ file->_bufsiz = 0;
+
+// The mode of the stream must be compatible with the mode of the file descriptor.
+// this should be checked.
+
+ if (rw)
+ file->_flag = _IOREAD | _IOWRT;
+ else if (*mode == L'r')
+ file->_flag = _IOREAD;
+ else
+ file->_flag = _IOWRT;
+
+ file->_base = file->_ptr = NULL;
+
+ return file;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+
+
+int _wrename(const wchar_t* old_, const wchar_t* new_)
+{
+ if (old_ == NULL || new_ == NULL)
+ return -1;
+
+ if (!MoveFileW(old_, new_))
+ return -1;
+
+ return 0;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
+
+
+wchar_t* _wtempnam(const wchar_t* dir, const wchar_t* prefix)
+{
+ wchar_t* TempFileName = malloc(MAX_PATH);
+ wchar_t* d;
+
+ if (dir == NULL)
+ d = _wgetenv(L"TMP");
+ else
+ d = (wchar_t*)dir;
+
+ if (GetTempFileNameW(d, prefix, 1, TempFileName) == 0) {
+ free(TempFileName);
+ return NULL;
+ }
+
+ return TempFileName;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/string.h>
+
+
+wchar_t* _wtmpnam(wchar_t* s)
+{
+ wchar_t PathName[MAX_PATH];
+ static wchar_t static_buf[MAX_PATH];
+
+ GetTempPathW(MAX_PATH, PathName);
+ GetTempFileNameW(PathName, L"ARI", 007, static_buf);
+ wcscpy(s, static_buf);
+
+ return s;
+}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/stdlib.h>
+#include <msvcrt/crttypes.h>
int
abs(int j)
#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 )
+char* _fullpath(char* absPath, const char* relPath, size_t maxLength)
{
- wchar_t *lpFilePart;
- if ( GetFullPathNameW(relPath,maxLength,absPath,&lpFilePart) == 0 )
- return NULL;
+ char* lpFilePart;
+
+ if (GetFullPathNameA(relPath,maxLength,absPath,&lpFilePart) == 0)
+ return NULL;
- return absPath;
+ return absPath;
}
* 1998: Added ltoa Boudewijn Dekker
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+
#include <msvcrt/errno.h>
#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
+
-char *
-_itoa(int value, char *string, int radix)
+char* _itoa(int value, char* string, int radix)
{
char tmp[33];
- char *tp = tmp;
+ char* tp = tmp;
int i;
unsigned v;
int sign;
- char *sp;
+ char* sp;
if (radix > 36 || radix <= 1)
{
}
if (string == 0)
- string = (char *)malloc((tp-tmp)+sign+1);
+ string = (char*)malloc((tp-tmp)+sign+1);
sp = string;
if (sign)
return string;
}
-char *
-_ltoa(long value, char *string, int radix)
+char* _ltoa(long value, char* string, int radix)
{
char tmp[33];
- char *tp = tmp;
+ char* tp = tmp;
long i;
unsigned long v;
int sign;
- char *sp;
+ char* sp;
if (radix > 36 || radix <= 1)
{
}
if (string == 0)
- string = (char *)malloc((tp-tmp)+sign+1);
+ string = (char*)malloc((tp-tmp)+sign+1);
sp = string;
if (sign)
return string;
}
-char *
-_ultoa(unsigned long value, char *string, int radix)
+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;
-}
-
-char *
-_i64toa(__int64 value, char *string, int radix)
-{
- char tmp[65];
- 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 *
-_ui64toa(unsigned __int64 value, char *string, int radix)
-{
- char tmp[65];
- char *tp = tmp;
+ char* tp = tmp;
long i;
unsigned long v = value;
- char *sp;
+ char* sp;
if (radix > 36 || radix <= 1)
{
}
if (string == 0)
- string = (char *)malloc((tp-tmp)+1);
+ string = (char*)malloc((tp-tmp)+1);
sp = string;
while (tp > tmp)
-/*
+/* $Id: itow.c,v 1.5 2002/11/24 18:42:25 robd Exp $
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/msvcrt/stdlib/itoa.c
- * PURPOSE: converts a integer to ascii
+ * FILE: lib/msvcrt/stdlib/itow.c
+ * PURPOSE: converts a integer to wchar_t
* PROGRAMER:
* UPDATE HISTORY:
* 1995: Created
* 1998: Added ltoa Boudewijn Dekker
+ * 2000: derived from ./itoa.c by ea
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+
#include <msvcrt/errno.h>
#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.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* _itow(int 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;
+ wchar_t tmp [33];
+ wchar_t * tp = tmp;
+ int i;
+ unsigned int 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+ (wchar_t) '0';
+ } else {
+ *tp++ = i + (wchar_t) 'a' - 10;
+ }
+ }
+
+ if (string == 0) {
+ string = (wchar_t*) malloc((tp-tmp) + (sign + 1) * sizeof(wchar_t));
+ }
+ sp = string;
+
+ if (sign) {
+ *sp++ = (wchar_t) '-';
+ }
+ while (tp > tmp) {
+ *sp++ = *--tp;
+ }
+ *sp = (wchar_t) 0;
+ return string;
}
-wchar_t *
-_i64tow(__int64 value, wchar_t *string, int radix)
+wchar_t* _ltow(long value, wchar_t* string, int radix)
{
- wchar_t tmp[65];
- wchar_t *tp = tmp;
- int i;
- unsigned v;
- int sign;
- wchar_t *sp;
-
- if (radix > 36 || radix <= 1)
- {
- __set_errno(EDOM);
- return 0;
- }
-
- sign = (radix == 10 && value < 0);
- if (sign)
- v = -value;
- else
- v = (unsigned)value;
- while (v || tp == tmp)
- {
- i = v % radix;
- v = v / radix;
- if (i < 10)
- *tp++ = i+L'0';
- else
- *tp++ = i + L'a' - 10;
- }
-
- if (string == 0)
- string = (wchar_t *)malloc(((tp-tmp)+sign+1)*sizeof(wchar_t));
- sp = string;
-
- if (sign)
- *sp++ = L'-';
- while (tp > tmp)
- *sp++ = *--tp;
- *sp = 0;
- return string;
+ wchar_t tmp [33];
+ wchar_t* tp = tmp;
+ long int i;
+ unsigned long int 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 + (wchar_t) '0';
+ } else {
+ *tp++ = i + (wchar_t) 'a' - 10;
+ }
+ }
+
+ if (string == 0) {
+ string = (wchar_t*) malloc((tp - tmp) + (sign + 1) * sizeof(wchar_t));
+ }
+ sp = string;
+
+ if (sign) {
+ *sp++ = (wchar_t) '-';
+ }
+ while (tp > tmp) {
+ *sp++ = *--tp;
+ }
+ *sp = (wchar_t) 0;
+ return string;
}
-wchar_t *
-_ui64tow(unsigned __int64 value, wchar_t *string, int radix)
+wchar_t* _ultow(unsigned long value, wchar_t* string, int radix)
{
- wchar_t tmp[65];
- wchar_t *tp = tmp;
- long i;
- unsigned long v = value;
- wchar_t *sp;
-
- if (radix > 36 || radix <= 1)
- {
- __set_errno(EDOM);
- return 0;
- }
-
- while (v || tp == tmp)
- {
- i = v % radix;
- v = v / radix;
- if (i < 10)
- *tp++ = i+L'0';
- else
- *tp++ = i + L'a' - 10;
- }
-
- if (string == 0)
- string = (wchar_t *)malloc(((tp-tmp)+1)*sizeof(wchar_t));
- sp = string;
-
- while (tp > tmp)
- *sp++ = *--tp;
- *sp = 0;
- return string;
+ wchar_t tmp [33];
+ wchar_t* tp = tmp;
+ long int i;
+ unsigned long int 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 + (wchar_t) '0';
+ } else {
+ *tp++ = i + (wchar_t) 'a' - 10;
+ }
+ }
+
+ if (string == 0) {
+#ifdef _MSVCRT_LIB_ // TODO: check on difference?
+ string = (wchar_t*)malloc(((tp-tmp)+1)*sizeof(wchar_t));
+#else // TODO: FIXME: review which is correct
+ string = (wchar_t*)malloc((tp - tmp) + sizeof(wchar_t));
+#endif /*_MSVCRT_LIB_*/
+ }
+ sp = string;
+
+ while (tp > tmp) {
+ *sp++ = *--tp;
+ }
+ *sp = (wchar_t) 0;
+ return string;
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/stdlib.h>
+#include <msvcrt/crttypes.h>
long
labs(long j)
-/* $Id: makepath.c,v 1.9 2002/09/08 10:22:57 chorns Exp $
+/* $Id: makepath.c,v 1.10 2002/11/24 18:42:25 robd Exp $
*/
#include <msvcrt/stdlib.h>
#include <msvcrt/string.h>
-void _makepath(char *path, const char *drive, const char *dir, const char *fname, const char *ext)
+void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext)
{
- int dir_len;
+ int dir_len;
- if ((drive != NULL) && (*drive))
- {
- strcpy(path, drive);
- strcat(path, ":");
+ if ((drive != NULL) && (*drive)) {
+ strcpy(path, drive);
+ strcat(path, ":");
+ } else {
+ (*path)=0;
}
- else
- (*path)=0;
- if (dir != NULL)
- {
- strcat(path, dir);
- dir_len = strlen(dir);
- if (dir_len && *(dir + dir_len - 1) != '\\')
- strcat(path, "\\");
+ if (dir != NULL) {
+ strcat(path, dir);
+ dir_len = strlen(dir);
+ if (dir_len && *(dir + dir_len - 1) != '\\')
+ strcat(path, "\\");
}
- if (fname != NULL)
- {
- strcat(path, fname);
- if (ext != NULL && *ext != 0)
- {
- if (*ext != '.')
- strcat(path, ".");
- strcat(path, ext);
- }
- }
-}
-
-
-void _wmakepath(wchar_t *path, const wchar_t *drive, const wchar_t *dir, const wchar_t *fname, const wchar_t *ext)
-{
- int dir_len;
-
- if ((drive != NULL) && (*drive))
- {
- wcscpy(path, drive);
- wcscat(path, L":");
- }
- else
- (*path)=0;
-
- if (dir != NULL)
- {
- wcscat(path, dir);
- dir_len = wcslen(dir);
- if (dir_len && *(dir + dir_len - 1) != L'\\')
- wcscat(path, L"\\");
- }
-
- if (fname != NULL)
- {
- wcscat(path, fname);
- if (ext != NULL && *ext != 0)
- {
- if (*ext != L'.')
- wcscat(path, L".");
- wcscat(path, ext);
- }
+ if (fname != NULL) {
+ strcat(path, fname);
+ if (ext != NULL && *ext != 0) {
+ if (*ext != '.')
+ strcat(path, ".");
+ strcat(path, ext);
+ }
}
}
+++ /dev/null
-#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;
-}
size_t mbstowcs( wchar_t *wcstr, const char *mbstr, size_t count )
{
- return 0;
+ size_t Size;
+/*
+ NTSTATUS Status;
+ ULONG Size;
+ ULONG Length;
+
+ Length = strlen (mbstr);
+
+ if (wcstr == NULL)
+ {
+ RtlMultiByteToUnicodeSize (&Size,
+ (char *)mbstr,
+ Length);
+
+ return (size_t)Size;
+ }
+
+ Status = RtlMultiByteToUnicodeN (wcstr,
+ count,
+ &Size,
+ (char *)mbstr,
+ Length);
+ if (!NT_SUCCESS(Status))
+ return -1;
+ */
+ return (size_t)Size;
}
-int mbtowc( wchar_t *wchar, const char *mbchar, size_t count )
-{
- return 0;
-}
\ No newline at end of file
+//int mbtowc( wchar_t *wchar, const char *mbchar, size_t count )
+//{
+// return 0;
+//}
--- /dev/null
+#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)
+int mbtowc(wchar_t *wchar, const char *mbchar, size_t count)
+{
+ *wchar = (wchar_t)*mbchar;
+ return 1;
+
+ // WideCharToMultiByte
+ // MultiByteToWideChar
+/*
+int MultiByteToWideChar(
+ UINT CodePage, // code page
+ DWORD dwFlags, // character-type options
+ LPCSTR lpMultiByteStr, // string to map
+ int cbMultiByte, // number of bytes in string
+ LPWSTR lpWideCharStr, // wide-character buffer
+ int cchWideChar // size of buffer
+);
+ */
+/*
+ NTSTATUS Status;
+ ULONG Size;
+
+ if (wchar == NULL)
+ return 0;
+
+ Status = RtlMultiByteToUnicodeN (wchar,
+ sizeof(WCHAR),
+ &Size,
+ (char *)mbchar,
+ count);
+ if (!NT_SUCCESS(Status))
+ return -1;
+
+ return (int)Size;
+ */
+}
unsigned char _cpumode = 0;
unsigned char *_cpumode_dll = &_cpumode;
+WINBOOL STDCALL Beep(DWORD dwFreq, DWORD dwDuration);
+VOID STDCALL Sleep(DWORD dwMilliseconds);
+UINT STDCALL SetErrorMode(UINT uMode);
+
void _seterrormode(int nMode)
{
SetErrorMode(nMode);
{
PTHREADDATA ThreadData = GetThreadData();
+#ifdef HAVE_LONGLONG
ThreadData->tnext = ThreadData->tnext * 0x5deece66dLL + 11;
+#else
+ ThreadData->tnext = ThreadData->tnext * 0x5deece66dL + 11;
+#endif
return (int)((ThreadData->tnext >> 16) & RAND_MAX);
}
{
PTHREADDATA ThreadData = GetThreadData();
- ThreadData->tnext = (unsigned long long)seed;
+ ThreadData->tnext = (ULONGLONG)seed;
}
*/
#include <msvcrt/stdlib.h>
+#include <msvcrt/crttypes.h>
unsigned int _rotl( unsigned int value, int shift )
{
if ( shift > max_bits )
shift = shift % max_bits;
return (value >> shift) | (value << (max_bits-shift));
-}
\ No newline at end of file
+}
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
-void _searchenv(const char *file,const char *var,char *path )
-{
- char *env = getenv(var);
- char *x;
- char *y;
- char *FilePart;
-
- DPRINT("_searchenv()\n");
- 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)
+void _searchenv(const char* file,const char* var,char* path)
{
- wchar_t *env = _wgetenv(var);
- wchar_t *x;
- wchar_t *y;
- wchar_t *FilePart;
+ char* env = getenv(var);
+ char* x;
+ char* y;
+ char* FilePart;
+
+ DPRINT("_searchenv()\n");
- DPRINT("_searchenw()\n");
- x = wcschr(env,L'=');
- if ( x != NULL ) {
- *x = 0;
- x++;
- }
- y = wcschr(env,L';');
- while ( y != NULL ) {
- *y = 0;
- if ( SearchPathW(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) {
- return;
- }
- x = y+1;
- y = wcschr(env,L';');
- }
- return;
+ 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;
}
#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;
- tmp_ext = (char *)path+strlen(path);
- }
- 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);
- *(fname+(tmp_ext-path))=0;
- }
-}
-void _wsplitpath( const wchar_t *path, wchar_t *drive, wchar_t *dir, wchar_t *fname, wchar_t *ext )
+void _splitpath(const char* path, char* drive, char* dir, char* fname, char* 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;
- tmp_ext = (wchar_t *)path+wcslen(path);
- }
-
- 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);
- *(fname+(tmp_ext-path))=0;
- }
+ 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;
+ tmp_ext = (char*)path+strlen(path);
+ }
+ 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);
+ *(fname+(tmp_ext-path))=0;
+ }
}
static double powten[] =
{
- 1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L
+ 1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L,
+#ifdef __GNUC__
1e512L, 1e512L*1e512L, 1e2048L, 1e4096L
+#else
+ 1e256L, 1e256L, 1e256L, 1e256L
+#endif
};
long double
static const wchar_t encoding_mask[] =
{
- ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff
+ (wchar_t)~0x7ff, (wchar_t)~0xffff, (wchar_t)~0x1fffff, (wchar_t)~0x3ffffff
};
static const unsigned char encoding_byte[] =
/* 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;
+typedef int mbstate_t;
+static mbstate_t mbstate_internal;
-extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */
+mbstate_t __no_r_state; /* Now defined in wcstombs.c. */
+//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */
size_t
__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps);
const wchar_t *run = *src;
if (ps == NULL)
- ps = &internal;
+ ps = &mbstate_internal;
if (dst == NULL)
/* The LEN parameter has to be ignored if we don't actually write
return written;
}
-//weak_alias (__wcsrtombs, wcsrtombs)
\ No newline at end of file
+//weak_alias (__wcsrtombs, wcsrtombs)
--- /dev/null
+/* 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 <msvcrt/stdlib.h>
+#include <msvcrt/wchar.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
+#ifndef EILSEQ
+#define EILSEQ EINVAL
+#endif
+
+static const wchar_t encoding_mask[] =
+{
+ /* This reflects the sources *nix origin where type wchar_t
+ was 32 bits wide. Since our type wchar_t is only 16 bits
+ wide all this module will need to be reviewed.
+ Simplest option may well be to forward this modules work
+ on to the kernel which already has support for this.
+ */
+ ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff
+ //~0x0000-07ff, ~0x0000-ffff, ~0x001f-ffff, ~0x03ff-ffff
+};
+
+static const unsigned char encoding_byte[] =
+{
+ 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
+};
+
+/* The state is for this UTF8 encoding not used. */
+//static mbstate_t internal;
+//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */
+
+size_t __wcrtomb(char *s, wchar_t wc);
+
+/* Convert WCHAR into its multibyte character representation,
+ putting this in S and returning its length.
+
+ Attention: this function should NEVER be intentionally used.
+ The interface is completely stupid. The state is shared between
+ all conversion functions. You should use instead the restartable
+ version `wcrtomb'. */
+
+int wctomb(char *s, wchar_t wchar)
+{
+ /* If S is NULL the function has to return null or not null
+ depending on the encoding having a state depending encoding or
+ not. This is nonsense because any multibyte encoding has a
+ state. The ISO C amendment 1 corrects this while introducing the
+ restartable functions. We simply say here all encodings have a
+ state. */
+ if (s == NULL) {
+ return 1;
+ }
+ return __wcrtomb(s, wchar);
+}
+
+size_t __wcrtomb(char *s, wchar_t wc)
+{
+ char fake[1];
+ size_t written = 0;
+
+ if (s == NULL) {
+ s = fake;
+ wc = L'\0';
+ }
+ /* Store the UTF8 representation of WC. */
+ //if (wc < 0 || wc > 0x7fffffff) {
+ if (wc < 0 || wc > 0x7fff) {
+ /* This is no correct ISO 10646 character. */
+ __set_errno (EILSEQ);
+ return (size_t) -1;
+ }
+ if (wc < 0x80) {
+ /* It's a one byte sequence. */
+ if (s != NULL) {
+ *s = (char)wc;
+ }
+ return 1;
+ }
+ for (written = 2; written < 6; ++written) {
+ if ((wc & encoding_mask[written - 2]) == 0) {
+ break;
+ }
+ }
+ if (s != NULL) {
+ size_t cnt = written;
+ s[0] = encoding_byte[cnt - 2];
+ --cnt;
+ do {
+ s[cnt] = 0x80 | (wc & 0x3f);
+ wc >>= 6;
+ } while (--cnt > 0);
+ s[0] |= wc;
+ }
+ return written;
+}
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/stdlib/fullpath.c
+ * PURPOSE: Gets the fullpathname
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+#include <windows.h>
+#include <msvcrt/stdlib.h>
+
+
+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;
+}
--- /dev/null
+/*
+ * 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>
+#include <msvcrt/internal/file.h>
+
+
+char* _i64toa(__int64 value, char* string, int radix)
+{
+ char tmp[65];
+ 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* _ui64toa(unsigned __int64 value, char* string, int radix)
+{
+ char tmp[65];
+ 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;
+}
--- /dev/null
+/* $Id: witow.c,v 1.1 2002/11/24 18:42:25 robd Exp $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/stdlib/itow.c
+ * PURPOSE: converts a integer to wchar_t
+ * PROGRAMER:
+ * UPDATE HISTORY:
+ * 1995: Created
+ * 1998: Added ltoa Boudewijn Dekker
+ * 2000: derived from ./itoa.c by ea
+ */
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+
+#include <msvcrt/errno.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/internal/file.h>
+
+
+wchar_t* _i64tow(__int64 value, wchar_t* string, int radix)
+{
+ wchar_t tmp[65];
+ wchar_t* tp = tmp;
+ int i;
+ unsigned v;
+ int sign;
+ wchar_t* sp;
+
+ if (radix > 36 || radix <= 1)
+ {
+ __set_errno(EDOM);
+ return 0;
+ }
+
+ sign = (radix == 10 && value < 0);
+ if (sign)
+ v = -value;
+ else
+ v = (unsigned)value;
+ while (v || tp == tmp)
+ {
+ i = v % radix;
+ v = v / radix;
+ if (i < 10)
+ *tp++ = i+L'0';
+ else
+ *tp++ = i + L'a' - 10;
+ }
+
+ if (string == 0)
+ string = (wchar_t*)malloc(((tp-tmp)+sign+1)*sizeof(wchar_t));
+ sp = string;
+
+ if (sign)
+ *sp++ = L'-';
+ while (tp > tmp)
+ *sp++ = *--tp;
+ *sp = 0;
+ return string;
+}
+
+wchar_t* _ui64tow(unsigned __int64 value, wchar_t* string, int radix)
+{
+ wchar_t tmp[65];
+ wchar_t* tp = tmp;
+ long i;
+ unsigned long v = value;
+ wchar_t* sp;
+
+ if (radix > 36 || radix <= 1)
+ {
+ __set_errno(EDOM);
+ return 0;
+ }
+
+ while (v || tp == tmp)
+ {
+ i = v % radix;
+ v = v / radix;
+ if (i < 10)
+ *tp++ = i+L'0';
+ else
+ *tp++ = i + L'a' - 10;
+ }
+
+ if (string == 0)
+ string = (wchar_t*)malloc(((tp-tmp)+1)*sizeof(wchar_t));
+ sp = string;
+
+ while (tp > tmp)
+ *sp++ = *--tp;
+ *sp = 0;
+ return string;
+}
--- /dev/null
+/* $Id: wmakpath.c,v 1.1 2002/11/24 18:42:25 robd Exp $
+ */
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+
+
+void _wmakepath(wchar_t* path, const wchar_t* drive, const wchar_t* dir, const wchar_t* fname, const wchar_t* ext)
+{
+ int dir_len;
+
+ if ((drive != NULL) && (*drive)) {
+ wcscpy(path, drive);
+ wcscat(path, L":");
+ } else {
+ (*path) = 0;
+ }
+
+ if (dir != NULL) {
+ wcscat(path, dir);
+ dir_len = wcslen(dir);
+ if (dir_len && *(dir + dir_len - 1) != L'\\')
+ wcscat(path, L"\\");
+ }
+
+ if (fname != NULL) {
+ wcscat(path, fname);
+ if (ext != NULL && *ext != 0) {
+ if (*ext != L'.')
+ wcscat(path, L".");
+ wcscat(path, ext);
+ }
+ }
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+
+void _wsearchenv(const wchar_t* file,const wchar_t* var,wchar_t* path)
+{
+ wchar_t* env = _wgetenv(var);
+ wchar_t* x;
+ wchar_t* y;
+ wchar_t* FilePart;
+
+ DPRINT("_wsearchenv()\n");
+ x = wcschr(env,L'=');
+ if ( x != NULL ) {
+ *x = 0;
+ x++;
+ }
+ y = wcschr(env,L';');
+ while ( y != NULL ) {
+ *y = 0;
+ if ( SearchPathW(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) {
+ return;
+ }
+ x = y+1;
+ y = wcschr(env,L';');
+ }
+ return;
+}
--- /dev/null
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+
+
+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;
+ tmp_ext = (wchar_t*)path+wcslen(path);
+ }
+
+ 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);
+ *(fname+(tmp_ext-path))=0;
+ }
+}
-
#include <msvcrt/ctype.h>
#include <msvcrt/stdlib.h>
-__int64
-_wtoi64(const wchar_t *nptr)
+
+__int64 _wtoi64(const wchar_t* nptr)
{
- wchar_t *s = (wchar_t *)nptr;
- __int64 acc = 0;
- int neg = 0;
+ wchar_t* s = (wchar_t*)nptr;
+ __int64 acc = 0;
+ int neg = 0;
- while(iswspace((int)*s))
- s++;
- if (*s == '-')
- {
- neg = 1;
- s++;
+ while (iswspace((int)*s))
+ s++;
+ if (*s == '-') {
+ neg = 1;
+ s++;
}
- else if (*s == '+')
- s++;
+ else if (*s == '+')
+ s++;
- while (iswdigit((int)*s))
- {
- acc = 10 * acc + ((int)*s - '0');
- s++;
+ while (iswdigit((int)*s)) {
+ acc = 10 * acc + ((int)*s - '0');
+ s++;
}
- if (neg)
- acc *= -1;
- return acc;
+ if (neg)
+ acc *= -1;
+ return acc;
}
/* 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;
+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;
}
#include <msvcrt/string.h>
+
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
void *
#include <msvcrt/string.h>
+
void * memset(void *src,int val,size_t count)
{
char *char_src = (char *)src;
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/string.h>
-char *
-strcat(char *s, const char *append)
+
+char* strcat(char* s, const char* append)
{
- char *save = s;
+ char* save = s;
- for (; *s; ++s);
- while ((*s++ = *append++));
- return save;
+ for (; *s; ++s);
+ while ((*s++ = *append++));
+ return save;
}
/* 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)
less than, equal to or greater than the collated form of S2. */
#if 1
-int strcoll (const char* s1, const char* s2)
+int strcoll(const char* s1, const char* s2)
{
- return strcmp(s1,s2);
+ return strcmp(s1, s2);
}
-int _stricoll (const char* s1, const char* s2)
+int _stricoll(const char* s1, const char* s2)
{
- return _stricmp(s1,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 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;
+ 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
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/string.h>
+#pragma function(strcpy)
char* strcpy(char *to, const char *from)
{
--- /dev/null
+#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. */
+
+
+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);
+}
#include <msvcrt/string.h>
#include <msvcrt/stdlib.h>
+#include <msvcrt/crttypes.h>
char* _strnset (char* szToFill, int szFill, size_t sizeMaxFill)
{
#include <msvcrt/string.h>
#include <msvcrt/internal/tls.h>
-char *strtok(char *s, const char *delim)
+char* strtok(char* s, const char* delim)
{
const char *spanp;
int c, sc;
-/* $Id: fstat.c,v 1.12 2002/09/08 10:22:59 chorns Exp $
+/* $Id: fstat.c,v 1.13 2002/11/24 18:42:25 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
-int _fstat(int fd, struct stat *statbuf)
+
+int _fstat(int fd, struct stat* statbuf)
{
BY_HANDLE_FILE_INFORMATION FileInformation;
DWORD dwFileType;
statbuf->st_mode |= S_IFDIR;
else
statbuf->st_mode |= S_IFREG;
- if (!(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) statbuf->st_mode |= S_IWRITE;
+ if (!(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ statbuf->st_mode |= S_IWRITE;
}
else if (dwFileType == FILE_TYPE_CHAR)
{
}
return 0;
}
-
-__int64 _fstati64 (int fd, struct _stati64* statbuf)
-{
- BY_HANDLE_FILE_INFORMATION FileInformation;
- DWORD dwFileType;
- void *handle;
-
- if (!statbuf)
- {
- __set_errno(EINVAL);
- return -1;
- }
-
- if ((void*)-1 == (handle = _get_osfhandle(fd)))
- {
- __set_errno(EBADF);
- return -1;
- }
-
- fflush(NULL);
-
- memset(statbuf, 0, sizeof(struct _stati64));
-
- dwFileType = GetFileType(handle);
-
- if (dwFileType == FILE_TYPE_DISK)
- {
- if (!GetFileInformationByHandle(handle,&FileInformation))
- {
- __set_errno(EBADF);
- return -1;
- }
- statbuf->st_ctime = FileTimeToUnixTime(&FileInformation.ftCreationTime,NULL);
- statbuf->st_atime = FileTimeToUnixTime(&FileInformation.ftLastAccessTime,NULL);
- statbuf->st_mtime = FileTimeToUnixTime(&FileInformation.ftLastWriteTime,NULL);
-
- statbuf->st_dev = fd;
- statbuf->st_size = (((__int64)FileInformation.nFileSizeHigh) << 32) +
- FileInformation.nFileSizeLow;
- statbuf->st_mode = S_IREAD;
- if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- statbuf->st_mode |= S_IFDIR;
- else
- statbuf->st_mode |= S_IFREG;
- if (!(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) statbuf->st_mode |= S_IWRITE;
- }
- else if (dwFileType == FILE_TYPE_CHAR)
- {
- statbuf->st_dev = fd;
- statbuf->st_mode = S_IFCHR;
- }
- else if (dwFileType == FILE_TYPE_PIPE)
- {
- statbuf->st_dev = fd;
- statbuf->st_mode = S_IFIFO;
- }
- else
- {
- // dwFileType is FILE_TYPE_UNKNOWN or has a bad value
- __set_errno(EBADF);
- return -1;
- }
- return 0;
-}
-
-
--- /dev/null
+/* $Id: fstati64.c,v 1.1 2002/11/24 18:42:25 robd Exp $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/sys/fstat.c
+ * PURPOSE: Gather file information
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+#include <windows.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/sys/stat.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/string.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
+
+__int64 _fstati64(int fd, struct _stati64* statbuf)
+{
+ BY_HANDLE_FILE_INFORMATION FileInformation;
+ DWORD dwFileType;
+ void *handle;
+
+ if (!statbuf)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ if ((void*)-1 == (handle = _get_osfhandle(fd)))
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+
+ fflush(NULL);
+
+ memset(statbuf, 0, sizeof(struct _stati64));
+
+ dwFileType = GetFileType(handle);
+
+ if (dwFileType == FILE_TYPE_DISK)
+ {
+ if (!GetFileInformationByHandle(handle,&FileInformation))
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+ statbuf->st_ctime = FileTimeToUnixTime(&FileInformation.ftCreationTime,NULL);
+ statbuf->st_atime = FileTimeToUnixTime(&FileInformation.ftLastAccessTime,NULL);
+ statbuf->st_mtime = FileTimeToUnixTime(&FileInformation.ftLastWriteTime,NULL);
+
+ statbuf->st_dev = fd;
+ statbuf->st_size = (((__int64)FileInformation.nFileSizeHigh) << 32) +
+ FileInformation.nFileSizeLow;
+ statbuf->st_mode = S_IREAD;
+ if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ statbuf->st_mode |= S_IFDIR;
+ else
+ statbuf->st_mode |= S_IFREG;
+ if (!(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) statbuf->st_mode |= S_IWRITE;
+ }
+ else if (dwFileType == FILE_TYPE_CHAR)
+ {
+ statbuf->st_dev = fd;
+ statbuf->st_mode = S_IFCHR;
+ }
+ else if (dwFileType == FILE_TYPE_PIPE)
+ {
+ statbuf->st_dev = fd;
+ statbuf->st_mode = S_IFIFO;
+ }
+ else
+ {
+ // dwFileType is FILE_TYPE_UNKNOWN or has a bad value
+ __set_errno(EBADF);
+ return -1;
+ }
+ return 0;
+}
FILETIME LastWriteTime;
// check for stdin / stdout handles ??
- if (nHandle == -1)
- {
+ if (nHandle == -1) {
__set_errno(EBADF);
return -1;
- }
+ }
- if (pTimes == NULL)
- {
+ if (pTimes == NULL) {
pTimes = alloca(sizeof(struct _utimbuf));
time(&pTimes->actime);
time(&pTimes->modtime);
- }
+ }
- if (pTimes->actime < pTimes->modtime)
- {
+ if (pTimes->actime < pTimes->modtime) {
__set_errno(EINVAL);
return -1;
- }
+ }
UnixTimeToFileTime(pTimes->actime,&LastAccessTime,0);
UnixTimeToFileTime(pTimes->modtime,&LastWriteTime,0);
- if (!SetFileTime(_get_osfhandle(nHandle),NULL, &LastAccessTime, &LastWriteTime))
- {
+ if (!SetFileTime(_get_osfhandle(nHandle),NULL, &LastAccessTime, &LastWriteTime)) {
__set_errno(EBADF);
return -1;
- }
+ }
return 0;
}
+#include <windows.h>
#include <msvcrt/sys/types.h>
#include <msvcrt/sys/stat.h>
#include <msvcrt/fcntl.h>
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
-
-#include <windows.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
-int _stat(const char *path, struct stat *buffer)
+int _stat(const char* path, struct stat* buffer)
{
HANDLE findHandle;
WIN32_FIND_DATAA findData;
return -1;
}
- if(strchr(path, '*') || strchr(path, '?'))
+ if (strchr(path, '*') || strchr(path, '?'))
{
__set_errno(EINVAL);
return -1;
return 0;
}
-
-__int64 _stati64 (const char *path, struct _stati64 *buffer)
-{
- HANDLE findHandle;
- WIN32_FIND_DATAA findData;
-
- if (!buffer)
- {
- __set_errno(EINVAL);
- return -1;
- }
-
- if(strchr(path, '*') || strchr(path, '?'))
- {
- __set_errno(EINVAL);
- return -1;
- }
-
- findHandle = FindFirstFileA(path, &findData);
- if (findHandle == INVALID_HANDLE_VALUE)
- {
- __set_errno(ENOENT);
- return -1;
- }
-
- FindClose(findHandle);
-
- memset (buffer, 0, sizeof(struct stat));
-
- buffer->st_ctime = FileTimeToUnixTime(&findData.ftCreationTime,NULL);
- buffer->st_atime = FileTimeToUnixTime(&findData.ftLastAccessTime,NULL);
- buffer->st_mtime = FileTimeToUnixTime(&findData.ftLastWriteTime,NULL);
-
-// statbuf->st_dev = fd;
- buffer->st_size = (((__int64)findData.nFileSizeHigh) << 32) +
- findData.nFileSizeLow;
- buffer->st_mode = S_IREAD;
- if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- buffer->st_mode |= S_IFDIR;
- else
- buffer->st_mode |= S_IFREG;
- if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
- buffer->st_mode |= S_IWRITE;
-
- return 0;
-}
-
-int _wstat (const wchar_t *path, struct stat *buffer)
-{
- HANDLE findHandle;
- WIN32_FIND_DATAW findData;
-
- if (!buffer)
- {
- __set_errno(EINVAL);
- return -1;
- }
-
- if(wcschr(path, L'*') || wcschr(path, L'?'))
- {
- __set_errno(EINVAL);
- return -1;
- }
-
- findHandle = FindFirstFileW(path, &findData);
- if (findHandle == INVALID_HANDLE_VALUE)
- {
- __set_errno(ENOENT);
- return -1;
- }
-
- FindClose(findHandle);
-
- memset (buffer, 0, sizeof(struct stat));
-
- buffer->st_ctime = FileTimeToUnixTime(&findData.ftCreationTime,NULL);
- buffer->st_atime = FileTimeToUnixTime(&findData.ftLastAccessTime,NULL);
- buffer->st_mtime = FileTimeToUnixTime(&findData.ftLastWriteTime,NULL);
-
-// statbuf->st_dev = fd;
- buffer->st_size = findData.nFileSizeLow;
- buffer->st_mode = S_IREAD;
- if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- buffer->st_mode |= S_IFDIR;
- else
- buffer->st_mode |= S_IFREG;
- if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
- buffer->st_mode |= S_IWRITE;
-
- return 0;
-}
-
-__int64 _wstati64 (const wchar_t *path, struct _stati64 *buffer)
-{
- HANDLE findHandle;
- WIN32_FIND_DATAW findData;
-
- if (!buffer)
- {
- __set_errno(EINVAL);
- return -1;
- }
-
- if(wcschr(path, L'*') || wcschr(path, L'?'))
- {
- __set_errno(EINVAL);
- return -1;
- }
-
- findHandle = FindFirstFileW(path, &findData);
- if (findHandle == INVALID_HANDLE_VALUE)
- {
- __set_errno(ENOENT);
- return -1;
- }
-
- FindClose(findHandle);
-
- memset (buffer, 0, sizeof(struct stat));
-
- buffer->st_ctime = FileTimeToUnixTime(&findData.ftCreationTime,NULL);
- buffer->st_atime = FileTimeToUnixTime(&findData.ftLastAccessTime,NULL);
- buffer->st_mtime = FileTimeToUnixTime(&findData.ftLastWriteTime,NULL);
-
-// statbuf->st_dev = fd;
- buffer->st_size = (((__int64)findData.nFileSizeHigh) << 32) +
- findData.nFileSizeLow;
- buffer->st_mode = S_IREAD;
- if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- buffer->st_mode |= S_IFDIR;
- else
- buffer->st_mode |= S_IFREG;
- if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
- buffer->st_mode |= S_IWRITE;
-
- return 0;
-}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/sys/types.h>
+#include <msvcrt/sys/stat.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
+
+
+int _wstat (const wchar_t *path, struct stat *buffer)
+{
+ HANDLE findHandle;
+ WIN32_FIND_DATAW findData;
+
+ if (!buffer)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ if(wcschr(path, L'*') || wcschr(path, L'?'))
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ findHandle = FindFirstFileW(path, &findData);
+ if (findHandle == INVALID_HANDLE_VALUE)
+ {
+ __set_errno(ENOENT);
+ return -1;
+ }
+
+ FindClose(findHandle);
+
+ memset (buffer, 0, sizeof(struct stat));
+
+ buffer->st_ctime = FileTimeToUnixTime(&findData.ftCreationTime,NULL);
+ buffer->st_atime = FileTimeToUnixTime(&findData.ftLastAccessTime,NULL);
+ buffer->st_mtime = FileTimeToUnixTime(&findData.ftLastWriteTime,NULL);
+
+// statbuf->st_dev = fd;
+ buffer->st_size = findData.nFileSizeLow;
+ buffer->st_mode = S_IREAD;
+ if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ buffer->st_mode |= S_IFDIR;
+ else
+ buffer->st_mode |= S_IFREG;
+ if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ buffer->st_mode |= S_IWRITE;
+
+ return 0;
+}
+
+__int64 _stati64 (const char *path, struct _stati64 *buffer)
+{
+ HANDLE findHandle;
+ WIN32_FIND_DATAA findData;
+
+ if (!buffer)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ if(strchr(path, '*') || strchr(path, '?'))
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ findHandle = FindFirstFileA(path, &findData);
+ if (findHandle == INVALID_HANDLE_VALUE)
+ {
+ __set_errno(ENOENT);
+ return -1;
+ }
+
+ FindClose(findHandle);
+
+ memset (buffer, 0, sizeof(struct stat));
+
+ buffer->st_ctime = FileTimeToUnixTime(&findData.ftCreationTime,NULL);
+ buffer->st_atime = FileTimeToUnixTime(&findData.ftLastAccessTime,NULL);
+ buffer->st_mtime = FileTimeToUnixTime(&findData.ftLastWriteTime,NULL);
+
+// statbuf->st_dev = fd;
+ buffer->st_size = (((__int64)findData.nFileSizeHigh) << 32) +
+ findData.nFileSizeLow;
+ buffer->st_mode = S_IREAD;
+ if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ buffer->st_mode |= S_IFDIR;
+ else
+ buffer->st_mode |= S_IFREG;
+ if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ buffer->st_mode |= S_IWRITE;
+
+ return 0;
+}
+
+__int64 _wstati64 (const wchar_t *path, struct _stati64 *buffer)
+{
+ HANDLE findHandle;
+ WIN32_FIND_DATAW findData;
+
+ if (!buffer)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ if(wcschr(path, L'*') || wcschr(path, L'?'))
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ findHandle = FindFirstFileW(path, &findData);
+ if (findHandle == INVALID_HANDLE_VALUE)
+ {
+ __set_errno(ENOENT);
+ return -1;
+ }
+
+ FindClose(findHandle);
+
+ memset (buffer, 0, sizeof(struct stat));
+
+ buffer->st_ctime = FileTimeToUnixTime(&findData.ftCreationTime,NULL);
+ buffer->st_atime = FileTimeToUnixTime(&findData.ftLastAccessTime,NULL);
+ buffer->st_mtime = FileTimeToUnixTime(&findData.ftLastWriteTime,NULL);
+
+// statbuf->st_dev = fd;
+ buffer->st_size = (((__int64)findData.nFileSizeHigh) << 32) +
+ findData.nFileSizeLow;
+ buffer->st_mode = S_IREAD;
+ if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ buffer->st_mode |= S_IFDIR;
+ else
+ buffer->st_mode |= S_IFREG;
+ if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ buffer->st_mode |= S_IWRITE;
+
+ return 0;
+}
** (guy@auspex.com).
*/
-
-
-
#include <msvcrt/fcntl.h>
#include <msvcrt/time.h>
#include <msvcrt/string.h>
#include "posixrul.h"
-#define P(s) s
-#define alloc_size_t size_t
-#define qsort_size_t size_t
-#define fread_size_t size_t
-#define fwrite_size_t size_t
+#ifdef __cplusplus
+#define CPP_CONST const
+#else
+#define CPP_CONST
+#endif
+
+#define P(s) s
+#define alloc_size_t size_t
+#define qsort_size_t size_t
+#define fread_size_t size_t
+#define fwrite_size_t size_t
-#define ACCESS_MODE O_RDONLY|O_BINARY
-#define OPEN_MODE O_RDONLY|O_BINARY
+#define ACCESS_MODE O_RDONLY|O_BINARY
+#define OPEN_MODE O_RDONLY|O_BINARY
/*
** Someone might make incorrect use of a time zone abbreviation:
-** 1. They might reference tzname[0] before calling tzset (explicitly
-** or implicitly).
-** 2. They might reference tzname[1] before calling tzset (explicitly
-** or implicitly).
-** 3. They might reference tzname[1] after setting to a time zone
-** in which Daylight Saving Time is never observed.
-** 4. They might reference tzname[0] after setting to a time zone
-** in which Standard Time is never observed.
-** 5. They might reference tm.TM_ZONE after calling offtime.
+** 1. They might reference tzname[0] before calling tzset (explicitly
+** or implicitly).
+** 2. They might reference tzname[1] before calling tzset (explicitly
+** or implicitly).
+** 3. They might reference tzname[1] after setting to a time zone
+** in which Daylight Saving Time is never observed.
+** 4. They might reference tzname[0] after setting to a time zone
+** in which Standard Time is never observed.
+** 5. They might reference tm.TM_ZONE after calling offtime.
** What's best to do in the above cases is open to debate;
** for now, we just set things up so that in any of the five cases
** WILDABBR is used. Another possibility: initialize tzname[0] to the
** manual page of what this "time zone abbreviation" means (doing this so
** that tzname[0] has the "normal" length of three characters).
*/
+
+#ifdef _MSVCRT_LIB_
int _daylight;
int _timezone;
+#else
+int _daylight_dll;
+int _timezone_dll;
+#endif /*_MSVCRT_LIB_*/
static char WILDABBR[] = " ";
#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
+#define TRUE 1
+#define FALSE 0
#endif /* !defined TRUE */
static const char GMT[] = "GMT";
-struct ttinfo { /* time type information */
- long tt_gmtoff; /* GMT offset in seconds */
- int tt_isdst; /* used to set tm_isdst */
- int tt_abbrind; /* abbreviation list index */
- int tt_ttisstd; /* TRUE if transition is std time */
+struct ttinfo { /* time type information */
+ long tt_gmtoff; /* GMT offset in seconds */
+ int tt_isdst; /* used to set tm_isdst */
+ int tt_abbrind; /* abbreviation list index */
+ int tt_ttisstd; /* TRUE if transition is std time */
};
-struct lsinfo { /* leap second information */
- time_t ls_trans; /* transition time */
- long ls_corr; /* correction to apply */
+struct lsinfo { /* leap second information */
+ time_t ls_trans; /* transition time */
+ long ls_corr; /* correction to apply */
};
struct state {
};
struct rule {
- int r_type; /* type of rule--see below */
- int r_day; /* day number of rule */
- int r_week; /* week number of rule */
- int r_mon; /* month number of rule */
- long r_time; /* transition time of rule */
+ int r_type; /* type of rule--see below */
+ int r_day; /* day number of rule */
+ int r_week; /* week number of rule */
+ int r_mon; /* month number of rule */
+ long r_time; /* transition time of rule */
};
-#define JULIAN_DAY 0 /* Jn - Julian day */
-#define DAY_OF_YEAR 1 /* n - day of year */
-#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */
+#define JULIAN_DAY 0 /* Jn - Julian day */
+#define DAY_OF_YEAR 1 /* n - day of year */
+#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */
/*
** Prototypes for static functions.
*/
+#if 0
+static long detzcode P((const char * codep));
+static const char * getzname P((const char * strp));
+static const char * getnum P((const char * strp, int * nump, int min, int max));
+static const char * getsecs P((const char * strp, long * secsp));
+static const char * getoffset P((const char * strp, long * offsetp));
+static const char * getrule P((const char * strp, struct rule * rulep));
+static void gmtload P((struct state * sp));
+static void gmtsub P((const time_t * timep, long offset, struct tm * tmp));
+static void localsub P((const time_t * timep, long offset, struct tm * tmp));
+static void normalize P((int * tensptr, int * unitsptr, int base));
+static void settzname P((void));
+static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset));
+static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset, int * okayp));
+static void timesub P((const time_t * timep, long offset, const struct state * sp, struct tm * tmp));
+static int tmcomp P((const struct tm * atmp, const struct tm * btmp));
+static time_t transtime P((time_t janfirst, int year, const struct rule * rulep, long offset));
+static int tzload P((const char * name, struct state * sp));
+static int tzparse P((const char * name, struct state * sp, int lastditch));
+static void tzsetwall(void);
+
+#else
+
+static const char * getnum(const char * strp, int * CPP_CONST nump, const int min, const int max);
+static void timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp);
+static time_t transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset);
+static void tzsetwall(void);
-static long detzcode P((const char * codep));
-static const char * getzname P((const char * strp));
-static const char * getnum P((const char * strp, int * nump, int min,
- int max));
-static const char * getsecs P((const char * strp, long * secsp));
-static const char * getoffset P((const char * strp, long * offsetp));
-static const char * getrule P((const char * strp, struct rule * rulep));
-static void gmtload P((struct state * sp));
-static void gmtsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static void localsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static void normalize P((int * tensptr, int * unitsptr, int base));
-static void settzname P((void));
-static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * const, const long, struct tm * const),
- long offset));
-static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * const, const long, struct tm * const),
- long offset, int * okayp));
-static void timesub P((const time_t * timep, long offset,
- const struct state * sp, struct tm * tmp));
-static int tmcomp P((const struct tm * atmp,
- const struct tm * btmp));
-static time_t transtime P((time_t janfirst, int year,
- const struct rule * rulep, long offset));
-static int tzload P((const char * name, struct state * sp));
-static int tzparse P((const char * name, struct state * sp,
- int lastditch));
-static void tzsetwall(void);
+#endif
#ifdef ALL_STATE
static struct state *lclptr;
};
static long
-detzcode(const char * const codep)
+detzcode(const char * CPP_CONST codep)
{
long result;
int i;
static void
settzname(void)
{
- const struct state * const sp = lclptr;
+ const struct state * CPP_CONST sp = lclptr;
int i;
_tzname[0] = WILDABBR;
#endif /* defined ALL_STATE */
for (i = 0; i < sp->typecnt; ++i)
{
- register const struct ttinfo * const ttisp = &sp->ttis[i];
+ register const struct ttinfo * CPP_CONST ttisp = &sp->ttis[i];
_tzname[ttisp->tt_isdst] =
(char *)&sp->chars[ttisp->tt_abbrind];
*/
for (i = 0; i < sp->timecnt; ++i)
{
- const struct ttinfo * const ttisp = &sp->ttis[sp->types[i]];
+ const struct ttinfo * CPP_CONST ttisp = &sp->ttis[sp->types[i]];
_tzname[ttisp->tt_isdst] = (char *)&sp->chars[ttisp->tt_abbrind];
}
}
static int
-tzload(const char *name, struct state * const sp)
+tzload(const char *name, struct state * CPP_CONST sp)
{
const char * p;
int i;
return -1;
ttisp->tt_abbrind = (unsigned char) *p++;
if (ttisp->tt_abbrind < 0 ||
- ttisp->tt_abbrind > sp->charcnt)
+ ttisp->tt_abbrind > sp->charcnt)
return -1;
}
for (i = 0; i < sp->charcnt; ++i)
sp->chars[i] = *p++;
- sp->chars[i] = '\0'; /* ensure '\0' at end */
+ sp->chars[i] = '\0'; /* ensure '\0' at end */
for (i = 0; i < sp->leapcnt; ++i)
{
struct lsinfo * lsisp;
{
ttisp->tt_ttisstd = *p++;
if (ttisp->tt_ttisstd != TRUE &&
- ttisp->tt_ttisstd != FALSE)
- return -1;
+ ttisp->tt_ttisstd != FALSE)
+ return -1;
}
}
return 0;
char c;
while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' &&
- c != '+')
+ c != '+')
++strp;
return strp;
}
*/
static const char *
-getnum(const char *strp, int * const nump, const int min, const int max)
+getnum(const char *strp, int * CPP_CONST nump, const int min, const int max)
{
char c;
int num;
*/
static const char *
-getsecs(const char *strp, long * const secsp)
+getsecs(const char *strp, long * CPP_CONST secsp)
{
int num;
++strp;
strp = getnum(strp, &num, 0, SECSPERMIN - 1);
if (strp == NULL)
- return NULL;
+ return NULL;
*secsp += num;
}
}
*/
static const char *
-getoffset(const char *strp, long * const offsetp)
+getoffset(const char *strp, long * CPP_CONST offsetp)
{
int neg;
*/
static const char *
-getrule(const char *strp, struct rule * const rulep)
+getrule(const char *strp, struct rule * CPP_CONST rulep)
{
if (*strp == 'J')
{
strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
}
else
- return NULL; /* invalid format */
+ return NULL; /* invalid format */
if (strp == NULL)
return NULL;
if (*strp == '/')
*/
static time_t
-transtime(const time_t janfirst, const int year, const struct rule * const rulep, const long offset)
+transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset)
{
int leapyear;
time_t value=0;
yy1 = yy0 / 100;
yy2 = yy0 % 100;
dow = ((26 * m1 - 2) / 10 +
- 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
+ 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
if (dow < 0)
dow += DAYSPERWEEK;
for (i = 1; i < rulep->r_week; ++i)
{
if (d + DAYSPERWEEK >=
- mon_lengths[leapyear][rulep->r_mon - 1])
- break;
+ mon_lengths[leapyear][rulep->r_mon - 1])
+ break;
d += DAYSPERWEEK;
}
*/
static int
-tzparse(const char *name, struct state * const sp, const int lastditch)
+tzparse(const char *name, struct state * CPP_CONST sp, const int lastditch)
{
const char * stdname;
const char * dstname=0;
stdname = name;
if (lastditch)
{
- stdlen = strlen(name); /* length of standard zone name */
+ stdlen = strlen(name); /* length of standard zone name */
name += stdlen;
if (stdlen >= sizeof sp->chars)
stdlen = (sizeof sp->chars) - 1;
}
load_result = tzload(TZDEFRULES, sp);
if (load_result != 0)
- sp->leapcnt = 0; /* so, we're off a little */
+ sp->leapcnt = 0; /* so, we're off a little */
if (*name != '\0')
{
dstname = name;
name = getzname(name);
- dstlen = name - dstname; /* length of DST zone name */
+ dstlen = name - dstname; /* length of DST zone name */
if (dstlen < 3)
return -1;
if (*name != '\0' && *name != ',' && *name != ';')
{
name = getoffset(name, &dstoffset);
if (name == NULL)
- return -1;
+ return -1;
}
else
dstoffset = stdoffset - SECSPERHOUR;
++name;
if ((name = getrule(name, &start)) == NULL)
- return -1;
+ return -1;
if (*name++ != ',')
- return -1;
+ return -1;
if ((name = getrule(name, &end)) == NULL)
- return -1;
+ return -1;
if (*name != '\0')
- return -1;
- sp->typecnt = 2; /* standard time and DST */
+ return -1;
+ sp->typecnt = 2; /* standard time and DST */
/*
** Two transitions per year, from EPOCH_YEAR to 2037.
*/
sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
if (sp->timecnt > TZ_MAX_TIMES)
- return -1;
+ return -1;
sp->ttis[0].tt_gmtoff = -dstoffset;
sp->ttis[0].tt_isdst = 1;
sp->ttis[0].tt_abbrind = stdlen + 1;
janfirst = 0;
for (year = EPOCH_YEAR; year <= 2037; ++year)
{
- starttime = transtime(janfirst, year, &start,
- stdoffset);
- endtime = transtime(janfirst, year, &end,
- dstoffset);
- if (starttime > endtime)
- {
- *atp++ = endtime;
- *typep++ = 1; /* DST ends */
- *atp++ = starttime;
- *typep++ = 0; /* DST begins */
- }
- else
- {
- *atp++ = starttime;
- *typep++ = 0; /* DST begins */
- *atp++ = endtime;
- *typep++ = 1; /* DST ends */
- }
- janfirst +=
- year_lengths[isleap(year)] * SECSPERDAY;
+ starttime = transtime(janfirst, year, &start,
+ stdoffset);
+ endtime = transtime(janfirst, year, &end,
+ dstoffset);
+ if (starttime > endtime)
+ {
+ *atp++ = endtime;
+ *typep++ = 1; /* DST ends */
+ *atp++ = starttime;
+ *typep++ = 0; /* DST begins */
+ }
+ else
+ {
+ *atp++ = starttime;
+ *typep++ = 0; /* DST begins */
+ *atp++ = endtime;
+ *typep++ = 1; /* DST ends */
+ }
+ janfirst +=
+ year_lengths[isleap(year)] * SECSPERDAY;
}
}
else
int i;
if (*name != '\0')
- return -1;
+ return -1;
if (load_result != 0)
- return -1;
+ return -1;
/*
** Compute the difference between the real and
** prototype standard and summer time offsets
dstfix = 0;
for (i = 0; i < sp->typecnt; ++i)
{
- if (sp->ttis[i].tt_isdst)
- {
- oldfix = dstfix;
- dstfix =
- sp->ttis[i].tt_gmtoff + dstoffset;
- if (sawdst && (oldfix != dstfix))
- return -1;
- sp->ttis[i].tt_gmtoff = -dstoffset;
- sp->ttis[i].tt_abbrind = stdlen + 1;
- sawdst = TRUE;
- }
- else
- {
- oldfix = stdfix;
- stdfix =
- sp->ttis[i].tt_gmtoff + stdoffset;
- if (sawstd && (oldfix != stdfix))
- return -1;
- sp->ttis[i].tt_gmtoff = -stdoffset;
- sp->ttis[i].tt_abbrind = 0;
- sawstd = TRUE;
- }
+ if (sp->ttis[i].tt_isdst)
+ {
+ oldfix = dstfix;
+ dstfix =
+ sp->ttis[i].tt_gmtoff + dstoffset;
+ if (sawdst && (oldfix != dstfix))
+ return -1;
+ sp->ttis[i].tt_gmtoff = -dstoffset;
+ sp->ttis[i].tt_abbrind = stdlen + 1;
+ sawdst = TRUE;
+ }
+ else
+ {
+ oldfix = stdfix;
+ stdfix =
+ sp->ttis[i].tt_gmtoff + stdoffset;
+ if (sawstd && (oldfix != stdfix))
+ return -1;
+ sp->ttis[i].tt_gmtoff = -stdoffset;
+ sp->ttis[i].tt_abbrind = 0;
+ sawstd = TRUE;
+ }
}
/*
** Make sure we have both standard and summer time.
*/
if (!sawdst || !sawstd)
- return -1;
+ return -1;
/*
** Now correct the transition times by shifting
** them by the difference between the real and
isdst = FALSE; /* we start in standard time */
for (i = 0; i < sp->timecnt; ++i)
{
- const struct ttinfo * ttisp;
-
- /*
- ** If summer time is in effect, and the
- ** transition time was not specified as
- ** standard time, add the summer time
- ** offset to the transition time;
- ** otherwise, add the standard time offset
- ** to the transition time.
- */
- ttisp = &sp->ttis[sp->types[i]];
- sp->ats[i] +=
- (isdst && !ttisp->tt_ttisstd) ?
- dstfix : stdfix;
- isdst = ttisp->tt_isdst;
+ const struct ttinfo * ttisp;
+
+ /*
+ ** If summer time is in effect, and the
+ ** transition time was not specified as
+ ** standard time, add the summer time
+ ** offset to the transition time;
+ ** otherwise, add the standard time offset
+ ** to the transition time.
+ */
+ ttisp = &sp->ttis[sp->types[i]];
+ sp->ats[i] +=
+ (isdst && !ttisp->tt_ttisstd) ?
+ dstfix : stdfix;
+ isdst = ttisp->tt_isdst;
}
}
}
else
{
dstlen = 0;
- sp->typecnt = 1; /* only standard time */
+ sp->typecnt = 1; /* only standard time */
sp->timecnt = 0;
sp->ttis[0].tt_gmtoff = -stdoffset;
sp->ttis[0].tt_isdst = 0;
}
static void
-gmtload(struct state * const sp)
+gmtload(struct state * CPP_CONST sp)
{
if (tzload(GMT, sp) != 0)
(void) tzparse(GMT, sp, TRUE);
lclptr = (struct state *) malloc(sizeof *lclptr);
if (lclptr == NULL)
{
- settzname(); /* all we can do */
+ settzname(); /* all we can do */
return;
}
}
/*
** User wants it fast rather than right.
*/
- lclptr->leapcnt = 0; /* so, we're off a little */
+ lclptr->leapcnt = 0; /* so, we're off a little */
lclptr->timecnt = 0;
lclptr->ttis[0].tt_gmtoff = 0;
lclptr->ttis[0].tt_abbrind = 0;
lclptr = (struct state *) malloc(sizeof *lclptr);
if (lclptr == NULL)
{
- settzname(); /* all we can do */
+ settzname(); /* all we can do */
return;
}
}
/*ARGSUSED*/
static void
-localsub(const time_t * const timep, const long offset, struct tm * const tmp)
+localsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp)
{
const struct state * sp;
const struct ttinfo * ttisp;
while (sp->ttis[i].tt_isdst)
if (++i >= sp->typecnt)
{
- i = 0;
- break;
+ i = 0;
+ break;
}
}
else
{
for (i = 1; i < sp->timecnt; ++i)
if (t < sp->ats[i])
- break;
+ break;
i = sp->types[i - 1];
}
ttisp = &sp->ttis[i];
}
struct tm *
-localtime(const time_t * const timep)
+localtime(const time_t * CPP_CONST timep)
{
static struct tm tm;
*/
static void
-gmtsub(const time_t * const timep, const long offset, struct tm * const tmp)
+gmtsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp)
{
if (!gmt_is_set)
{
}
struct tm *
-gmtime(const time_t * const timep)
+gmtime(const time_t * CPP_CONST timep)
{
static struct tm tm;
}
static void
-timesub(const time_t * const timep, const long offset, const struct state * const sp, struct tm * const tmp)
+timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp)
{
const struct lsinfo * lp;
long days;
if (*timep >= lp->ls_trans)
{
if (*timep == lp->ls_trans)
- hit = ((i == 0 && lp->ls_corr > 0) ||
- lp->ls_corr > sp->lsis[i - 1].ls_corr);
+ hit = ((i == 0 && lp->ls_corr > 0) ||
+ lp->ls_corr > sp->lsis[i - 1].ls_corr);
corr = lp->ls_corr;
break;
}
{
yleap = isleap(y);
if (days < (long) year_lengths[yleap])
- break;
+ break;
++y;
days = days - (long) year_lengths[yleap];
}
static char result[26];
(void) sprintf(result, "%.3s %.3s%3d %02d:%02d:%02d %d\n",
- wday_name[timeptr->tm_wday],
- mon_name[timeptr->tm_mon],
- timeptr->tm_mday, timeptr->tm_hour,
- timeptr->tm_min, timeptr->tm_sec,
- TM_YEAR_BASE + timeptr->tm_year);
+ wday_name[timeptr->tm_wday],
+ mon_name[timeptr->tm_mon],
+ timeptr->tm_mday, timeptr->tm_hour,
+ timeptr->tm_min, timeptr->tm_sec,
+ TM_YEAR_BASE + timeptr->tm_year);
return result;
}
-wchar_t *
-_wasctime(const struct tm *timeptr)
-{
- static const wchar_t wday_name[DAYSPERWEEK][3] = {
- L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat"
- };
- static const wchar_t mon_name[MONSPERYEAR][3] = {
- L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
- L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
- };
- static wchar_t result[26];
-
- (void)swprintf(result, L"%.3s %.3s%3d %02d:%02d:%02d %d\n",
- wday_name[timeptr->tm_wday],
- mon_name[timeptr->tm_mon],
- timeptr->tm_mday, timeptr->tm_hour,
- timeptr->tm_min, timeptr->tm_sec,
- TM_YEAR_BASE + timeptr->tm_year);
- return result;
-}
-
-
char *
-ctime(const time_t * const timep)
+ctime(const time_t * CPP_CONST timep)
{
return asctime(localtime(timep));
}
-wchar_t *
-_wctime(const time_t * const timep)
-{
- return _wasctime(localtime(timep));
-}
-
/*
** Adapted from code provided by Robert Elz, who writes:
-** The "best" way to do mktime I think is based on an idea of Bob
-** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now).
-** It does a binary search of the time_t space. Since time_t's are
-** just 32 bits, its a max of 32 iterations (even at 64 bits it
-** would still be very reasonable).
+** The "best" way to do mktime I think is based on an idea of Bob
+** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now).
+** It does a binary search of the time_t space. Since time_t's are
+** just 32 bits, its a max of 32 iterations (even at 64 bits it
+** would still be very reasonable).
*/
#ifndef WRONG
-#define WRONG (-1)
+#define WRONG (-1)
#endif /* !defined WRONG */
static void
-normalize(int * const tensptr, int * const unitsptr, const int base)
+normalize(int * CPP_CONST tensptr, int * CPP_CONST unitsptr, const int base)
{
if (*unitsptr >= base)
{
}
static int
-tmcomp(const struct tm * const atmp, const struct tm * const btmp)
+tmcomp(const struct tm * CPP_CONST atmp, const struct tm * CPP_CONST btmp)
{
int result;
}
static time_t
-time2(struct tm *tmp, void (*const funcp)(const time_t *const,const long,struct tm *), const long offset, int * const okayp)
+time2(struct tm *tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset, int * CPP_CONST okayp)
{
const struct state * sp;
int dir;
for ( ; ; )
{
i = mon_lengths[isleap(yourtm.tm_year +
- TM_YEAR_BASE)][yourtm.tm_mon];
+ TM_YEAR_BASE)][yourtm.tm_mon];
if (yourtm.tm_mday <= i)
break;
yourtm.tm_mday -= i;
** If time_t is signed, then 0 is the median value,
** if time_t is unsigned, then 1 << bits is median.
*/
+#ifdef _MSVCRT_LIB_
t = (time_t) ((1 << bits) - 1);
+#else // TODO: FIXME: review which is correct
+ t = (time_t) 1 << bits;
+#endif /*_MSVCRT_LIB_*/
+
for ( ; ; )
{
(*funcp)(&t, offset, &mytm);
if (dir != 0)
{
if (bits-- < 0)
- return WRONG;
+ return WRONG;
if (bits < 0)
- --t;
+ --t;
else if (dir > 0)
- t -= (time_t) 1 << bits;
+ t -= (time_t) 1 << bits;
else t += (time_t) 1 << bits;
continue;
}
for (i = 0; i < sp->typecnt; ++i)
{
if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
- continue;
+ continue;
for (j = 0; j < sp->typecnt; ++j)
{
- if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
- continue;
- newt = t + sp->ttis[j].tt_gmtoff -
- sp->ttis[i].tt_gmtoff;
- (*funcp)(&newt, offset, &mytm);
- if (tmcomp(&mytm, &yourtm) != 0)
- continue;
- if (mytm.tm_isdst != yourtm.tm_isdst)
- continue;
- /*
- ** We have a match.
- */
- t = newt;
- goto label;
+ if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
+ continue;
+ newt = t + sp->ttis[j].tt_gmtoff -
+ sp->ttis[i].tt_gmtoff;
+ (*funcp)(&newt, offset, &mytm);
+ if (tmcomp(&mytm, &yourtm) != 0)
+ continue;
+ if (mytm.tm_isdst != yourtm.tm_isdst)
+ continue;
+ /*
+ ** We have a match.
+ */
+ t = newt;
+ goto label;
}
}
return WRONG;
}
static time_t
-time1(struct tm * const tmp, void (*const funcp)(const time_t * const, const long, struct tm *), const long offset)
+time1(struct tm * CPP_CONST tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset)
{
time_t t;
const struct state * sp;
for (otheri = 0; otheri < sp->typecnt; ++otheri)
{
if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
- continue;
+ continue;
tmp->tm_sec += sp->ttis[otheri].tt_gmtoff -
- sp->ttis[samei].tt_gmtoff;
+ sp->ttis[samei].tt_gmtoff;
tmp->tm_isdst = !tmp->tm_isdst;
t = time2(tmp, funcp, offset, &okay);
if (okay)
- return t;
+ return t;
tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff -
- sp->ttis[samei].tt_gmtoff;
+ sp->ttis[samei].tt_gmtoff;
tmp->tm_isdst = !tmp->tm_isdst;
}
}
{
return time1(tmp, localsub, 0L);
}
-
-
-
-
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
-char *_strdate( const char *datestr )
-{
- time_t t;
- struct tm *d;
- char *dt = (char *)datestr;
-
- if ( datestr == NULL )
- {
- __set_errno(EINVAL);
- return NULL;
- }
- t = time(NULL);
- d = localtime(&t);
- sprintf(dt,"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year);
- return dt;
-}
-wchar_t *_wstrdate( const wchar_t *datestr )
+char* _strdate(const char* datestr)
{
- time_t t;
- struct tm *d;
- wchar_t *dt = (wchar_t *)datestr;
+ time_t t;
+ struct tm* d;
+ char* dt = (char*)datestr;
- if ( datestr == NULL )
- {
- __set_errno(EINVAL);
- return NULL;
+ if (datestr == NULL) {
+ __set_errno(EINVAL);
+ return NULL;
}
- t = time(NULL);
- d = localtime(&t);
- swprintf(dt,L"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year);
- return dt;
+ t = time(NULL);
+ d = localtime(&t);
+ sprintf(dt,"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year);
+ return dt;
}
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
-char *_strtime(char* buf)
-{
- time_t t;
- struct tm *d;
- char *dt = (char *)buf;
-
- if ( buf == NULL )
- {
- __set_errno(EINVAL);
- return NULL;
- }
- t = time(NULL);
- d = localtime(&t);
- sprintf(dt,"%d:%d:%d",d->tm_hour,d->tm_min,d->tm_sec);
- return dt;
-}
-wchar_t *_wstrtime(wchar_t* buf)
+char* _strtime(char* buf)
{
- time_t t;
- struct tm *d;
- wchar_t *dt = (wchar_t *)buf;
+ time_t t;
+ struct tm *d;
+ char* dt = (char*)buf;
- if ( buf == NULL )
- {
- __set_errno(EINVAL);
- return NULL;
+ if ( buf == NULL ) {
+ __set_errno(EINVAL);
+ return NULL;
}
- t = time(NULL);
- d = localtime(&t);
- swprintf(dt,L"%d:%d:%d",d->tm_hour,d->tm_min,d->tm_sec);
- return dt;
+ t = time(NULL);
+ d = localtime(&t);
+ sprintf(dt,"%d:%d:%d",d->tm_hour,d->tm_min,d->tm_sec);
+ return dt;
}
--- /dev/null
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+/* This file has been modified by DJ Delorie. These modifications are
+** Copyright (C) 1995 DJ Delorie, 24 Kirsten Ave, Rochester NH,
+** 03867-2954, USA.
+*/
+
+/*
+ * Copyright (c) 1987, 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Arthur David Olson of the National Cancer Institute.
+ *
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement: ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <msvcrt/fcntl.h>
+#include <msvcrt/time.h>
+#include <windows.h>
+#include "tzfile.h"
+
+
+wchar_t* _wasctime(const struct tm* timeptr)
+{
+#ifdef __GNUC__
+ static const wchar_t wday_name[DAYSPERWEEK][3] = {
+ L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat"
+ };
+ static const wchar_t mon_name[MONSPERYEAR][3] = {
+ L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
+ L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
+ };
+#else
+ static const wchar_t wday_name[DAYSPERWEEK][4] = {
+ L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat"
+ };
+ static const wchar_t mon_name[MONSPERYEAR][4] = {
+ L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
+ L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
+ };
+#endif
+ static wchar_t result[26];
+
+ (void)swprintf(result, L"%.3s %.3s%3d %02d:%02d:%02d %d\n",
+ wday_name[timeptr->tm_wday],
+ mon_name[timeptr->tm_mon],
+ timeptr->tm_mday, timeptr->tm_hour,
+ timeptr->tm_min, timeptr->tm_sec,
+ TM_YEAR_BASE + timeptr->tm_year);
+ return result;
+}
+
+
+wchar_t* _wctime(const time_t* const timep)
+{
+ return _wasctime(localtime(timep));
+}
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/time/strtime.c
+ * PURPOSE: Fills a buffer with a formatted date representation
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+#include <msvcrt/time.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
+
+wchar_t* _wstrdate(const wchar_t* datestr)
+{
+ time_t t;
+ struct tm* d;
+ wchar_t* dt = (wchar_t*)datestr;
+
+ if (datestr == NULL) {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+ t = time(NULL);
+ d = localtime(&t);
+ swprintf(dt,L"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year);
+ return dt;
+}
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/time/strtime.c
+ * PURPOSE: Fills a buffer with a formatted time representation
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+#include <msvcrt/time.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
+
+wchar_t* _wstrtime(wchar_t* buf)
+{
+ time_t t;
+ struct tm* d;
+ wchar_t* dt = (wchar_t*)buf;
+
+ if ( buf == NULL ) {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+ t = time(NULL);
+ d = localtime(&t);
+ swprintf(dt,L"%d:%d:%d",d->tm_hour,d->tm_min,d->tm_sec);
+ return dt;
+}
#include <msvcrt/errno.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
-wchar_t *_wcsdup(const wchar_t *ptr)
+wchar_t* _wcsdup(const wchar_t* ptr)
{
- wchar_t *dup;
- dup = malloc((wcslen(ptr) + 1)*sizeof(wchar_t));
- if( dup == NULL ) {
- __set_errno(ENOMEM);
- return NULL;
- }
- wcscpy(dup,ptr);
- return dup;
+ wchar_t* dup;
+
+ dup = malloc((wcslen(ptr) + 1) * sizeof(wchar_t));
+ if (dup == NULL) {
+ __set_errno(ENOMEM);
+ return NULL;
+ }
+ wcscpy(dup, ptr);
+ return dup;
}
}
}
return 0;
-}
\ No newline at end of file
+}