-# $Id: Makefile,v 1.26 2002/11/24 18:42:20 robd Exp $
+# $Id: Makefile,v 1.27 2002/11/25 17:41:39 robd Exp $
PATH_TO_TOP = ../..
stdlib/wfulpath.o \
stdlib/witoa.o \
stdlib/witow.o \
+ stdlib/wputenv.o \
stdlib/wsenv.o \
stdlib/wsplitp.o \
stdlib/wmakpath.o \
#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
-);
+//#define SETFILEPOINTEREX_AVAILABLE
__int64 _lseeki64(int _fildes, __int64 _offset, int _whence)
{
-#if 0
- __int64 new_pos;
- LARGE_INTEGER offset = _offset;
+#ifdef SETFILEPOINTEREX_AVAILABLE
+ LARGE_INTEGER new_pos;
+ LARGE_INTEGER offset;
+ offset.QuadPart = _offset;
// if (invalid_filehnd(_fildes)) {
// errno = EBADF;
//errno = EINVAL;
return -1L;
}
- return new_pos;
+ return new_pos.QuadPart;
#else
- ULONG lo_pos, hi_pos;
- //DWORD lo_pos;
+ //ULONG lo_pos;
+ //DWORD hi_pos = 0; // must equal 0 or -1 if supplied, -1 for negative 32 seek value
+ //lo_pos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, &hi_pos, _whence);
+ //return((((__int64)hi_pos) << 32) + lo_pos);
- 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 );
+ LARGE_INTEGER offset;
+ offset.QuadPart = _offset;
+
+ offset.u.LowPart = SetFilePointer((HANDLE)filehnd(_fildes),
+ offset.u.LowPart, &offset.u.HighPart, _whence);
+ return ((((__int64)offset.u.HighPart) << 32) + offset.u.LowPart);
-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
-);
- */
+#endif /*SETFILEPOINTEREX_AVAILABLE*/
+}
-/* $Id: crtmain.c,v 1.1 2002/11/24 18:42:23 robd Exp $
+/* $Id: crtmain.c,v 1.2 2002/11/25 17:41:39 robd Exp $
*
* ReactOS MSVCRT.DLL Compatibility Library
*/
/* GLOBAL VARIABLES *******************************************************/
int _fltused;
-//int _allmul;
-/* FUNCTIONS **************************************************************/
+/* FUNCTIONS **************************************************************/
-int __cdecl _allmul(void)
+/*
+ */
+int
+STDCALL
+_except_handler3(void)
{
return 0;
}
-int __cdecl _allshl(void)
+int
+STDCALL
+_local_unwind2(void)
{
return 0;
}
-#if 1
-
-void __cdecl _chkesp(int value1, int value2)
-{
-}
-
-#else
-
-int __cdecl _chkesp(int value)
+int
+STDCALL
+_spawnlp(int a, const char* b, const char* args, ...)
{
- return value;
+ return 0;
}
-#endif
+#else /*__GNUC__*/
-int __cdecl _alloca_probe(void)
+int
+_spawnlp(int a, const char* b, const char* args, ...)
{
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);
+#endif /*__GNUC__*/
- result = DllMain(hInst, DLL_PROCESS_ATTACH, lpReserved);
-
- return (result ? 1 : 0);
-}
- */
/*
-int
-STDCALL
-_abnormal_termination(void)
+int __cdecl _allmul(void)
{
return 0;
}
-int
-STDCALL
-_setjmp(void)
+int __cdecl _allshl(void)
{
return 0;
}
- */
-int
-STDCALL
-_except_handler3(void)
+
+void __cdecl _chkesp(int value1, int value2)
{
- return 0;
}
-int
-STDCALL
-_local_unwind2(void)
+int __cdecl _alloca_probe(void)
{
return 0;
}
-int
-STDCALL
-_spawnlp(int a, const char* b, const char* args, ...)
+int STDCALL _abnormal_termination(void)
{
return 0;
}
-#else /*__GNUC__*/
-
-int
-_spawnlp(int a, const char* b, const char* args, ...)
+int STDCALL _setjmp(void)
{
return 0;
}
+*/
+/*
+BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved);
-#endif /*__GNUC__*/
+int STDCALL _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
+{
+ BOOL result;
+ //__fileno_init();
+ //result = DllMain(hInst, ul_reason_for_call, lpReserved);
+
+ result = DllMain(hInst, DLL_PROCESS_ATTACH, lpReserved);
+
+
+ return (result ? 1 : 0);
+}
+ */
/* EOF */
-/* $Id: _system.c,v 1.5 2002/11/24 18:42:23 robd Exp $
+/* $Id: _system.c,v 1.6 2002/11/25 17:41:39 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
#include <msvcrt/string.h>
#include <msvcrt/process.h>
#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
int system(const char *command)
{
__set_errno(0);
_fwalk((void (*)(FILE *))fflush);
- if (_errno)
+ if (errno)
return EOF;
__set_errno(e);
return 0;
/* Integral holding variables. */
union
{
- LONGLONG int q;
- ULONGLONG int uq;
+ LONGLONG q;
+ ULONGLONG uq;
long int l;
unsigned long int ul;
} num;
if (! number_signed)
{
if (flags & LONGDBL) {
- *ARG (ULONGLONG int *) = num.uq;
+ *ARG (ULONGLONG*) = num.uq;
}
else if (flags & LONG)
- *ARG (unsigned long int *) = num.ul;
+ *ARG (unsigned long int*) = num.ul;
else if (flags & SHORT)
- *ARG (unsigned short int *) = (unsigned short int) num.ul;
+ *ARG (unsigned short int*) = (unsigned short int) num.ul;
else
- *ARG (unsigned int *) = (unsigned int) num.ul;
+ *ARG (unsigned int*) = (unsigned int) num.ul;
}
else
{
if (flags & LONGDBL) {
- *ARG (LONGLONG int *) = num.q;
+ *ARG (LONGLONG *) = num.q;
}
else if (flags & LONG)
*ARG (long int *) = num.l;
extern int BlockEnvToEnviron(); // defined in misc/dllmain.c
-int _putenv(const char *val)
+int _putenv(const char* val)
{
- char *buffer;
- char *epos;
- int res;
+ char* buffer;
+ char* epos;
+ int res;
- DPRINT("_putenv('%s')\n", val);
- epos = strchr(val, '=');
- if ( epos == NULL )
- return -1;
- buffer = (char*)malloc(epos - val + 1);
- if (buffer == NULL)
- return -1;
- strncpy(buffer, val, epos - val);
- buffer[epos - val] = 0;
- res = SetEnvironmentVariableA(buffer,epos+1);
- free(buffer);
- if (BlockEnvToEnviron()) return 0;
- return res;
-}
-
-int _wputenv(const wchar_t *val)
-{
- wchar_t *buffer;
- wchar_t *epos;
- int res;
-
- DPRINT("_wputenv('%S')\n", val);
- epos = wcsrchr(val, L'=');
- if ( epos == NULL )
- return -1;
- buffer = (char*)malloc((epos - val + 1) * sizeof (wchar_t));
- if (buffer == NULL)
- return -1;
- wcsncpy(buffer, val, epos - val);
- buffer[epos - val] = 0;
- res = SetEnvironmentVariableW(buffer,epos+1);
- free(buffer);
- if (BlockEnvToEnviron() ) return 0;
- return res;
+ DPRINT("_putenv('%s')\n", val);
+ epos = strchr(val, '=');
+ if ( epos == NULL )
+ return -1;
+ buffer = (char*)malloc(epos - val + 1);
+ if (buffer == NULL)
+ return -1;
+ strncpy(buffer, val, epos - val);
+ buffer[epos - val] = 0;
+ res = SetEnvironmentVariableA(buffer, epos+1);
+ free(buffer);
+ if (BlockEnvToEnviron())
+ return 0;
+ return res;
}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+
+#define NDEBUG
+#include <msvcrt/msvcrtdbg.h>
+
+
+extern int BlockEnvToEnviron(); // defined in misc/dllmain.c
+
+int _wputenv(const wchar_t* val)
+{
+ wchar_t* buffer;
+ wchar_t* epos;
+ int res;
+
+ DPRINT("_wputenv('%S')\n", val);
+ epos = wcsrchr(val, L'=');
+ if (epos == NULL)
+ return -1;
+ buffer = (char*)malloc((epos - val + 1) * sizeof(wchar_t));
+ if (buffer == NULL)
+ return -1;
+ wcsncpy(buffer, val, epos - val);
+ buffer[epos - val] = 0;
+ res = SetEnvironmentVariableW(buffer, epos+1);
+ free(buffer);
+ if (BlockEnvToEnviron())
+ return 0;
+ return res;
+}
+#include <msvcrt/ctype.h>
#include <msvcrt/string.h>
wchar_t *_wcsupr(wchar_t *x)
{
- wchar_t *y=x;
+ wchar_t *y = x;
while (*y) {
- *y=towupper(*y);
+ *y = towupper(*y);
y++;
}
return x;