int main(int argc, char **argv) { Args args(argc, argv, "PORT BAUD"); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); Port *port = OpenPort(config, nullptr, *(DataHandler *)nullptr); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } FlarmDevice flarm(*port); RunUI(flarm, env); delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "PORT BAUD"); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); MyHandler handler; Port *port = OpenPort(config, handler); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } if (!port->StartRxThread()) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to start the port thread\n"); return EXIT_FAILURE; } char stamp[6] = ""; char line[1024]; while (fgets(line, sizeof(line), stdin) != NULL) { if (memcmp(line, "$GP", 3) == 0 && (memcmp(line + 3, "GGA", 3) == 0 || memcmp(line + 3, "RMC", 3) == 0) && line[6] == ',' && strncmp(stamp, line + 7, sizeof(stamp)) != 0) { /* the time stamp has changed - sleep for one second */ Sleep(1000); strncpy(stamp, line + 7, sizeof(stamp)); } if (!port->FullWriteString(line, env, 1000)) { fprintf(stderr, "Failed to write to port\n"); delete port; return EXIT_FAILURE; } } delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "PORT BAUD"); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); Port *port = OpenPort(config, nullptr, *(DataHandler *)nullptr); if (port == NULL) { delete port; fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } char buffer[4096]; while (true) { switch (port->WaitRead(env, 60000)) { case Port::WaitResult::READY: break; case Port::WaitResult::TIMEOUT: continue; case Port::WaitResult::FAILED: delete port; return EXIT_FAILURE; case Port::WaitResult::CANCELLED: delete port; return EXIT_SUCCESS; } int nbytes = port->Read(buffer, sizeof(buffer)); if (nbytes < 0) break; fwrite((const void *)buffer, 1, nbytes, stdout); } delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "PORT BAUD"); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); NullDataHandler handler; std::unique_ptr<Port> port(OpenPort(config, handler)); if (!port) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } RunUI(*port, env); DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "PORT BAUD"); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); MyHandler handler; Port *port = OpenPort(config, handler); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } if (!port->StartRxThread()) { delete port; fprintf(stderr, "Failed to start the port thread\n"); return EXIT_FAILURE; } while (true) Sleep(10000); delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "DRIVER PORT BAUD"); Emulator *emulator = LoadEmulator(args); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); Port *port = OpenPort(config, *emulator->handler); if (port == NULL) { delete emulator; fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } emulator->port = port; ConsoleOperationEnvironment env; emulator->env = &env; if (!port->WaitConnected(env)) { delete port; delete emulator; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } if (!port->StartRxThread()) { delete port; delete emulator; DeinitialiseIOThread(); fprintf(stderr, "Failed to start the port thread\n"); return EXIT_FAILURE; } while (port->GetState() != PortState::FAILED) Sleep(1000); delete port; delete emulator; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { const char *const usage = "PORT BAUD COMMAND\n\n" "Where COMMAND is one of:" "\n\tinfo" "\n\treboot" "\n\tpoweroff" "\n\tstartlogger" "\n\tstoplogger" "\n\tpilots" "\n\tnavpoints" ; Args args(argc, argv, usage); const DeviceConfig config = ParsePortArgs(args); const char *command = args.ExpectNext(); args.ExpectEnd(); InitialiseIOThread(); Port *port = OpenPort(config, nullptr, *(DataHandler *)nullptr); if (port == NULL) { fprintf(stderr, "Failed to open port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } CAI302Device device(config, *port); if (!RunCommand(device, command, env)) { fprintf(stderr, "error\n"); return EXIT_FAILURE; } delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "PORT BAUD [NAME=VALUE] [NAME] ..."); const DeviceConfig config = ParsePortArgs(args); InitialiseIOThread(); Port *port = OpenPort(config, nullptr, *(DataHandler *)nullptr); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } VegaDevice device(*port); while (!args.IsEmpty()) { const char *p = args.GetNext(); char *q = strdup(p); char *v = strchr(q, '='); if (v == NULL) { if (!device.RequestSetting(q, env)) printf("Error\n"); } else { *v++ = 0; if (!device.SendSetting(q, atoi(v), env)) printf("Error\n"); } free(q); } delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "DRIVER PORT BAUD"); tstring _driver_name = args.ExpectNextT(); const TCHAR *driver_name = _driver_name.c_str(); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); Port *port = OpenPort(config, *(DataHandler *)NULL); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } const struct DeviceRegister *driver = FindDriverByName(driver_name); if (driver == NULL) { _ftprintf(stderr, _T("No such driver: %s\n"), driver_name); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } assert(driver->CreateOnPort != NULL); Device *device = driver->CreateOnPort(config, *port); assert(device != NULL); device->EnableNMEA(env); delete device; delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "PORT BAUD"); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); MyHandler handler; Port *port = OpenPort(config, handler); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } /* turn off output buffering */ setvbuf(stdout, NULL, _IONBF, 0); if (!port->StartRxThread()) { delete port; fprintf(stderr, "Failed to start the port thread\n"); return EXIT_FAILURE; } while (true) Sleep(10000); delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
gcc_visibility_default JNIEXPORT void JNICALL Java_org_xcsoar_NativeView_deinitializeNative(JNIEnv *env, jobject obj) { InitThreadDebug(); delete CommonInterface::main_window; DisallowLanguage(); Fonts::Deinitialize(); #ifdef IOIOLIB delete ioio_helper; ioio_helper = NULL; #endif delete vibrator; vibrator = NULL; SoundUtil::Deinitialise(env); delete event_queue; event_queue = NULL; delete native_view; TextUtil::Deinitialise(env); OpenGL::Deinitialise(); ScreenDeinitialized(); DeinitialiseDataPath(); delete context; #ifdef IOIOLIB BMP085Device::Deinitialise(env); NativeBMP085Listener::Deinitialise(env); I2CbaroDevice::Deinitialise(env); NativeI2CbaroListener::Deinitialise(env); NunchuckDevice::Deinitialise(env); NativeNunchuckListener::Deinitialise(env); VoltageDevice::Deinitialise(env); NativeVoltageListener::Deinitialise(env); IOIOHelper::Deinitialise(env); #endif BluetoothHelper::Deinitialise(env); NativeInputListener::Deinitialise(env); InternalSensors::Deinitialise(env); Environment::Deinitialise(env); Java::URL::Deinitialise(env); DeinitialiseIOThread(); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE gcc_unused LPWSTR lpCmdLine, #else gcc_unused LPSTR lpCmdLine2, #endif int nCmdShow) #endif { #ifdef WIN32 ResourceLoader::Init(hInstance); #endif Net::Initialise(); InitialiseDataPath(); StartupLogFreeRamAndStorage(); // Write startup note + version to logfile LogStartUp(_T("Starting XCSoar %s"), XCSoar_ProductToken); // Read options from the command line #ifndef WIN32 CommandLine::Parse(Args(argc, argv, Usage)); #else CommandLine::Parse(Args(GetCommandLine(), Usage)); #endif ScreenGlobalInit screen_init; // Write initialization note to logfile LogStartUp(_T("Initialise application instance")); #ifdef WIN32 /* try to make the UI most responsive */ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); #endif // Register window classes #ifdef USE_GDI MainWindow::register_class(hInstance); #endif AllowLanguage(); InitialiseIOThread(); // Perform application initialization and run loop int ret = EXIT_FAILURE; if (XCSoarInterface::Startup()) ret = CommonInterface::main_window.RunEventLoop(); CommonInterface::main_window.reset(); DeinitialiseIOThread(); DisallowLanguage(); Fonts::Deinitialize(); DeinitialiseDataPath(); Net::Deinitialise(); assert(!ExistsAnyThread()); return ret; }
int main(int argc, char **argv) { Args args(argc, argv, "PORT BAUD"); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); MyHandler handler; Port *port = OpenPort(config, handler); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } if (!port->StartRxThread()) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to start the port thread\n"); return EXIT_FAILURE; } unsigned long last_stamp = -1; char line[1024]; while (fgets(line, sizeof(line), stdin) != NULL) { char *endptr; unsigned long current_stamp = strtoul(line, &endptr, 10); if (endptr == line || *endptr != ' ' || endptr[1] != '<') continue; char *start = endptr + 2; char *end = strchr(start, '>'); if (end == NULL) continue; *end++ = '\n'; *end = 0; if (current_stamp > last_stamp) { unsigned long delta_t = std::min(current_stamp - last_stamp, 1000ul); Sleep(delta_t); } last_stamp = current_stamp; if (!port->FullWrite(start, end - start, env, 1000)) { fprintf(stderr, "Failed to write to port\n"); delete port; return EXIT_FAILURE; } } delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "PORT"); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); Port *port = OpenPort(config, nullptr, *(DataHandler *)nullptr); if (port == nullptr) { DeinitialiseIOThread(); fprintf(stderr, "Failed to open port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } PeriodClock start_clock; start_clock.Update(); PeriodClock pressure_clock; PeriodClock battery_clock; fixed pressure = fixed(101300); unsigned battery_level = 11; while (true) { if (pressure_clock.CheckUpdate(48)) { NarrowString<16> sentence; int elapsed_ms = start_clock.Elapsed(); auto elapsed = fixed(elapsed_ms) / 1000; auto vario = sin(elapsed / 3) * cos(elapsed / 10) * cos(elapsed / 20 + fixed(2)) * 3; auto pressure_vario = -vario * fixed(12.5); auto delta_pressure = pressure_vario * 48 / 1000; pressure += delta_pressure; sentence = "_PRS "; sentence.AppendFormat("%08X", uround(pressure)); sentence += "\n"; port->Write(sentence.c_str(), sentence.length()); } if (battery_clock.CheckUpdate(11000)) { NarrowString<16> sentence; sentence = "_BAT "; if (battery_level <= 10) sentence.AppendFormat("%X", battery_level); else sentence += "*"; sentence += "\n"; port->Write(sentence.c_str(), sentence.length()); if (battery_level == 0) battery_level = 11; else battery_level--; } } }
int main(int argc, char *argv[]) { Args args(argc, argv, "HOST KEY"); const char *host = args.ExpectNext(); const char *key = args.ExpectNext(); SocketAddress address; if (!address.Lookup(host, "5597", SOCK_DGRAM)) { fprintf(stderr, "Failed to look up: %s\n", host); return EXIT_FAILURE; } #ifdef HAVE_SKYLINES_TRACKING_HANDLER InitialiseIOThread(); #endif SkyLinesTracking::Client client; #ifdef HAVE_SKYLINES_TRACKING_HANDLER client.SetIOThread(io_thread); Handler handler; client.SetHandler(&handler); #endif client.SetKey(ParseUint64(key, NULL, 16)); if (!client.Open(address)) { fprintf(stderr, "Failed to create client\n"); return EXIT_FAILURE; } if (args.IsEmpty() || StringIsEqual(args.PeekNext(), "fix")) { NMEAInfo basic; basic.Reset(); basic.UpdateClock(); basic.time = fixed(1); basic.time_available.Update(basic.clock); return client.SendFix(basic) ? EXIT_SUCCESS : EXIT_FAILURE; } else if (StringIsEqual(args.PeekNext(), "ping")) { client.SendPing(1); #ifdef HAVE_SKYLINES_TRACKING_HANDLER handler.Wait(); #endif } else if (StringIsEqual(args.PeekNext(), "traffic")) { client.SendTrafficRequest(true, true); #ifdef HAVE_SKYLINES_TRACKING_HANDLER handler.Wait(); #endif } else { DebugReplay *replay = CreateDebugReplay(args); if (replay == NULL) return EXIT_FAILURE; while (replay->Next()) { client.SendFix(replay->Basic()); usleep(100000); } } #ifdef HAVE_SKYLINES_TRACKING_HANDLER client.Close(); DeinitialiseIOThread(); #endif return EXIT_SUCCESS; }
gcc_visibility_default JNIEXPORT void JNICALL Java_org_xcsoar_NativeView_deinitializeNative(JNIEnv *env, jobject obj) { Shutdown(); if (IsNookSimpleTouch()) { Nook::ExitFastMode(); } StopLogCat(); InitThreadDebug(); if (CommonInterface::main_window != nullptr) { CommonInterface::main_window->Destroy(); delete CommonInterface::main_window; CommonInterface::main_window = nullptr; } DisallowLanguage(); Fonts::Deinitialize(); delete ioio_helper; ioio_helper = nullptr; delete vibrator; vibrator = nullptr; SoundUtil::Deinitialise(env); delete event_queue; event_queue = nullptr; delete native_view; native_view = nullptr; TextUtil::Deinitialise(env); OpenGL::Deinitialise(); ScreenDeinitialized(); DeinitialiseDataPath(); delete context; context = nullptr; BMP085Device::Deinitialise(env); NativeBMP085Listener::Deinitialise(env); I2CbaroDevice::Deinitialise(env); NativeI2CbaroListener::Deinitialise(env); NunchuckDevice::Deinitialise(env); NativeNunchuckListener::Deinitialise(env); VoltageDevice::Deinitialise(env); NativeVoltageListener::Deinitialise(env); IOIOHelper::Deinitialise(env); NativeLeScanCallback::Deinitialise(env); BluetoothHelper::Deinitialise(env); NativeInputListener::Deinitialise(env); NativePortListener::Deinitialise(env); InternalSensors::Deinitialise(env); AndroidBitmap::Deinitialise(env); Environment::Deinitialise(env); NativeView::Deinitialise(env); Java::URL::Deinitialise(env); DeinitialiseIOThread(); }
int main(int argc, char **argv) { NarrowString<1024> usage; usage = "DRIVER PORT BAUD FILE.igc [FLIGHT NR]\n\n" "Where DRIVER is one of:"; { const DeviceRegister *driver; for (unsigned i = 0; (driver = GetDriverByIndex(i)) != NULL; ++i) { if (driver->IsLogger()) { WideToUTF8Converter driver_name(driver->name); usage.AppendFormat("\n\t%s", (const char *)driver_name); } } } Args args(argc, argv, usage); tstring driver_name = args.ExpectNextT(); const DeviceConfig config = ParsePortArgs(args); PathName path(args.ExpectNext()); unsigned flight_id = args.IsEmpty() ? 0 : atoi(args.GetNext()); args.ExpectEnd(); InitialiseIOThread(); Port *port = OpenPort(config, *(DataHandler *)NULL); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; const struct DeviceRegister *driver = FindDriverByName(driver_name.c_str()); if (driver == NULL) { fprintf(stderr, "No such driver: %s\n", argv[1]); args.UsageError(); } if (!driver->IsLogger()) { fprintf(stderr, "Not a logger driver: %s\n", argv[1]); args.UsageError(); } assert(driver->CreateOnPort != NULL); Device *device = driver->CreateOnPort(config, *port); assert(device != NULL); RecordedFlightList flight_list; if (!device->ReadFlightList(flight_list, env)) { delete device; delete port; fprintf(stderr, "Failed to download flight list\n"); return EXIT_FAILURE; } if (flight_list.empty()) { delete device; delete port; fprintf(stderr, "Logger is empty\n"); return EXIT_FAILURE; } PrintFlightList(flight_list); if (flight_id >= flight_list.size()) { delete device; delete port; fprintf(stderr, "Flight id not found\n"); return EXIT_FAILURE; } if (!device->DownloadFlight(flight_list[flight_id], path, env)) { delete device; delete port; fprintf(stderr, "Failed to download flight\n"); return EXIT_FAILURE; } delete device; delete port; DeinitialiseIOThread(); printf("Flight downloaded successfully\n"); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Args args(argc, argv, "[--through DRIVER0] DRIVER PORT BAUD"); tstring _through_name; const TCHAR *through_name = NULL; const char *a; while ((a = args.PeekNext()) != NULL && *a == '-') { a = args.ExpectNext(); if (strcmp(a, "--through") == 0) { _through_name = args.ExpectNextT(); through_name = _through_name.c_str(); } else args.UsageError(); } tstring _driver_name = args.ExpectNextT(); const TCHAR *driver_name = _driver_name.c_str(); const DeviceConfig config = ParsePortArgs(args); args.ExpectEnd(); InitialiseIOThread(); Port *port = OpenPort(config, *(DataHandler *)NULL); if (port == NULL) { fprintf(stderr, "Failed to open COM port\n"); return EXIT_FAILURE; } ConsoleOperationEnvironment env; if (!port->WaitConnected(env)) { delete port; DeinitialiseIOThread(); fprintf(stderr, "Failed to connect the port\n"); return EXIT_FAILURE; } LoggerSettings logger_settings; logger_settings.pilot_name = _T("Foo Bar"); Plane plane; plane.registration = _T("D-3003"); plane.competition_id = _T("33"); plane.type = _T("Cirrus"); Declaration declaration(logger_settings, plane, NULL); declaration.Append(MakeWaypoint(_T("Bergneustadt"), 488, 7.7061111111111114, 51.051944444444445)); declaration.Append(MakeWaypoint(_T("Foo"), 488, 8, 52)); declaration.Append(MakeWaypoint(_T("Bar"), 488, 7.5, 50)); declaration.Append(MakeWaypoint(_T("Bergneustadt"), 488, 7.7061111111111114, 51.051944444444445)); Device *through_device = NULL; if (through_name != NULL) { const struct DeviceRegister *through_driver = FindDriverByName(through_name); if (through_driver == NULL) { _ftprintf(stderr, _T("No such driver: %s\n"), through_name); return EXIT_FAILURE; } if (!through_driver->HasPassThrough()) { _ftprintf(stderr, _T("Not a pass-through driver: %s\n"), through_name); return EXIT_FAILURE; } assert(through_driver->CreateOnPort != NULL); through_device = through_driver->CreateOnPort(config, *port); assert(through_device != NULL); } const struct DeviceRegister *driver = FindDriverByName(driver_name); if (driver == NULL) { _ftprintf(stderr, _T("No such driver: %s\n"), driver_name); return EXIT_FAILURE; } if (!driver->CanDeclare()) { _ftprintf(stderr, _T("Not a logger driver: %s\n"), driver_name); return EXIT_FAILURE; } assert(driver->CreateOnPort != NULL); Device *device = driver->CreateOnPort(config, *port); assert(device != NULL); if (through_device != NULL && !through_device->EnablePassThrough(env)) { _ftprintf(stderr, _T("Failed to enable pass-through mode: %s\n"), through_name); return EXIT_FAILURE; } if (device->Declare(declaration, NULL, env)) fprintf(stderr, "Declaration ok\n"); else fprintf(stderr, "Declaration failed\n"); delete through_device; delete device; delete port; DeinitialiseIOThread(); return EXIT_SUCCESS; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE gcc_unused LPWSTR lpCmdLine, #else gcc_unused LPSTR lpCmdLine2, #endif int nCmdShow) #endif { #ifdef WIN32 ResourceLoader::Init(hInstance); #endif Net::Initialise(); InitialiseDataPath(); StartupLogFreeRamAndStorage(); // Write startup note + version to logfile LogFormat(_T("Starting XCSoar %s"), XCSoar_ProductToken); // Read options from the command line { #ifdef WIN32 Args args(GetCommandLine(), Usage); #else Args args(argc, argv, Usage); #endif CommandLine::Parse(args); } ScreenGlobalInit screen_init; #ifdef WIN32 /* try to make the UI most responsive */ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); #endif AllowLanguage(); InitialiseIOThread(); // Perform application initialization and run loop int ret = EXIT_FAILURE; if (Startup()) ret = CommonInterface::main_window->RunEventLoop(); if (CommonInterface::main_window != nullptr) { CommonInterface::main_window->Destroy(); delete CommonInterface::main_window; } DeinitialiseIOThread(); DisallowLanguage(); Fonts::Deinitialize(); DeinitialiseDataPath(); Net::Deinitialise(); assert(!ExistsAnyThread()); return ret; }