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.
This commit is contained in:
Colin Finck 2019-04-27 16:19:26 +02:00
parent c02257ef57
commit 2c11c41115
No known key found for this signature in database
GPG key ID: 1BA74E70456BA1A9
18 changed files with 1305 additions and 1615 deletions

View file

@ -16,6 +16,8 @@
#include <unistd.h>
#endif
#include "../port/port.h"
// isotypes.h would provide these, but it's not available on MSVC < 2013.
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
@ -31,30 +33,6 @@ void isohybrid_warning(const char* fmt, ...);
#define warnx(...) isohybrid_warning(__VA_ARGS__)
/////////////////////////////////////////////////////////////////////////////
// getopt code from mingw-w64
/////////////////////////////////////////////////////////////////////////////
extern int optopt; /* single option character, as parsed */
extern char *optarg; /* pointer to argument of current option */
struct option /* specification for a long form option... */
{
const char *name; /* option name, without leading hyphens */
int has_arg; /* does it take an argument? */
int *flag; /* where to save its status, or NULL */
int val; /* its associated status value */
};
enum /* permitted values for its `has_arg' field... */
{
no_argument = 0, /* option never takes an argument */
required_argument, /* option always requires an argument */
optional_argument /* option may take an argument */
};
int getopt_long_only(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx);
/////////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
int fsync(int fd);
int getppid(void);