void AnalyzeTask::run_ex(void)
{
	int fileType = fileTypeNormal;
	QString currentFile = QDir::fromNativeSeparators(m_inputFile);
	qDebug("Analyzing: %s", MUTILS_UTF8(currentFile));
	
	AudioFileModel fileInfo(currentFile);
	analyzeFile(currentFile, fileInfo, &fileType);

	if(MUTILS_BOOLIFY(m_abortFlag))
	{
		qWarning("Operation cancelled by user!");
		return;
	}

	switch(fileType)
	{
	case fileTypeDenied:
		qWarning("Cannot access file for reading, skipping!");
		break;
	case fileTypeCDDA:
		qWarning("Dummy CDDA file detected, skipping!");
		break;
	default:
		if(fileInfo.metaInfo().title().isEmpty() || fileInfo.techInfo().containerType().isEmpty() || fileInfo.techInfo().audioType().isEmpty())
		{
			fileType = fileTypeUnknown;
			if(!QFileInfo(currentFile).suffix().compare("cue", Qt::CaseInsensitive))
			{
				qWarning("Cue Sheet file detected, skipping!");
				fileType = fileTypeCueSheet;
			}
			else if(!QFileInfo(currentFile).suffix().compare("avs", Qt::CaseInsensitive))
			{
				qDebug("Found a potential Avisynth script, investigating...");
				if(analyzeAvisynthFile(currentFile, fileInfo))
				{
					fileType = fileTypeNormal;
				}
				else
				{
					qDebug("Rejected Avisynth file: %s", MUTILS_UTF8(fileInfo.filePath()));
				}
			}
			else
			{
				qDebug("Rejected file of unknown type: %s", MUTILS_UTF8(fileInfo.filePath()));
			}
		}
		break;
	}

	//Emit the file now!
	emit fileAnalyzed(m_taskId, fileType, fileInfo);
}
Example #2
0
int		main(int ac, char **av)
{
	t_d		d;

	if (ac != 2)
		exitProg("Please, add one file after fdf.\n");
	if (analyzeFile(ac, av, &d))
		exitProg("Map specify may have incorrect values or error when reading file.\n");
/*	if ((d.mlx = mlx_init()) == NULL)
		exitProg("Fail to init the minilibx library.\n");
	if ((d.win = mlx_new_window(d.mlx, 500, 500, av[1])) == NULL)
		exitProg("Fail to open a new window.\n");
	mlx_mouse_hook(d.win, mouse_click, &d);
	mlx_key_hook(d.win, key_press, &d);
	//mlx_expose_hook(d.win, expose_hook, &d);
	mlx_loop(d.mlx);
*/	return (EXIT_SUCCESS);
}
Example #3
0
int main(int argc, char* argv[]) {
   HumdrumFileSet infiles;

   // process the command-line options
   checkOptions(options, argc, argv);

   string filename = "";
   int i;

   Array<int> pc12;  // twelve-tone pitch-class note histogram
   Array<int> pc40;  // base-40 enharmonic pitch-class note histogram

   pc12.setSize(12);
   pc12.allowGrowth(0);
   pc12.setAll(0);

   pc40.setSize(40);
   pc40.allowGrowth(0);
   pc40.setAll(0);

   int numinputs = options.getArgCount();

   if (numinputs < 1) {
      infiles.read(cin);
   } else {
      for (i=0; i<numinputs; i++) {
         infiles.readAppend(options.getArg(i+1));
      }
   }

   for (i=0; i<infiles.getCount(); i++) {
      if (suppressQ) {
         filename = "";
      } else {
         filename = infiles[i].getFilename();
      }
      analyzeFile(infiles[i], pc12, pc40);
      printAnalysis(infiles[i], pc12, pc40, filename);
   }

   return 0;
}
Example #4
0
bool TirFwExtractThread::findCandidates(QString name)
{
  if(quit) return false;
  int i;
  QDir dir(name);
  QStringList patt;
  patt<<QString::fromUtf8("*.dll")<<QString::fromUtf8("*.exe")<<QString::fromUtf8("*.dat");
  QFileInfoList files = dir.entryInfoList(patt, QDir::Files | QDir::Readable);
  for(i = 0; i < files.size(); ++i){
    if(quit) return false;
    if(files[i].fileName().compare(QString::fromUtf8("TIRViews.dll")) == 0){
      QString outfile = QString::fromUtf8("%1/TIRViews.dll").arg(destPath);
      if((tirviewsFound = QFile::copy(files[i].canonicalFilePath(), outfile))){
        emit progress(QString::fromUtf8("Extracted TIRViews.dll..."));
      }
    }else if(files[i].fileName().compare(QString::fromUtf8("sgl.dat"))){
      analyzeFile(files[i].canonicalFilePath());
    }else{
      QString outfile = QString::fromUtf8("%1/gamedata.txt").arg(destPath);
      gameDataFound = get_game_data(files[i].canonicalFilePath().toUtf8().constData(),
                                    outfile.toUtf8().constData(), false);
      emit progress(QString::fromUtf8("Extracted game data..."));
    }
    if(allFound()){
      return true;
    }
  }

  QFileInfoList subdirs =
    dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
  QString dirname;
  for(i = 0; i < subdirs.size(); ++i){
    dirname = subdirs[i].canonicalFilePath();
    if((!dirname.endsWith(QString::fromUtf8("windows"))) && findCandidates(dirname)){
      return true;
    }
  }
  return false;
}
Example #5
0
int runIntegrationTest(const char *testName, CharString testArguments,
                       ReturnCode expectedResultCode,
                       const TestOutputType testOutputType,
                       const CharString mrsWatsonExePath,
                       const CharString resourcesPath) {
  int result = 0;
  int returnCode;
  ReturnCode resultCode;
  ChannelCount failedAnalysisChannel;
  SampleCount failedAnalysisFrame;

#if WINDOWS
  STARTUPINFOA startupInfo;
  PROCESS_INFORMATION processInfo;
#endif

  // Remove files from a previous test run
  File outputFolder = newFileWithPathCString(kApplicationRunnerOutputFolder);

  if (fileExists(outputFolder)) {
    _removeOutputFiles(testName);
  } else {
    fileCreate(outputFolder, kFileTypeDirectory);
  }

  freeFile(outputFolder);

  if (mrsWatsonExePath == NULL) {
    return -1;
  } else {
    File mrsWatsonExe = newFileWithPath(mrsWatsonExePath);
    boolByte mrsWatsonExeExists = fileExists(mrsWatsonExe);
    freeFile(mrsWatsonExe);

    if (!mrsWatsonExeExists) {
      freeCharString(testArguments);
      return -1;
    }
  }

  if (resourcesPath == NULL) {
    freeCharString(testArguments);
    return -1;
  } else {
    File resourcesFile = newFileWithPath(resourcesPath);
    boolByte resourcesExists = fileExists(resourcesFile);
    freeFile(resourcesFile);

    if (!resourcesExists) {
      freeCharString(testArguments);
      return -1;
    }
  }

  // Create the command line argument
  CharString arguments = newCharStringWithCapacity(kCharStringLengthLong);
  charStringAppendCString(arguments, "\"");
  charStringAppend(arguments, mrsWatsonExePath);
  charStringAppendCString(arguments, "\"");
  charStringAppendCString(arguments, " ");
  CharString defaultArguments;
  CharString outputFilename = getTestOutputFilename(testName, testOutputType);
  defaultArguments =
      _getDefaultArguments(testName, resourcesPath, outputFilename);
  charStringAppend(arguments, defaultArguments);
  freeCharString(defaultArguments);
  charStringAppendCString(arguments, " ");
  charStringAppend(arguments, testArguments);
  // Although testArguments is passed into this function (and hence, it would
  // generally not take ownership of it), in this case we free the arguments
  // here to make writing the test cases simpler and reduce the amount of
  // boilerplate code.
  freeCharString(testArguments);

#if WINDOWS
  memset(&startupInfo, 0, sizeof(startupInfo));
  memset(&processInfo, 0, sizeof(processInfo));
  startupInfo.cb = sizeof(startupInfo);
  returnCode = CreateProcessA(
      (LPCSTR)(mrsWatsonExePath->data), (LPSTR)(arguments->data), 0, 0, false,
      CREATE_DEFAULT_ERROR_MODE, 0, 0, &startupInfo, &processInfo);

  if (returnCode) {
    // TODO: Check return codes for these calls
    WaitForSingleObject(processInfo.hProcess,
                        kApplicationRunnerWaitTimeoutInMs);
    GetExitCodeProcess(processInfo.hProcess, (LPDWORD)&resultCode);
    CloseHandle(processInfo.hProcess);
    CloseHandle(processInfo.hThread);
  } else {
    logCritical("Could not launch process, got error %s",
                stringForLastError(GetLastError()));
    return 1;
  }

#else
  returnCode = system(arguments->data);
  resultCode = (ReturnCode)WEXITSTATUS(returnCode);
#endif
  freeCharString(arguments);

  if (resultCode == RETURN_CODE_FORK_FAILED ||
      resultCode == RETURN_CODE_SHELL_FAILED ||
      resultCode == RETURN_CODE_LAUNCH_FAILED_OTHER) {
    logCritical("Could not launch shell, got return code %d\n\
Please check the executable path specified in the --mrswatson-path argument.",
                resultCode);
    return 1;
  } else if (resultCode == expectedResultCode) {
    CharString failedAnalysisFunctionName = newCharString();
    if (testOutputType != kTestOutputNone) {
      if (analyzeFile(outputFilename->data, failedAnalysisFunctionName,
                      &failedAnalysisChannel, &failedAnalysisFrame)) {
        // TODO:
        //                if (!testEnvironment->results->keepFiles) {
        //                    _removeOutputFiles(testName);
        //                }
        result = 0;
      } else {
        fprintf(stderr,
                "Audio analysis check for %s failed at frame %lu, channel %d. ",
                failedAnalysisFunctionName->data, failedAnalysisFrame,
                failedAnalysisChannel);
        result = 1;
      }
    } else {
      result = 0;

      // TODO:
      //            if (!testEnvironment->results->keepFiles) {
      //                _removeOutputFiles(testName);
      //            }
    }
    freeCharString(failedAnalysisFunctionName);
  } else {
    fprintf(stderr, "Expected result code %d (%s), got %d (%s). ",
            expectedResultCode, _getResultCodeString(expectedResultCode),
            resultCode, _getResultCodeString(resultCode));
    result = 1;
  }

  freeCharString(outputFilename);
  return result;
}
Example #6
0
File: main.c Project: IUNIXI/LxNAND
void prompt(int menu)
{
    	console_clrscr();
        
        switch (menu)
        {
            case MAIN_MENU:{            
                printf("\n  LibXenon NANDFlasher v%s  \n",version);
                printf("  **************************\n\n");
                printf("Flashconfig 0x%08X\n",flashconfig);
                printf("NAND-Size %i MB\n\n",sfc.size_mb);
                printf("Press A to save NAND to file on USB.\n");
                printf("Press X to write file from USB to NAND.\n");
                printf("Press B to analyze NAND.\n");
                printf("Press Y to update XeLL.\n");
                printf("Press START for DMA test.\n");
                printf("Press GUIDE to return to XeLL.\n");
        
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a))
                        prompt(DUMP_SUBMENU);

                    if((button.x)&&(!controller.x))
                        writeNand("uda:/updflash.bin");

                    if((button.b)&&(!controller.b))
                        prompt(ANALYZE_SUBMENU);
                               
                    if((button.y)&&(!controller.y))
                        updateXeLL("uda:/updxell.bin");
                    
                    if((button.start)&&(!controller.start))                    
                        dmatest();
                    
                    if((button.logo)&&(!controller.logo))
                        break;
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
            case DUMP_SUBMENU:{
                
                int nand_sz = sfc.size_bytes;
                
                if (nand_sz != NAND_SIZE_256MB && nand_sz != NAND_SIZE_512MB)
                    readNand("uda:/flashdmp.bin", FULL_DUMP);
                
                printf("\n         DUMP MENU          \n");
                printf("  **************************\n\n");
                printf("Press A to dump whole NAND.\n");
                printf("Press B to dump only flash-partition.\n");
                printf("Press BACK to go back to main menu.\n");
                
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a))
                        readNand("uda:/flashdmp.bin", FULL_DUMP);

                    if((button.b)&&(!controller.b))
                        readNand("uda:/flashdmp.bin", BB64MB_ONLY);
                               
                    if((button.select)&&(!controller.select))
                        prompt(MAIN_MENU);
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
            case ANALYZE_SUBMENU:{
                
                printf("\n       ANALYZE MENU        \n");
                printf("  **************************\n\n");
                printf("Press A to analyze physical NAND.\n");
                printf("Press B to analyze file updflash.bin.\n");
                printf("Press BACK to go back to main menu.\n");
                
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a))
                        prompt(ANALYZE_PHYS_SUBMENU);

                    if((button.b)&&(!controller.b))
                        prompt(ANALYZE_FILE_SUBMENU);
                               
                    if((button.select)&&(!controller.select))
                        prompt(MAIN_MENU);
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
            case ANALYZE_PHYS_SUBMENU:{
                
                int nand_sz = sfc.size_bytes;
                int blocks = sfc.size_blocks;
                if (nand_sz == NAND_SIZE_256MB || nand_sz == NAND_SIZE_512MB)
                    blocks = 0x200;
                
                printf("\n       ANALYZE NAND       \n");
                printf("  **************************\n\n");
                printf("Press A to scan for Bad Blocks.\n");
                printf("Press B to scan for Bad Blocks and EDC errors.\n");
                printf("Press BACK to go back to main menu.\n");
                
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a)){
                        analyzeNand(0,blocks,0);
                        printReport(BBMnand);
                        waitforexit();
                    }

                    if((button.b)&&(!controller.b)){
                        analyzeNand(0,blocks,1);
                        printReport(BBMnand);
                        waitforexit();
                    }
                               
                    if((button.select)&&(!controller.select))
                        prompt(MAIN_MENU);
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
            case ANALYZE_FILE_SUBMENU:{
                
                int nand_sz = sfc.size_bytes;
                int blocks = sfc.size_blocks;
                if (nand_sz == NAND_SIZE_256MB || nand_sz == NAND_SIZE_512MB)
                    blocks = 0x200;
                
                printf("\n       ANALYZE FILE        \n");
                printf("  **************************\n\n");
                printf("Press A to scan for Bad Blocks.\n");
                printf("Press B to scan for Bad Blocks and EDC errors.\n");
                printf("Press BACK to go back to main menu.\n");
                
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a)){
                        analyzeFile("uda:/updflash.bin",0,blocks, 0);
                        printReport(BBMfile);
                        waitforexit();
                    }

                    if((button.b)&&(!controller.b)){
                        analyzeFile("uda:/updflash.bin",0,blocks, 1);
                        printReport(BBMfile);
                        waitforexit();
                    }
                               
                    if((button.select)&&(!controller.select))
                        prompt(MAIN_MENU);
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
        }
        return 0;
}
void runApplicationTest(char *applicationPath, const char *testName, LinkedList testArguments, ReturnCodes expectedResultCode, boolByte anazyleOutput) {
  char** applicationArguments;
  ArgumentsCopyData argumentsCopyData;
  int resultCode = -1;
  LinkedList defaultArguments = getDefaultArguments(testName);
  LinkedList arguments = _appendLinkedLists(defaultArguments, testArguments);
  CharString failedAnalysisFunctionName = newCharString();
  unsigned long failedAnalysisSample;

  // Remove any output files which may have been left from previous tests
  foreachItemInList(defaultArguments, _removeOutputFile, NULL);

#if WINDOWS
#else
  mkdir("out", 0755);
#endif

#if WINDOWS
  logUnsupportedFeature("Application testing");
#else
  int numArgs = numItemsInList(arguments);
  // Add two extra items to the array, one for the application path and another for a NULL object.
  // These are required for the calls to the execv* functions.
  applicationArguments = (char**)malloc(sizeof(char*) * (numArgs + 2));
  applicationArguments[0] = applicationPath;
  applicationArguments[numArgs + 1] = NULL;
  argumentsCopyData.currentIndex = 1;
  argumentsCopyData.outArray = applicationArguments;
  foreachItemInList(arguments, _copyArgumentToArray, &argumentsCopyData);
  printf("  %s: ", testName);

  pid_t forkedPid = fork();
  if(forkedPid == 0) {
    resultCode = execvp(applicationPath, applicationArguments);
    exit(resultCode);
  }
  else {
    int statusLoc;
    waitpid(forkedPid, &statusLoc, 0);
    if(WIFEXITED(statusLoc)) {
      resultCode = WEXITSTATUS(statusLoc);
    }
  }
#endif

  if(resultCode == expectedResultCode) {
    if(anazyleOutput) {
      if(analyzeFile(_getTestOutputFilename(testName, "pcm"), failedAnalysisFunctionName, &failedAnalysisSample)) {
        testsPassed++;
        foreachItemInList(defaultArguments, _removeOutputFile, NULL);
        printTestSuccess();
      }
      else {
        printTestFail();
        printf("    in test '%s', while analyzing output for %s at sample %lu.\n",
          testName, failedAnalysisFunctionName->data, failedAnalysisSample);
        testsFailed++;
      }
    }
    else {
      testsPassed++;
      foreachItemInList(defaultArguments, _removeOutputFile, NULL);
      printTestSuccess();
    }
  }
  else {
    printTestFail();
    printf("    in %s. Expected result code %d, got %d.\n", testName, expectedResultCode, resultCode);
    testsFailed++;
  }

  freeLinkedList(defaultArguments);
  freeLinkedList(testArguments);
  freeLinkedList(arguments);
}