+#ifdef _WIN32
+# include <io.h>
+#else
+# include <unistd.h>
+#endif
+
+/*
+ * Windows compatibility defines for string encoding. Applications using wimlib
+ * that need to run on both UNIX and Windows will need to do something similar
+ * to this, whereas applications that only need to run on one or the other can
+ * just use their platform's convention directly.
+ */
+#ifdef _WIN32
+# define main wmain
+ typedef wchar_t tchar;
+# define _T(text) L##text
+# define T(text) _T(text)
+# define TS "ls"
+# define topen _wopen
+# define tstrcmp wcscmp
+# define tstrtol wcstol
+#else
+ typedef char tchar;
+# define T(text) text
+# define TS "s"
+# define topen open
+# define O_BINARY 0
+# define tstrcmp strcmp
+# define tstrtol strtol
+#endif
+
+static void
+fatal_error(int err, const char *format, ...)
+{
+ va_list va;
+
+ va_start(va, format);
+ vfprintf(stderr, format, va);
+ if (err != 0)
+ fprintf(stderr, ": %s\n", strerror(err));
+ else
+ fputc('\n', stderr);
+ va_end(va);
+ exit(1);
+}