mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 05:21:22 +00:00

-critical.c: catch (more) invalid use -impl. sscanf (stolen from wine) crt: -use native mingw headers and not private copies of them -converted some routines to using tchar == impl. many missing unicode routines -impl. sscanf and friends correctly (stolen from wine) tchar.h: -added lotsa missin stuff svn path=/trunk/; revision=13608
40 lines
666 B
C
40 lines
666 B
C
#include "precomp.h"
|
|
#include <io.h>
|
|
#include <errno.h>
|
|
#include <internal/file.h>
|
|
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
int _dup(int handle)
|
|
{
|
|
HANDLE hFile;
|
|
HANDLE hProcess = GetCurrentProcess();
|
|
BOOL result;
|
|
int fd;
|
|
|
|
hFile = (HANDLE)_get_osfhandle(handle);
|
|
if (hFile == INVALID_HANDLE_VALUE) {
|
|
__set_errno(EBADF);
|
|
return -1;
|
|
}
|
|
result = DuplicateHandle(hProcess,
|
|
hFile,
|
|
hProcess,
|
|
&hFile,
|
|
0,
|
|
TRUE,
|
|
DUPLICATE_SAME_ACCESS);
|
|
if (result == FALSE) {
|
|
_dosmaperr(GetLastError());
|
|
return -1;
|
|
}
|
|
|
|
fd = alloc_fd(hFile, __fileno_getmode(handle));
|
|
if (fd < 0)
|
|
{
|
|
CloseHandle(hFile);
|
|
}
|
|
return fd;
|
|
}
|