reactos/sdk/tools/isohybrid/reactos_support_code.c
Colin Finck 2c11c41115
Add a shared "port" directory for POSIX functions needed by multiple host tools (getopt/mkstemps) and import the one and only getopt from glibc.
This finally fixes our duplicated getopt functions from different sources and gives us an up to date and the most compatible implementation.
isohybrid actually relies on a glibc-specific getopt behavior that we previously hacked into the reactos_support_code.c implementation derived from BSD/mingw-w64.
widl also needs getopt and previously used an even older BSD-derived code.
2019-04-28 23:23:06 +02:00

43 lines
746 B
C

#include "reactos_support_code.h"
void
isohybrid_error(int eval, const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "isohybrid: ");
vfprintf(stderr, fmt, ap);
va_end(ap);
exit(eval);
}
void
isohybrid_warning(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "isohybrid: ");
vfprintf(stderr, fmt, ap);
va_end(ap);
}
#ifdef _WIN32
int
fsync(int fd)
{
HANDLE hFile = (HANDLE)_get_osfhandle(fd);
if (hFile == INVALID_HANDLE_VALUE)
return 1;
return !FlushFileBuffers(hFile);
}
int
getppid(void)
{
// Just return any nonzero value under Windows to enable isohybrid's usage
// as a part of srand initialization.
return 1;
}
#endif