int Util_CompareDotted(const char *s1, const char *s2);
+/*
+ * This enum defines how Util_GetOpt should handle non-option arguments:
+ *
+ * UTIL_NONOPT_PERMUTE: Permute argv so that all non-options are at the end.
+ * UTIL_NONOPT_STOP: Stop when first non-option argument is seen.
+ * UTIL_NONOPT_ALL: Return each non-option argument as if it were
+ * an option with character code 1.
+ */
+typedef enum { UTIL_NONOPT_PERMUTE, UTIL_NONOPT_STOP, UTIL_NONOPT_ALL } Util_NonOptMode;
+struct option;
+int Util_GetOpt(int argc, char * const *argv, const struct option *opts,
+ Util_NonOptMode mode);
+
+
#if defined(VMX86_STATS)
Bool Util_QueryCStResidency(uint32 *numCpus, uint32 *numCStates,
uint64 **transitns, uint64 **residency,
#define VCB_FILE_VERSION 4,0,0,0
#define VIM_VERSION "5.0.0"
#define VPX_VERSION "5.0.0"
+#define SVA_VERSION "1.0.0"
#define WBC_VERSION "5.0.0"
#define SDK_VERSION "4.1.0"
#define FOUNDRY_VERSION "1.10.0"
#define USB_ARBITRATOR_VERSION_MAJOR 8
#define USB_ARBITRATOR_VERSION_MINOR 2
-#define USB_ARBITRATOR_VERSION_Z 2
+#define USB_ARBITRATOR_VERSION_Z 4
#define USB_ARBITRATOR_VERSION_BASE USB_ARBITRATOR_VERSION_MAJOR.\
USB_ARBITRATOR_VERSION_MINOR
* USB Arbitrator Component version. This version is used by the linux
* installer. See USB_ARBITRATOR_COMPONENT_VERSION_NUMBER in mk/defs-onetime.mk
*/
-#define USB_ARBITRATOR_COMPONENT_VERSION_NUMBER "8.2.2"
+#define USB_ARBITRATOR_COMPONENT_VERSION_NUMBER "8.2.4"
#ifdef VMX86_VPX
#define VIM_API_TYPE "VirtualCenter"
# include <io.h>
# include <process.h>
# include "coreDump.h"
+# include "getoptWin32.h"
#endif
#include <fcntl.h>
#if !defined(_WIN32) && !defined(N_PLAT_NLM)
# include <unistd.h>
+# include <getopt.h>
# include <pwd.h>
# include <dlfcn.h>
#endif
}
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Util_GetOpt --
+ *
+ * A wrapper around getopt_long that avoids needing separate long and
+ * short option lists.
+ *
+ * To use this, the array of option structs must:
+ * * Store the short option name in the 'val' member.
+ * * Set the 'name' member to NULL if the option has a short name but no
+ * long name.
+ * * For options that have only a long name, 'val' should be set to a
+ * unique value greater than UCHAR_MAX.
+ * * Terminate the array with a sentinel value that zero-initializes both
+ * 'name' and 'val'.
+ *
+ * Results:
+ * See getopt_long.
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int
+Util_GetOpt(int argc, // IN
+ char * const *argv, // IN
+ const struct option *opts, // IN
+ Util_NonOptMode mode) // IN
+{
+ int ret = -1;
+
+ struct option *longOpts = NULL;
+ char *shortOptString = NULL;
+
+ /*
+ * In the worst case, each character needs "::" to indicate that it takes
+ * an optional argument.
+ */
+ const size_t maxCharsPerShortOption = 3;
+ const size_t modePrefixSize = 1;
+
+ size_t n = 0;
+ size_t shortOptStringSize;
+
+ while (!(opts[n].name == NULL && opts[n].val == 0)) {
+ if (UNLIKELY(n == SIZE_MAX)) {
+ /*
+ * Avoid integer overflow. If you have this many options, you're
+ * doing something wrong.
+ */
+ ASSERT(FALSE);
+ goto exit;
+ }
+ n++;
+ }
+
+ if (UNLIKELY(n > SIZE_MAX / sizeof *longOpts - 1)) {
+ /* Avoid integer overflow. */
+ ASSERT(FALSE);
+ goto exit;
+ }
+ longOpts = malloc((n + 1) * sizeof *longOpts);
+ if (longOpts == NULL) {
+ goto exit;
+ }
+
+ if (UNLIKELY(n > (SIZE_MAX - modePrefixSize - 1 /* NUL */) /
+ maxCharsPerShortOption)) {
+ /* Avoid integer overflow. */
+ ASSERT(FALSE);
+ goto exit;
+ }
+ shortOptStringSize = n * maxCharsPerShortOption + modePrefixSize + 1 /* NUL */;
+ shortOptString = malloc(shortOptStringSize);
+ if (shortOptString == NULL) {
+ goto exit;
+ } else {
+ struct option empty = { 0 };
+
+ size_t i;
+ struct option *longOptOut = longOpts;
+ char *shortOptOut = shortOptString;
+
+ switch (mode) {
+ case UTIL_NONOPT_STOP:
+ *shortOptOut++ = '+';
+ break;
+ case UTIL_NONOPT_ALL:
+ *shortOptOut++ = '-';
+ break;
+ default:
+ break;
+ }
+
+ for (i = 0; i < n; i++) {
+ int val = opts[i].val;
+
+ if (opts[i].name != NULL) {
+ *longOptOut++ = opts[i];
+ }
+
+ if (val > 0 && val <= UCHAR_MAX) {
+ int argSpec = opts[i].has_arg;
+
+ *shortOptOut++ = (char) val;
+
+ if (argSpec != no_argument) {
+ *shortOptOut++ = ':';
+
+ if (argSpec == optional_argument) {
+ *shortOptOut++ = ':';
+ }
+ }
+ }
+ }
+
+ ASSERT(longOptOut - longOpts <= n);
+ *longOptOut = empty;
+
+ ASSERT(shortOptOut - shortOptString < shortOptStringSize);
+ *shortOptOut = '\0';
+ }
+
+ ret = getopt_long(argc, argv, shortOptString, longOpts, NULL);
+
+exit:
+ free(longOpts);
+ free(shortOptString);
+ return ret;
+}
+
+
+
/*
*-----------------------------------------------------------------------------