void DupAndCloseStderr() { int OutputFd = DuplicateFile(2); if (OutputFd > 0) { FILE *NewOutputFile = OpenFile(OutputFd, "w"); if (NewOutputFile) { OutputFile = NewOutputFile; if (EF->__sanitizer_set_report_fd) EF->__sanitizer_set_report_fd( reinterpret_cast<void *>(GetHandleFromFd(OutputFd))); DiscardOutput(2); } } }
int main( int argc, char *argv[] ) { DEBUG_BREAK; #if defined (LOCAL_DEBUG) qDebug() << "Decrypted rads_password to" << decrypt( "AwKel0QzUiZmEkIw", 89473829 ); //AwKqGyUhayqpheog or AwIfrpCU3p8cMF+V with default_key? qDebug() << "Encrypted rads_password to" << encrypt( "rat@tu1", 89473829 ); qDebug() << "Encrypted rads_password to" << encrypt( "rat@tu1", 89473829 ); QString to_decrypt = encrypt( "rat@tu1", 89473829 ); //AwKqGyUhayqpheog with default_key qDebug() << "Encrypted rads_password to" << to_decrypt; qDebug() << "Decrypted rads_password to" << decrypt( to_decrypt, 89473829 ); #endif #if !defined(Q_OS_WIN) // QtService stores service settings in SystemScope, which normally require root privileges. // To allow testing this example as non-root, we change the directory of the SystemScope settings file. QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath()); qWarning("(Example uses dummy settings file: %s/QtSoftware.conf)", QDir::tempPath().toLatin1().constData()); #endif const CApplicationStaticPaths brat_paths( argv[ 0 ], RADS_SERVICE_NAME ); const std::string log_path = brat_paths.mExecutableDir + "/RadsServiceLog.txt"; qputenv( "QGIS_LOG_FILE", log_path.c_str() ); if ( IsFile( log_path ) ) { QFileInfo info( log_path.c_str() ); if ( info.size() > 10000 ) { std::string old_path = CreateUniqueFileName( log_path ); //old_path is a new path, to save old contents if ( old_path.empty() || !DuplicateFile( log_path, old_path ) ) //save "old" file LOG_WARN( "Could not create new log file. Trying to use existing one." ); else RemoveFile( log_path ); } } #if defined (LOCAL_DEBUG) QCoreApplication service( argc, argv ); new CRadsDaemon( brat_paths ); return service.exec(); #else CRadsService service( argc, argv, brat_paths ); return service.exec(); #endif }