+/* If !NULL, do setuid to given user after startup */
+static const char *switchuser = NULL;
+#endif
+
+/* If nonzero, write log entries to a separate file. */
+bool use_logfile = false;
+
+/* If nonzero, use syslog instead of stderr in no-detach mode. */
+bool use_syslog = false;
+
+char **g_argv; /* a copy of the cmdline arguments */
+
+static int status = 1;
+
+static struct option const long_options[] = {
+ {"config", required_argument, NULL, 'c'},
+ {"net", required_argument, NULL, 'n'},
+ {"help", no_argument, NULL, 1},
+ {"version", no_argument, NULL, 2},
+ {"no-detach", no_argument, NULL, 'D'},
+ {"debug", optional_argument, NULL, 'd'},
+ {"bypass-security", no_argument, NULL, 3},
+ {"mlock", no_argument, NULL, 'L'},
+ {"chroot", no_argument, NULL, 'R'},
+ {"user", required_argument, NULL, 'U'},
+ {"logfile", optional_argument, NULL, 4},
+ {"syslog", no_argument, NULL, 's'},
+ {"pidfile", required_argument, NULL, 5},
+ {"option", required_argument, NULL, 'o'},
+ {NULL, 0, NULL, 0}
+};
+
+#ifdef HAVE_MINGW
+static struct WSAData wsa_state;
+int main2(int argc, char **argv);
+#endif
+
+static void usage(bool status) {
+ if(status)
+ fprintf(stderr, "Try `%s --help\' for more information.\n",
+ program_name);
+ else {
+ printf("Usage: %s [option]...\n\n", program_name);
+ printf( " -c, --config=DIR Read configuration options from DIR.\n"
+ " -D, --no-detach Don't fork and detach.\n"
+ " -d, --debug[=LEVEL] Increase debug level or set it to LEVEL.\n"
+ " -n, --net=NETNAME Connect to net NETNAME.\n"
+#ifdef HAVE_MLOCKALL
+ " -L, --mlock Lock tinc into main memory.\n"
+#endif
+ " --logfile[=FILENAME] Write log entries to a logfile.\n"
+ " -s --syslog Use syslog instead of stderr with --no-detach.\n"
+ " --pidfile=FILENAME Write PID and control socket cookie to FILENAME.\n"
+ " --bypass-security Disables meta protocol security, for debugging.\n"
+ " -o, --option[HOST.]KEY=VALUE Set global/host configuration value.\n"
+#ifndef HAVE_MINGW
+ " -R, --chroot chroot to NET dir at startup.\n"
+ " -U, --user=USER setuid to given USER at startup.\n"
+#endif
+ " --help Display this help and exit.\n"
+ " --version Output version information and exit.\n\n");
+ printf("Report bugs to tinc@tinc-vpn.org.\n");