static const TCHAR * SelectLuaFile(TCHAR *buffer, const TCHAR *path) { if (StringIsEmpty(path)) { /* no parameter: let user select a *.lua file */ LuaFileVisitor visitor; Directory::VisitSpecificFiles(LocalPath(buffer, _T("lua")), _T("*.lua"), visitor, true); if (visitor.combo_list.empty()) { ShowMessageBox(_("Not found"), _T("RunLuaFile"), MB_OK|MB_ICONINFORMATION); return nullptr; } int i = ComboPicker(_("Select a file"), visitor.combo_list); if (i < 0) return nullptr; UnsafeCopyString(buffer, visitor.combo_list[i].string_value); return buffer; } else if (StringEndsWith(path, _T(".lua"))) { /* *.lua file specified: run this file */ return IsAbsolutePath(path) ? path : LocalPath(buffer, _T("lua"), path); } else { ShowMessageBox(_T("RunLuaFile expects *.lua parameter"), _T("RunLuaFile"), MB_OK|MB_ICONINFORMATION); return nullptr; } }
gcc_nonnull_all static inline wchar_t * UnsafeCopyStringP(wchar_t *dest, const wchar_t *src) { #ifdef WIN32 /* emulate wcpcpy() */ UnsafeCopyString(dest, src); return dest + StringLength(dest); #else return wcpcpy(dest, src); #endif }
bool AltairProDevice::DeclareInternal(const struct Declaration &declaration, OperationEnvironment &env) { TCHAR Buffer[256]; StringFormatUnsafe(Buffer, _T("PDVSC,S,Pilot,%s"), declaration.pilot_name.c_str()); if (!PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env)) return false; StringFormatUnsafe(Buffer, _T("PDVSC,S,GliderID,%s"), declaration.aircraft_registration.c_str()); if (!PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env)) return false; StringFormatUnsafe(Buffer, _T("PDVSC,S,GliderType,%s"), declaration.aircraft_type.c_str()); if (!PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env)) return false; /* TODO currently not supported by XCSOAR * Pilot2 * CompetitionID * CompetitionClass * ObserverID * DeclDescription * DeclFlightDate */ if (declaration.Size() > 1) { PutTurnPoint(_T("DeclTakeoff"), nullptr, env); PutTurnPoint(_T("DeclLanding"), nullptr, env); PutTurnPoint(_T("DeclStart"), &declaration.GetFirstWaypoint(), env); PutTurnPoint(_T("DeclFinish"), &declaration.GetLastWaypoint(), env); for (unsigned int index=1; index <= 10; index++) { TCHAR TurnPointPropertyName[32]; StringFormatUnsafe(TurnPointPropertyName, _T("DeclTurnPoint%d"), index); if (index < declaration.Size() - 1) { PutTurnPoint(TurnPointPropertyName, &declaration.GetWaypoint(index), env); } else { PutTurnPoint(TurnPointPropertyName, nullptr, env); } } } UnsafeCopyString(Buffer, _T("PDVSC,S,DeclAction,DECLARE")); if (!PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env)) return false; if (StringIsEqual(&Buffer[9], _T("LOCKED"))) // FAILED! try to declare a task on a airborn recorder return false; // Buffer holds the declaration ticket. // but no one is intresting in that // eg "2010-11-21 13:01:43 (1)" return true; }