bool ParseProgramOptions(int32 &return_code, int32 argc, char **argv) { // Convert the argument list to a vector of strings for convenience std::vector<std::string> options(argv, argv + argc); return_code = 0; for(uint32 i = 1; i < options.size(); i++) { if(options[i] == "-c" || options[i] == "--check") { if(CheckFiles() == true) { return_code = 0; } else { return_code = 1; } return false; } else if(options[i] == "-d" || options[i] == "--debug") { if((i + 1) >= options.size()) { std::cerr << "Option " << options[i] << " requires an argument." << std::endl; PrintUsage(); return_code = 1; return false; } if(EnableDebugging(options[i + 1]) == false) { return_code = 1; return false; } i++; } else if(options[i] == "--disable-audio") { vt_audio::AUDIO_ENABLE = false; } else if(options[i] == "-h" || options[i] == "--help") { PrintUsage(); return_code = 0; return false; } else if(options[i] == "-i" || options[i] == "--info") { if(PrintSystemInformation() == true) { return_code = 0; } else { return_code = 1; } return false; } else if(options[i] == "-r" || options[i] == "--reset") { if(ResetSettings() == true) { return_code = 0; } else { return_code = 1; } return_code = 0; return false; } else { std::cerr << "Unrecognized option: " << options[i] << std::endl; PrintUsage(); return_code = 1; return false; } } return true; } // bool ParseProgramOptions(int32_t &return_code, int32_t argc, char **argv)
void ParRenamer::Execute() { m_progressLabel.Format("Checking renamed files for %s", *m_infoName); m_stageProgress = 0; UpdateProgress(); BuildDirList(m_destDir); for (CString& destDir : m_dirList) { debug("Checking %s", *destDir); m_fileHashList.clear(); m_parInfoList.clear(); m_badParList.clear(); m_loadedParList.clear(); CheckFiles(destDir, true); RenameParFiles(destDir); LoadMainParFiles(destDir); if (m_hasDamagedParFiles) { LoadExtraParFiles(destDir); } CheckFiles(destDir, false); if (m_detectMissing) { CheckMissing(); } if (m_renamedCount > 0 && !m_badParList.empty()) { RenameBadParFiles(); } } }
//---------------------------------------------------------------- BOOL LocalFilesScan(DWORD iitem, PSCANNE_ST config, long int *id_ok, DWORD cb_id) { char tmp[MAX_PATH], letter[3]=" :\0"; int i,nblecteurs = GetLogicalDriveStrings(MAX_PATH,tmp); for (i=0;i<nblecteurs && scan_start;i+=4) { switch(GetDriveType(&tmp[i])) { /*case DRIVE_UNKNOWN: break; case DRIVE_NO_ROOT_DIR: break; case DRIVE_CDROM:break;*/ case DRIVE_FIXED: //case DRIVE_REMOTE: //case DRIVE_RAMDISK: //case DRIVE_REMOVABLE: { //check file char file[LINE_SIZE]; DWORD j, _nb_i = SendDlgItemMessage(h_main,cb_id,LB_GETCOUNT,(WPARAM)NULL,(LPARAM)NULL); letter[0] = tmp[i]; if (id_ok != NULL && *id_ok > ID_ERROR) j = *id_ok; #ifdef DEBUG_MODE_FILES AddMsg(h_main,(char*)"INFORMATION","START LOCAL FILE SEARCH",(char*)letter); #endif for (j=0;j<_nb_i && scan_start;j++) { if (SendDlgItemMessage(h_main,cb_id,LB_GETTEXTLEN,(WPARAM)j,(LPARAM)NULL) > LINE_SIZE)continue; file[0] = 0; if (SendDlgItemMessage(h_main,cb_id,LB_GETTEXT,(WPARAM)j,(LPARAM)file)) { #ifdef DEBUG_MODE_FILES AddMsg(h_main,(char*)"DEBUG (LocalFilesScan)",file,(char*)letter); #endif if (file)CheckFiles(iitem, letter, file); } } #ifdef DEBUG_MODE_FILES AddMsg(h_main,(char*)"INFORMATION","END LOCAL FILE SEARCH",(char*)letter); #endif } break; } } return TRUE; }
int CheckChangedFiles(const char* filename,StrList& dst) { String file=filename; file.ToLower(); for(int i=0;i<files.Count();i++) { if(files[i]->filename==file && files[i]->indexFile.Length()) { struct stat stf,sti; if(stat(file,&stf)==-1)return 0; if(stat(files[i]->indexFile,&sti)==-1)return 0; if(stf.st_mtime!=sti.st_mtime)return 0; CheckFiles(files[i],dst); return 1; } } return 0; }
int CheckFilenames(LPTSTR filename1, LPTSTR filename2) { HANDLE hFile1 = CreateFile(filename1,0,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_ATTRIBUTE_NORMAL,0); HANDLE hFile2 = CreateFile(filename2,0,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_ATTRIBUTE_NORMAL,0); if (!hFile1 && !hFile2) { return 0; } else if (hFile1 && !hFile2) { CloseHandle(hFile1); return 1; } else if (!hFile1 && hFile2) { CloseHandle(hFile2); return -1; } int res = CheckFiles(hFile1,hFile2); CloseHandle(hFile1); CloseHandle(hFile2); return res; }
//---------------------------------------------------------------- BOOL RemoteAuthenticationFilesScan(DWORD iitem, char *ip, DWORD ip_id, char *remote_share, PSCANNE_ST config, long int *id_ok, DWORD id_cb, BOOL multi) { #ifdef DEBUG_MODE_FILES AddMsg(h_main,"DEBUG","files:RemoteAuthenticationFilesScan START",ip); #endif //check file char remote_name[LINE_SIZE], msg[LINE_SIZE]; snprintf(remote_name,LINE_SIZE,"\\\\%s\\%s",ip,remote_share); if (config->nb_accounts == 0) { NETRESOURCE NetRes = {0}; NetRes.dwScope = RESOURCE_GLOBALNET; NetRes.dwType = RESOURCETYPE_ANY; NetRes.lpLocalName = (LPSTR)""; NetRes.lpProvider = (LPSTR)""; NetRes.lpRemoteName = remote_name; char tmp_login[MAX_PATH]=""; if (config->domain[0] != 0) { snprintf(tmp_login,MAX_PATH,"%s\\%s",config->domain,config->login); }else { if (!config->local_account)snprintf(tmp_login,MAX_PATH,"%s\\%s",ip,config->login); } if (WNetAddConnection2(&NetRes,config->password,tmp_login,CONNECT_PROMPT)==NO_ERROR) { if (multi) { DWORD nb_file_check = CheckRecursivFilesList(iitem, remote_name, id_cb); char source[MAX_PATH]; snprintf(source,MAX_PATH,"%s\\%s",ip,remote_share); snprintf(msg,MAX_PATH,"%lu files checked",nb_file_check); AddMsg(h_main,(char*)"INFORMATION (Files)",source,msg); }else { snprintf(msg,LINE_SIZE,"%s\\%s with %s account.",ip,remote_share,tmp_login); AddMsg(h_main,(char*)"LOGIN (Files:NET)",msg,(char*)""); snprintf(msg,LINE_SIZE,"Login NET %s\\%s with %s account",ip,remote_share,tmp_login); AddLSTVUpdateItem(msg, COL_CONFIG, iitem); //check file char file[LINE_SIZE]; DWORD j=0, _nb_i = SendDlgItemMessage(h_main,id_cb,LB_GETCOUNT,(WPARAM)NULL,(LPARAM)NULL); if (id_ok != NULL && *id_ok > ID_ERROR) j = *id_ok; for (;j<_nb_i && scan_start;j++) { if (SendDlgItemMessage(h_main,id_cb,LB_GETTEXTLEN,(WPARAM)j,(LPARAM)NULL) > LINE_SIZE)continue; file[0] = 0; if (SendDlgItemMessage(h_main,id_cb,LB_GETTEXT,(WPARAM)j,(LPARAM)file)) { if (file)CheckFiles(iitem, remote_name, file); } } } WNetCancelConnection2(remote_name,CONNECT_UPDATE_PROFILE,1); #ifdef DEBUG_MODE_FILES AddMsg(h_main,"DEBUG","files:RemoteAuthenticationFilesScan END",ip); #endif return TRUE; } }else if (config->global_ip_file) { NETRESOURCE NetRes = {0}; NetRes.dwScope = RESOURCE_GLOBALNET; NetRes.dwType = RESOURCETYPE_ANY; NetRes.lpLocalName = (LPSTR)""; NetRes.lpProvider = (LPSTR)""; NetRes.lpRemoteName = remote_name; char tmp_login[MAX_PATH]; if (config->accounts[ip_id].domain[0] != 0) { snprintf(tmp_login,MAX_PATH,"%s\\%s",config->accounts[ip_id].domain,config->accounts[ip_id].login); }else { snprintf(tmp_login,MAX_PATH,"%s\\%s",ip,config->accounts[ip_id].login); } if (WNetAddConnection2(&NetRes,config->accounts[ip_id].password,tmp_login,CONNECT_PROMPT)==NO_ERROR) { if (multi) { DWORD nb_file_check = CheckRecursivFilesList(iitem, remote_name, id_cb); char source[MAX_PATH]; snprintf(source,MAX_PATH,"%s\\%s",ip,remote_share); snprintf(msg,MAX_PATH,"%lu files checked",nb_file_check); AddMsg(h_main,(char*)"INFORMATION (Files)",source,msg); }else { snprintf(msg,LINE_SIZE,"%s\\%s with %s (%02d) account.",ip,remote_share,tmp_login,ip_id); AddMsg(h_main,(char*)"LOGIN (Files:NET)",msg,(char*)""); snprintf(msg,LINE_SIZE,"Login NET %s\\%s with %s (%02d) account",ip,remote_share,tmp_login,ip_id); AddLSTVUpdateItem(msg, COL_CONFIG, iitem); //check file char file[LINE_SIZE]; DWORD j, _nb_i = SendDlgItemMessage(h_main,id_cb,LB_GETCOUNT,(WPARAM)NULL,(LPARAM)NULL); if (id_ok != NULL && *id_ok > ID_ERROR) j = *id_ok; for (j=0;j<_nb_i && scan_start;j++) { if (SendDlgItemMessage(h_main,id_cb,LB_GETTEXTLEN,(WPARAM)j,(LPARAM)NULL) > LINE_SIZE)continue; file[0] = 0; if (SendDlgItemMessage(h_main,id_cb,LB_GETTEXT,(WPARAM)j,(LPARAM)file)) { if (file)CheckFiles(iitem, remote_name, file); } } } WNetCancelConnection2(remote_name,CONNECT_UPDATE_PROFILE,1); #ifdef DEBUG_MODE_FILES AddMsg(h_main,"DEBUG","files:RemoteAuthenticationFilesScan END",ip); #endif return TRUE; } }else { unsigned int i; for (i=0; i<config->nb_accounts && scan_start ;i++) { NETRESOURCE NetRes = {0}; NetRes.dwScope = RESOURCE_GLOBALNET; NetRes.dwType = RESOURCETYPE_ANY; NetRes.lpLocalName = (LPSTR)""; NetRes.lpProvider = (LPSTR)""; NetRes.lpRemoteName = remote_name; char tmp_login[MAX_PATH]; if (config->accounts[i].domain[0] != 0) { snprintf(tmp_login,MAX_PATH,"%s\\%s",config->accounts[i].domain,config->accounts[i].login); }else { snprintf(tmp_login,MAX_PATH,"%s\\%s",ip,config->accounts[i].login); } if (WNetAddConnection2(&NetRes,config->accounts[i].password,tmp_login,CONNECT_PROMPT)==NO_ERROR) { if (multi) { DWORD nb_file_check = CheckRecursivFilesList(iitem, remote_name, id_cb); char source[MAX_PATH]; snprintf(source,MAX_PATH,"%s\\%s",ip,remote_share); snprintf(msg,MAX_PATH,"%lu files checked",nb_file_check); AddMsg(h_main,(char*)"INFORMATION (Files)",source,msg); }else { snprintf(msg,LINE_SIZE,"%s\\%s with %s (%02d) account.",ip,remote_share,tmp_login,i); AddMsg(h_main,(char*)"LOGIN (Files:NET)",msg,(char*)""); snprintf(msg,LINE_SIZE,"Login NET %s\\%s with %s (%02d) account",ip,remote_share,tmp_login,i); AddLSTVUpdateItem(msg, COL_CONFIG, iitem); //check file char file[LINE_SIZE]; DWORD j, _nb_i = SendDlgItemMessage(h_main,id_cb,LB_GETCOUNT,(WPARAM)NULL,(LPARAM)NULL); if (id_ok != NULL && *id_ok > ID_ERROR) j = *id_ok; for (j=0;j<_nb_i && scan_start;j++) { if (SendDlgItemMessage(h_main,id_cb,LB_GETTEXTLEN,(WPARAM)j,(LPARAM)NULL) > LINE_SIZE)continue; file[0] = 0; if (SendDlgItemMessage(h_main,id_cb,LB_GETTEXT,(WPARAM)j,(LPARAM)file)) { if (file)CheckFiles(iitem, remote_name, file); } } } WNetCancelConnection2(remote_name,CONNECT_UPDATE_PROFILE,1); #ifdef DEBUG_MODE_FILES AddMsg(h_main,"DEBUG","files:RemoteAuthenticationFilesScan END",ip); #endif return TRUE; } } } #ifdef DEBUG_MODE_FILES AddMsg(h_main,"DEBUG","files:RemoteAuthenticationFilesScan END",ip); #endif return FALSE; }
/* * Start proper action for command */ int ProcessCommand(char* command, char *content) { // printf("Entered command: %s\n", command); if(strcmp(command, "!connect")==0) { // printf("%s %s\n",command, content); return ConnectToServer(content); } else if(g_serverFd < 0) { printf("You must be connected!\n"); return -1; } else if(strcmp(command, "!bye")==0) { // printf("%s\n",command); return Disconnect(); } else if(strcmp(command, "!rooms")==0) { //printf("%s\n",command); return GetRooms(command); } else if(strcmp(command, "!open")==0) { // printf("%s\n",command); return OpenRoom(command, content); } else if(strcmp(command, "!close")==0) { //printf("%s\n",command); return CloseRoom(content); } else if(strcmp(command, "!enter")==0) { //printf("%s\n",command); return EnterRoom(command, content); } else if(strcmp(command, "!leave")==0) { //printf("%s\n",command); return LeaveRoom(); } else if(strcmp(command, "!files")==0) { //printf("%s\n",command); return CheckFiles(); } else if(strcmp(command, "!push")==0) { // printf("%s\n",command); return UploadFile(content); } else if(strcmp(command, "!pull")==0) { // printf("%s\n",command); return DownloadFile(content); } else if(strcmp(command, "!rm")==0) { //printf("%s\n",command); return 1; } else if(strcmp(command, "!send")==0) { //printf("%s\n", command); return SendMessageToRoom(content); } else return -1; }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLanguages(new QActionGroup(this)), mLogView(NULL), mHelpWindow(NULL), mProject(NULL), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView(mSettings); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); CreateLanguageMenuItems(); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { DoCheckFiles(args); } }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLogView(NULL), mProject(NULL), mPlatformActions(new QActionGroup(this)), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView; // Filter timer to delay filtering results slightly while typing mFilterTimer = new QTimer(this); mFilterTimer->setInterval(500); mFilterTimer->setSingleShot(true); connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(FilterResults())); // "Filter" toolbar mLineEditFilter = new QLineEdit(mUI.mToolBarFilter); mLineEditFilter->setPlaceholderText(tr("Quick Filter:")); mUI.mToolBarFilter->addWidget(mLineEditFilter); connect(mLineEditFilter, SIGNAL(textChanged(const QString&)), mFilterTimer, SLOT(start())); connect(mLineEditFilter, SIGNAL(returnPressed()), this, SLOT(FilterResults())); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); // About menu connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); // View > Toolbar menu connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(ToggleFilterToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); // File menu connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); // Must setup MRU menu before CLI param handling as it can load a // project file and update MRU menu. for (int i = 0; i < MaxRecentProjects; ++i) { mRecentProjectActs[i] = new QAction(this); mRecentProjectActs[i]->setVisible(false); connect(mRecentProjectActs[i], SIGNAL(triggered()), this, SLOT(OpenRecentProject())); } mRecentProjectActs[MaxRecentProjects] = NULL; // The separator mUI.mActionProjectMRU->setVisible(false); UpdateMRUMenuItems(); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { HandleCLIParams(args); } for (int i = 0; i < mPlatforms.getCount(); i++) { Platform plat = mPlatforms.mPlatforms[i]; QAction *act = new QAction(this); plat.mActMainWindow = act; mPlatforms.mPlatforms[i] = plat; act->setText(plat.mTitle); act->setData(plat.mType); act->setCheckable(true); act->setActionGroup(mPlatformActions); mUI.mMenuCheck->insertAction(mUI.mActionPlatforms, act); connect(act, SIGNAL(triggered()), this, SLOT(SelectPlatform())); } // For Windows platforms default to Win32 checked platform. // For other platforms default to unspecified/default which means the // platform Cppcheck GUI was compiled on. #if defined(_WIN32) Platform &plat = mPlatforms.get(Settings::Win32A); #else Platform &plat = mPlatforms.get(Settings::Unspecified); #endif plat.mActMainWindow->setChecked(true); mSettings->setValue(SETTINGS_CHECKED_PLATFORM, plat.mType); }
void VideoWatcher::CaptureFinished() { QFuture<void> CaptureTask; static bool AudioStarted = false; // In debug mode, keep the audio and video playback in sync if (WaitDuration > 0) MCSleep(WaitDuration); FrameCount++; OverallFrameCount++; *OriginalImage = *CapturedImage; if (AudioStarted == false) { QTimer::singleShot(100, this, SIGNAL(StartAudio())); AudioStarted = true; } // Start a new capture CaptureTask = QtConcurrent::run(boost::bind(&VideoWatcher::CaptureImage, this)); CaptureWatcher.setFuture(CaptureTask); if (FrameCount % 3 == 1) return; OriginalImage->ConvertBGRToRGB(); *FinalImage = *OriginalImage; CheckFiles(); // Check if the capture process stopped by some reason if (!CaptureDevice->IsCapturing()) { MC_LOG("Capture stopped"); QCoreApplication::quit(); } // Be sure that the image has the expected size if (FinalImage->GetWidth() != FrameWidth && FinalImage->GetHeight() != FrameHeight) { FinalImage->Resize(FrameWidth, FrameHeight); } if (Undistort && FinalImage->GetWidth() == FrameWidth && FinalImage->GetHeight() == FrameHeight) { Calibration->Undistort(*FinalImage); // TODO: The rotational correction is too CPU expensive if (!MCIsFloatInfinity(RotationAngle)) { FinalImage->Rotate(RotationCenter.X, RotationCenter.Y, RotationAngle); } } // Check if the lights are off if (FinalImage->AverageBrightnessLevel() < 10) { Markers->Reset(); MotionDetection->Reset(); Q_EMIT(VideoEvent(IOP::IdleEvent)); Q_EMIT(VideoEvent(IOP::CaptureEvent)); return; } // Calculate fps if (FrameCount % 300 == 0) { MC_LOG("Capture speed: %1.2f fps", (float)1000 / FpsTimer.elapsed()*FrameCount); FpsTimer.start(); FrameCount = 0; MC_LOG("Average brightness level: %1.2f", FinalImage->AverageBrightnessLevel()); } // Corner detection Markers->AddImage(*FinalImage); // TODO: The rotational correction is too CPU expensive if (Markers->IsReady() && !Markers->IsAnyMissingCorner() && MCIsFloatInfinity(RotationAngle)) { // Get the rotational angle and reset the marker detection Markers->GetRotationalCorrection(*FinalImage, RotationAngle, RotationCenter); MC_LOG("Detected rotation: %1.2f degrees", RotationAngle); Markers->Reset(); } // Motion detection MEImage MotionFrame = *FinalImage; MotionFrame.Resize(FrameWidth / 4, FrameHeight / 4); MotionDetection->DetectMotions(MotionFrame); /* * Draw the debug signs and texts on the original image */ DebugMessageImage->Clear(); // Composite debug signs if (DebugMotions) { MEImage MaskImage; MotionDetection->GetMotionsMask(MaskImage); // Convert the grayscale image back to RGB MaskImage.ConvertToRGB(); MaskImage.Resize(FrameWidth, FrameHeight); FinalImage->Addition(MaskImage, ME::MaskAddition); } if (DebugCorners) Markers->DrawDebugSigns(*FinalImage); if (Markers->IsReady() && Markers->IsAnyMissingCorner()) { Markers->DrawMissingCorners(*FinalImage); DebugMessageImage->DrawText(160, 320, "Table not detected", 1, MEColor(255, 255, 255)); Q_EMIT(VideoEvent(IOP::MissingCornersEvent)); } Q_EMIT(VideoEvent(IOP::NormalEvent)); Q_EMIT(VideoEvent(IOP::CaptureEvent)); }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLogView(NULL), mProject(NULL), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView; // Filter timer to delay filtering results slightly while typing mFilterTimer = new QTimer(this); mFilterTimer->setInterval(500); mFilterTimer->setSingleShot(true); connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(FilterResults())); // "Filter" toolbar mLineEditFilter = new QLineEdit(mUI.mToolBarFilter); mLineEditFilter->setPlaceholderText(tr("Quick Filter:")); mUI.mToolBarFilter->addWidget(mLineEditFilter); connect(mLineEditFilter, SIGNAL(textChanged(const QString&)), mFilterTimer, SLOT(start())); connect(mLineEditFilter, SIGNAL(returnPressed()), this, SLOT(FilterResults())); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); // About menu connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); // View > Toolbar menu connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(ToggleFilterToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); // File menu connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { HandleCLIParams(args); } for (int i = 0; i < MaxRecentProjects; ++i) { mRecentProjectActs[i] = new QAction(this); mRecentProjectActs[i]->setVisible(false); connect(mRecentProjectActs[i], SIGNAL(triggered()), this, SLOT(OpenRecentProject())); } mUI.mActionProjectMRU->setVisible(false); UpdateMRUMenuItems(); }
MAKEPATCHLIST_RESULT CPatchManager::MakePatchList( int nVersion ) { m_files.clear(); char szPath[MAX_PATH]; sprintf( szPath, "%s\\%s", m_szCurrentDirectory, "list.txt" ); FILE* fp = fopen( szPath, "rt" ); if( !fp ) return MAKEPATCHLIST_FILE_NOTFOUND; SYSTEMTIME sysTime; char szTokens[4][256]; char szBuffer[256], szDir[256], szFile[256]; char szRoot[256] = {0, }; char cbFlag; int nYY, nMM, nDD; int nHour, nMin; while( 1 ) { if( fgets( szBuffer, 127, fp ) == NULL) break; if( strlen( szBuffer ) < 6 ) continue; if( szBuffer[0] == 'v' ) { if( memcmp( szBuffer, "ver:", 4 ) == 0 ) { if( atoi( szBuffer+4 ) == nVersion ) continue; else { fclose( fp ); m_files.clear(); return MAKEPATCHLIST_VERSION_MISMATCH; } } } else if( szBuffer[2] == ':' ) { sscanf( szBuffer, "%s %s", szTokens[0], szTokens[1] ); if( szRoot[0] == 0 ) { strcpy( szRoot, szTokens[0] ); szDir[0] = 0; } else { memset( szDir, 0x00, sizeof( szDir ) ); memcpy( szDir, szTokens[0] + strlen( szRoot ), strlen( szTokens[0] ) - strlen( szRoot ) ); EnqueueFILE( szDir, true, 0, NULL ); } } else if( szBuffer[4] == '-' ) { sscanf( szBuffer, "%s %s %s %s", szTokens[0], szTokens[1], szTokens[2], szTokens[3] ); if( strcmp( szTokens[2], "<DIR>") ) { sscanf( szTokens[0], "%d-%d-%d", &nYY, &nMM, &nDD ); sscanf( szTokens[1], "%02d:%02d%c", &nHour, &nMin, &cbFlag ); if( nHour == 12 ) nHour = 0; if( cbFlag == 'p' ) nHour += 12; sprintf( szFile, "%s\\%s", szDir, szBuffer + 39 ); szFile[ strlen(szFile) - 1 ] = 0; // line feed 제거 sysTime.wYear = (WORD)nYY; sysTime.wMonth = (WORD)nMM; sysTime.wDay = (WORD)nDD; sysTime.wHour = (WORD)nHour; sysTime.wMinute = (WORD)nMin; sysTime.wSecond = 0; sysTime.wMilliseconds = 0; EnqueueFILE( szFile, false, atoi(szTokens[2]), &sysTime ); } } } fclose( fp ); CheckFiles(); return MAKEPATCHLIST_OK; }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLanguages(new QActionGroup(this)) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionShowAll, SIGNAL(toggled(bool)), this, SLOT(ShowAll(bool))); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowAllStyle, SIGNAL(toggled(bool)), this, SLOT(ShowAllStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); connect(mUI.mActionToolbar, SIGNAL(toggled(bool)), this, SLOT(ToggleToolbar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); CreateLanguageMenuItems(); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { DoCheckFiles(args); } }
int main (void) { SHORT ix, iy; SHORT iwidth, idepth; SWP swp; ULONG ulResult; int iRes; static CHAR szClientClass[]="ZIN"; static ULONG flFrameFlags= FCF_TITLEBAR | FCF_SYSMENU | FCF_TASKLIST | FCF_ICON | FCF_SHELLPOSITION| FCF_BORDER | FCF_NOBYTEALIGN; hab=WinInitialize(0); hmq=WinCreateMsgQueue(hab, 0); //Register processing class WinRegisterClass( hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0); //Create Window hwndFrame=WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE, &flFrameFlags, szClientClass, NULL, 0L, 0, //Module handle for resources ID_RESOURCE, //ID of resources &hwndClient); //Size window WinSetWindowPos( hwndFrame, HWND_TOP, 0, 0, 640, 480, SWP_SIZE ); //Center window iwidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); idepth = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); WinQueryWindowPos( hwndFrame, (PSWP)&swp ); ix = (SHORT)(( iwidth - swp.cx ) / 2); iy = (SHORT)(( idepth - swp.cy ) / 2); WinSetWindowPos( hwndFrame, HWND_TOP, ix, iy, 0, 0, SWP_MOVE ); //Set focus to edit window. WinSetFocus(HWND_DESKTOP,hwndClient); //Load application title WinLoadString(hab, 0, ID_APPNAME, LITTLEBUF, (PSZ) szAppName); //Set title of frame. WinSetWindowText(hwndFrame, (PSZ) szAppName); //Show the window WinShowWindow(hwndFrame,TRUE); //Get source directory. GetCurrentDirectory(szSourceDir); //Load first message FIRSTMSG: usResponse=MsgBox(ID_FIRSTMSG, ID_APPNAME, MB_OKCANCEL); WinUpdateWindow(hwndClient); if (usResponse==MBID_OK) { //Show readme.txt file ulResult=WinDlgBox(HWND_DESKTOP, hwndClient, ReadmeDlgProc, NULLHANDLE, IDD_README, NULL); if (ulResult==FALSE) { //The installation has been cancelled. usResponse=MsgBox(ID_CANCELINSTALL, ID_APPNAME, MB_OK); goto END_INSTALL; } ulResult=WinDlgBox(HWND_DESKTOP, hwndClient, GetDirDlgProc, NULLHANDLE, IDD_GETDIR, NULL); if (ulResult==FALSE) goto FIRSTMSG; //Update the window WinUpdateWindow(hwndClient); //Load status dialog LoadStatusDlg(); //Make sure all files exist iRes=CheckFiles(szSourceDir); if (iRes!=0) { DestroyStatusDlg(); usResponse=MsgBox(ID_FILENOTFOUND, ID_APPNAME, MB_OK); goto END_INSTALL; } //Copy the files iRes=CopyFiles(szSourceDir, szInstallDir); if (iRes!=0) { DestroyStatusDlg(); usResponse=MsgBox(ID_FILESNOTCOPIED, ID_APPNAME, MB_OK); goto END_INSTALL; } iRes=PatchZed(szInstallDir); if (iRes!=0) { DestroyStatusDlg(); usResponse=MsgBox(ID_PATCHFAILED, ID_APPNAME, MB_OK); goto END_INSTALL; } iRes=CreateObject(szInstallDir); if (iRes!=0) usResponse=MsgBox(ID_CANTCREATEOBJECT, ID_APPNAME, MB_OK); //unload status window DestroyStatusDlg(); //Update the window WinUpdateWindow(hwndClient); //Success usResponse=MsgBox(ID_SUCCESS, ID_APPNAME, MB_OK); goto END_INSTALL; //Main message loop while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg(hab, &qmsg); } if (usResponse==MBID_CANCEL) { //The installation has been cancelled. usResponse=MsgBox(ID_CANCELINSTALL, ID_APPNAME, MB_OK); } END_INSTALL: //Cleanup WinDestroyWindow(hwndFrame); WinDestroyMsgQueue(hmq); WinTerminate(hab); //End return 0; }
/*---------------------------------------------------------------------------------* FUNCTION : main Purpose : program entry point Arguments : argc - argument count Globals : none Return : 0 for successful execution none-zero for any error *---------------------------------------------------------------------------------*/ int main(int argc, char *argv[]) { CONVERT *cp=NULL; WAVEHEADER *whp1=NULL, *whp2=NULL; int fd1=0, fd2=0, i; long total_bytes_written=0; cp = ConvertCreate(inputBuffer, outputBuffer); /* intialize the CONVERT structure */ ParseCommandLine(argc,argv, cp); /* parse the command line options */ CheckFiles(cp); /* validate the input/output file */ fd1=_open(cp->inputFilename,_O_RDONLY | _O_BINARY ); if(fd1==-1) Error("Opening INPUT FILE \"%s\" \n",cp->inputFilename); fd2=_open(cp->outputFilename,_O_WRONLY | _O_CREAT | _O_EXCL | _O_BINARY, _S_IREAD | _S_IWRITE); if( errno == EEXIST ) /* if OVERWRITE option not specified, give prompt */ { char ch; if (cp->overWrite == FALSE) { fprintf(stderr, "Target %s exists. Overwrite? ", cp->outputFilename ); ch = getch(); if( (ch == 'y') || (ch == 'Y') ) fd2 = _open( cp->outputFilename, _O_BINARY | _O_WRONLY | _O_CREAT | _O_TRUNC, _S_IREAD | _S_IWRITE ); else return 0; fprintf(stderr, "\n" ); } else if (cp->overWrite == TRUE) fd2 = _open( cp->outputFilename, _O_BINARY | _O_WRONLY | _O_CREAT | _O_TRUNC, _S_IREAD | _S_IWRITE ); } else if(fd2==-1) Error("Opening OUTPUT FILE \"%s\" \n",cp->outputFilename); /* if output type is specified as WAV 8/16 bit, set the WAV format header */ if( (cp->outputType == WAV8) || (cp->outputType == WAV16) ) { long nSamplesPerSec=11025; int wBitsPerSample= (cp->outputType==WAV8)? 8: 16; switch(cp->outputSampleRate) { case 11: nSamplesPerSec = 11025; break; case 22: nSamplesPerSec = 22050; break; case 44: nSamplesPerSec = 44100; break; } whp2 = CreateWaveHeader( nSamplesPerSec, wBitsPerSample ); if( _write(fd2, whp2, sizeof(WAVEHEADER)) == -1 ) Error("Writing OUTPUT FILE %s",cp->outputFilename); } /* this is done again for input type WAVxx, since we'll be checking the input file */ /* if input type is specified as WAV 8/16 bit, set the WAV format header, check it against actual input file */ if( (cp->inputType == WAV8) || (cp->inputType == WAV16) ) { whp1 = CreateWaveHeader( 0L, 0 ); if( _read(fd1, whp1, sizeof(WAVEHEADER)) == -1 ) Error("Reading INPUT FILE %s",cp->inputFilename); CheckWaveHeader(whp1); cp->inputType = (whp1->wBitsPerSample==8)? WAV8: WAV16; cp->inputSampleRate = (int)(whp1->nSamplesPerSec/1000L); SetRateType(cp); // if (cp->convertRateCb) CVC_ConvertDestroy(cp->convertRateCb); if(cp->rateType != CVT_CONV01TO01) cp->convertRateCb = CVC_ConvertCreate(cp->rateType); // if (cp->inputTypeCb) CVC_WaveDestroy(cp->inputTypeCb); if (cp->inputType == WAV8) { cp->inputTypeCb = CVC_WaveCreate(CVT_MONO08); cp->linInpRatio = 2.0; } else if (cp->inputType == WAV16) { cp->inputTypeCb = CVC_WaveCreate(CVT_MONO16); cp->linInpRatio = 1.0; } } /* calculate the maximum size allow per conversion in the loop */ cp->maxInpSize = min( (unsigned int)floor(INPBUFLEN/cp->linInpRatio), (unsigned int)floor((double)INPBUFLEN/cp->outputSampleRate*cp->inputSampleRate)); for (i=0; i < 24; i++) putchar('\n'); printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»\n"); printf("º RHETOREX º CONVERT UTILITY º Version: 1.00 º\n"); printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ\n"); printf(" input filename : %s\n", cp->inputFilename ); printf(" input type : %s\n", TypeStr(cp->inputType) ); printf(" input sample rate : %2d Khz\n", cp->inputSampleRate ); printf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n"); printf(" output filename : %s\n", cp->outputFilename ); printf(" output type : %s\n", TypeStr(cp->outputType) ); printf(" output sample rate : %2d Khz\n", cp->outputSampleRate ); printf("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\n"); printf("\n CONVERTING PLEASE WAIT \n"); /* read each block of data upto maxInpSize, do the conversion & write result to output file */ while((cp->inpBufSize=_read(fd1, inputBuffer,cp->maxInpSize<<1)) > 0) { cp->inpBufSize >>=1; cp->inpBufPtr=inputBuffer; cp->outBufPtr=outputBuffer; ConvertToLin(cp); /* 1st, convert it to LIN */ cp->inpBufPtr=outputBuffer; /* switch the input <-> output */ cp->outBufPtr=inputBuffer; cp->inpBufSize = *cp->outBufLen; ConvertRate(cp); /* 2nd, convert the LIN to appropriate rate */ cp->inpBufPtr=inputBuffer; /* switch the output <-> input */ cp->outBufPtr=outputBuffer; cp->inpBufSize = *cp->outBufLen; ConvertFromLin(cp); /* finally, convert LIN to destination format */ /* write output buffer to file */ total_bytes_written += _write(fd2, outputBuffer,sizeof(outputBuffer[0])*(*cp->outBufLen)); putchar('.'); } /* if ouput type is specified as WAV 8/16 bit, must update the header file size */ if( (cp->outputType == WAV8) || (cp->outputType == WAV16) ) UpdateWaveHeaderSize(cp->outputFilename, total_bytes_written); printf("\n\n"); printf("------------------------------------------------------------------------------\n"); printf(" input file length : %5ld bytes\n", _filelength(fd1) ); printf(" output file length : %5ld bytes\n", _filelength(fd2) ); printf("------------------------------------------------------------------------------\n"); /* close file descriptors used and free all structures */ _close(fd1); _close(fd2); ConvertDestroy(cp); if (whp1) DestroyWaveHeader(whp1); if (whp2) DestroyWaveHeader(whp2); return 0; }