summaryrefslogtreecommitdiff
path: root/kernel/driver.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-10-17 15:51:33 +0200
committerClifford Wolf <clifford@clifford.at>2014-10-17 16:04:59 +0200
commitb3a6f8f53019d1984d4e319db459b11da0663aa3 (patch)
tree4f370d208bb86cfe681a0a054783ec7869c6ccf1 /kernel/driver.cc
parent468ae923748a01b2763bafa3cf5fba883fe06479 (diff)
More win32 (mxe and vs) build fixes
Diffstat (limited to 'kernel/driver.cc')
-rw-r--r--kernel/driver.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc
index 7a3cd1a1..5e69cced 100644
--- a/kernel/driver.cc
+++ b/kernel/driver.cc
@@ -32,6 +32,36 @@
#if !defined(_WIN32) || defined(__MINGW32__)
# include <unistd.h>
+#else
+char *optarg;
+int optind = 1, optcur = 1;
+int getopt(int argc, char **argv, const char *optstring)
+{
+ if (optind >= argc || argv[optind][0] != '-')
+ return -1;
+
+ bool takes_arg = false;
+ int opt = argv[optind][optcur];
+ for (int i = 0; optstring[i]; i++)
+ if (opt == optstring[i] && optstring[i + 1] == ':')
+ takes_arg = true;
+
+ if (!takes_arg) {
+ if (argv[optind][++optcur] == 0)
+ optind++, optcur = 1;
+ return opt;
+ }
+
+ if (argv[optind][++optcur]) {
+ optarg = argv[optind++] + optcur;
+ optcur = 1;
+ return opt;
+ }
+
+ optarg = argv[++optind];
+ optind++, optcur = 1;
+ return opt;
+}
#endif