Ejemplo n.º 1
0
CurveletGUI::CurveletGUI(QWidget *parent)
: QMainWindow(parent)
{
	this->resize(800,600);
	this->FileListView = new QListWidget;
	this->FileListView->isSortingEnabled();
	this->setCentralWidget(this->FileListView);
	this->InputFileList.clear();
	QToolBar * mainToolBar = new QToolBar(this);

	this->exitAction = new QAction(tr("Exit"), this);
	connect(this->exitAction, SIGNAL(triggered()), this, SLOT(close()));
	this->exitAction->setShortcut(QKeySequence::Close);
	this->menuBar()->addAction(this->exitAction);

	this->loadImages = new QAction("Load Images", this);
	connect(this->loadImages, SIGNAL(triggered()), this, SLOT(BrowseFiles()));
	this->menuBar()->addAction(this->loadImages);

	this->ProcessImages = new QAction("Run Curvelets on Images", this);
	connect(this->ProcessImages, SIGNAL(triggered()), this, SLOT(ProcessFiles()));
	this->ProcessImages->setEnabled(false);
	this->menuBar()->addAction(this->ProcessImages);

	this->SigmaValue = new QDoubleSpinBox(this);
	this->SigmaValue->setRange(0,1);
	this->SigmaValue->setValue(.03);
	this->SigmaValue->setSingleStep(.01);
	mainToolBar->addWidget(new QLabel("Sigma Value: "));
	mainToolBar->addWidget(this->SigmaValue);
	this->addToolBar(mainToolBar);
}
Ejemplo n.º 2
0
static void ProcessFilename(char *name) {
   char buffer[1000];

   FILE *in, *out;

   strcpy(buffer, name);
   if (strlen(buffer) > 4 && strcmp(buffer + strlen(buffer) - 4, ".sfd") == 0)
      strcpy(buffer + strlen(buffer) - 4, "-new.sfd");
   else
      strcat(buffer, "-new");
   in = fopen(name, "r");
   if (in == NULL) {
      fprintf(stderr, "Could not open %s for reading\n", name);
      exit(1);
   }
   out = fopen(buffer, "w");
   if (out == NULL) {
      fclose(in);
      fprintf(stderr, "Could not open %s for writing\n", buffer);
      exit(1);
   }
   ProcessFiles(in, out);
   fclose(in);
   fclose(out);
}
Ejemplo n.º 3
0
void FileGrabber::Init(const string &path, FrameGrabber *frame_grabber)
{
  ProcessFiles(path);

  frame_grabber_  = frame_grabber;
  initialised_    = true;

  fg_thread_ = boost::thread(boost::ref(*this));
}
Ejemplo n.º 4
0
int main(int argc, char **argv) {
   int i;

   if (argc == 1)
      ProcessFiles(stdin, stdout);
   else {
      for (i = 1; i < argc; ++i)
	 ProcessFilename(argv[i]);
   }
   return (0);
}
Ejemplo n.º 5
0
void CMainDlg::OnProcess()
{
	UpdateData(TRUE);
	if (ProcessFiles(m_sFileIn, m_sFileOut) != TRUE)
	{
		MessageBox(L"Обработка файлов завершилась с ошибкой!", L"Ошибка", MB_OK | MB_ICONERROR);
	}
	else
	{
		MessageBox(L"Файлы обработаны успешно!", L"Информация", MB_OK | MB_ICONINFORMATION);
	}
}
Ejemplo n.º 6
0
BOOL
ProcessDirectories(LPTSTR Path)
{
  WIN32_FIND_DATA FindFile;
  TCHAR SearchPath[MAX_PATH];
  HANDLE SearchHandle;
  BOOL More;

  if(!BeSilent)
  {
    _tprintf (_T("Processing %s ...\n"), Path);
  }

  _tcscpy (SearchPath, Path);
  _tcscat (SearchPath, _T("\\*.*"));

  SearchHandle = FindFirstFileEx (SearchPath,
    FindExInfoStandard,
    &FindFile,
    FindExSearchLimitToDirectories,
    NULL,
    0);
  if (SearchHandle != INVALID_HANDLE_VALUE)
  {
    More = TRUE;
    while (More)
    {
	    if ((FindFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
      && (_tcscmp (FindFile.cFileName, _T(".")) != 0)
      && (_tcscmp (FindFile.cFileName, _T("..")) != 0)
      && (_tcscmp (FindFile.cFileName, _T("CVS")) != 0)
      && (_tcscmp (FindFile.cFileName, _T(".svn")) != 0))
			{
			  _tcscpy (SearchPath, Path);
			  _tcscat (SearchPath, _T("\\"));
			  _tcscat (SearchPath, FindFile.cFileName);
	      if (!ProcessDirectories (SearchPath))
          return FALSE;
	      if (!ProcessFiles (SearchPath))
          return FALSE;
			}
      More = FindNextFile (SearchHandle, &FindFile);
    }
    FindClose (SearchHandle);
  }
  return TRUE;
}
Ejemplo n.º 7
0
void FileGrabber::ProcessFiles(const boost::filesystem::path &directory)
{
  if (exists(directory)) {
    boost::filesystem::directory_iterator end;

    for (boost::filesystem::directory_iterator iter(directory); iter!=end; ++iter) {
      if (is_directory(*iter)) {
        ProcessFiles(*iter);
      } else {
        string  path_name = iter->path().string();

        files_vec_.push_back(path_name);
      }
    }

    sort(files_vec_.begin(), files_vec_.end());
  }
}
Ejemplo n.º 8
0
int CTorrentBuilder::Run()
{
    if ( m_pSection.Lock() )
    {
        m_nTotalSize	= 0;
        m_nTotalPos		= 0;
        m_pFileSize		= NULL;
        m_pFileSHA1		= NULL;
        m_pFileED2K		= NULL;
        m_pFileMD5		= NULL;
        m_pPieceSHA1	= NULL;
        m_pSection.Unlock();
    }

    if ( ScanFiles() && ! m_bAbort )
    {
        if ( ProcessFiles() && WriteOutput() )
            m_bFinished = TRUE;
    }

    if ( m_pSection.Lock() )
    {
        delete [] m_pPieceSHA1;
        m_pPieceSHA1 = NULL;
        delete [] m_pFileMD5;
        m_pFileMD5 = NULL;
        delete [] m_pFileED2K;
        m_pFileED2K = NULL;
        delete [] m_pFileSHA1;
        m_pFileSHA1 = NULL;
        delete [] m_pFileSize;
        m_pFileSize = NULL;

        m_sThisFile.Empty();
        m_bActive = FALSE;

        m_pSection.Unlock();
    }

    return 0;
}
bool ProjectOptionsManipulator::OperateProject(cbProject* prj, wxArrayString& result)
{
  if (!prj) return false;

  ProjectOptionsManipulatorDlg::EProjectScanOption scan_opt = m_Dlg->GetScanOption();
  if (scan_opt==ProjectOptionsManipulatorDlg::eFiles)
    ProcessFiles(prj, result);
  else
  {
    const wxString src = m_Dlg->GetSearchFor();
    const wxString dst = m_Dlg->GetReplaceWith();
    const wxString val = m_Dlg->GetCustomVarValue();

    if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eCompiler) )
      ProcessCompilerOptions(prj, src, dst, result);

    if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eLinker) )
      ProcessLinkerOptions(prj, src, dst, result);

    if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eResCompiler) )
      ProcessResCompilerOptions(prj, src, dst, result);

    if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eCompilerPaths) )
      ProcessCompilerPaths(prj, src, dst, result);

    if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eLinkerPaths) )
      ProcessLinkerPaths(prj, src, dst, result);

    if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eResCompPaths) )
      ProcessResCompPaths(prj, src, dst, result);

    if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eLinkerLibs) )
      ProcessLinkerLibs(prj, src, dst, result);

    if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eCustomVars) )
      ProcessCustomVars(prj, src, val, result);
  }

  return true;
}
Ejemplo n.º 10
0
VOID
Execute(LPTSTR Path)
{
  if (!ExtInfoList)
  {
	  _tprintf (_T("No extensions specified.\n"));
    return;
  }

  if (!ProcessDirectories (Path))
  {
	  _tprintf (_T("Failed to process directories.\n"));
    return;
  }

  if (!ProcessFiles (Path))
  {
	  _tprintf (_T("Failed to process files.\n"));
    return;
  }

  PrintStatistics();
}
Ejemplo n.º 11
0
  bool Preprocess::Import(const TypeConfigRef& typeConfig,
                          const ImportParameter& parameter,
                          Progress& progress)
  {
    bool     result=false;
    Callback callback(typeConfig,
                      parameter,
                      progress);

    if (!callback.Initialize()) {
      return false;
    }

    result=ProcessFiles(typeConfig,
                        parameter,
                        progress,
                        callback);

    if (!callback.Cleanup(result)) {
      return false;
    }

    return result;
  }
Ejemplo n.º 12
0
ImageFileManger::ImageFileManger(QWidget *parent)
: QMainWindow(parent)
{
	this->FileListView = new QListWidget;
	this->FileListView->isSortingEnabled();
	this->setCentralWidget(this->FileListView);
	this->InputFileList.clear();

	this->exitAction = new QAction(tr("Exit"), this);
	connect(this->exitAction, SIGNAL(triggered()), this, SLOT(close()));
	this->exitAction->setShortcut(QKeySequence::Close);
	this->menuBar()->addAction(this->exitAction);

	this->loadImages = new QAction("Load Images", this);
	connect(this->loadImages, SIGNAL(triggered()), this, SLOT(BrowseFiles()));
	this->menuBar()->addAction(this->loadImages);

	this->append = new QAction("Append L Measure txt", this);
	connect(this->append, SIGNAL(triggered()), this, SLOT(appendLists()));
	this->menuBar()->addAction(this->append);

	this->StartPreprocessing = new QAction("Preprocess..", this);
	connect(this->StartPreprocessing, SIGNAL(triggered()), this, SLOT(Preprocess()));
	this->StartPreprocessing->setEnabled(false);
	this->menuBar()->addAction(this->StartPreprocessing);

	preprocessdialog = new PreprocessDialog("",this);

	this->ProcessImages = new QAction("Process Images", this);
	connect(this->ProcessImages, SIGNAL(triggered()), this, SLOT(ProcessFiles()));
	this->ProcessImages->setEnabled(false);
	this->menuBar()->addAction(this->ProcessImages);

	this->outputDirectories;
	this->outputDirectories << "DAPI" << "Cy5"<< "TRITC"<<"GFP";
}
Ejemplo n.º 13
0
int main(int argc, char **argv)
{
    char *  psz;
    int     argi;
    int     argi1st = -1;
    int     i;
    APIRET  rc;


    /*
     * Parse commandline
     */
    if (argc == 1)
    {
        syntax();
        return -1;
    }

    for (argi = 1; argi < argc; argi++)
    {
        if ((argv[argi][0] == '-')||(argv[argi][0] == '/'))
        {
            switch (argv[argi][1])
            {
                case 'h':
                case 'H':
                case '?':
                case '-':
                    syntax();
                    return 0;


                case 's':
                case 'S':
                case 'q':
                case 'Q':
                    options.fQuiet = argv[argi][2] != '-';
                    break;

                default:
                  // Invalid parameter
                  cmd_ShowSystemMessage(MSG_BAD_PARM1, 0);
                  return -1;
            }
        }
        else if (argi1st == -1)
        {
            argi1st = argi;
        }
        else
        {
            /*
             * Bind files.
             */
            rc = ProcessFiles(argv[argi1st], argv[argi]);
            if (rc)
            {
                fprintf(stderr, "Failed to process files '%s' / '%s'. SYS%04d\n",
                        argv[argi1st], argv[argi], rc);
                return -4;
            }
            argi1st = -1;
        }
    }


    /*
     * Check if no second filepattern.
     */
    if (argi1st != -1)
    {
        fprintf(stderr, "Must specify an even number of filepatterns.");
        return -4;
    }

    return cErrors;
}
Ejemplo n.º 14
0
int main (int argc, char* argv[])
{
	int option_index = 0;
	BGPDATA BGP;
	Initialize(BGP);
	int help = 0;
	while (1) {
                static struct option long_options[] = {
			{"verbose", no_argument, &BGP.verbose, 1},
			{"or", no_argument, &BGP.or_flag, 1},
			{"help", no_argument, &help, 1},
                        {"cidrfile",required_argument,0, 'a'},
                        {"update",required_argument,0, 'b'},
                        {"dir",required_argument,0, 'c'},
			{"startdate",required_argument,0,'d'},
			{"enddate",required_argument,0,'e'},
			{"asnfile",required_argument,0,'f'},
			{"outfile",required_argument,0,'g'},
			{"file",required_argument,0,'h'},
                        {0, 0, 0, 0}
                };
                int c = getopt_long(argc, argv, "", long_options,&option_index);
                if (c == -1) break;
                switch(c) {
			case 0:
				break;
			case 'a':
				BGP.setfile = optarg;
				break;
			case 'b':
				BGP.bgpfile.push_back(optarg);
				break;
			case 'c':
				BGP.dir.push_back(optarg);
				break;
			case 'd':
				BGP.startdate = optarg;
				break;
			case 'e':
				BGP.enddate = optarg;
				break;
			case 'f':
				BGP.asnfile = optarg;
				break;
			case 'g':
				BGP.outfile = optarg;
				break;
			case 'h':
				BGP.file = optarg;
				break;
			default :
				print_help();
				exit(1);
		}
	}
	if (help) { 
		print_help();
		exit(1);
	}

	std::ofstream myFile;

	if(!BGP.outfile.empty()) {
		myFile.open(BGP.outfile.c_str(), std::ios::out);
	}

	std::ofstream &outFile = (BGP.outfile.empty() ? (std::ofstream&)cout : myFile);

	if (!BGP.setfile.empty()) {
		skipset_t *ipset = NULL;
		ReadFile(BGP.setfile,&ipset);
		BGP.ipset = ipset;
	}
	if (!BGP.asnfile.empty()) {
		ReadASNFile(BGP);
	}
	if (BGP.bgpfile.size() > 0) {
		vector<string>::iterator it;
		for (it = BGP.bgpfile.begin(); it != BGP.bgpfile.end(); it++) {
			ReadBGPFile(BGP,*it,outFile);
		}
		if (!BGP.outfile.empty()) {
			outFile.close();
		}
		exit(1);
	}
	if (!BGP.file.empty()) {
		ProcessFiles(BGP,outFile);
		exit(1);
	}
	if (BGP.startdate.empty() || BGP.enddate.empty() || BGP.dir.empty()) {
		print_help();
		exit(1);
	}

	if (BGP.startdate.length() != 8 || BGP.enddate.length() != 8) {
		cout << "The date format is YYYYMMDD and should be of length 8\n";
		exit(1);
	}
	if (!is_digits(BGP.startdate) || !is_digits(BGP.enddate)) {
		cout << "The date format is YYYYMMDD and should be all integers\n";
		exit(1);
	}
	if (BGP.startdate > BGP.enddate) {
		cout << "Start date must come before end date.\n";
		print_help();
		exit(1);
	}
	Traverse(BGP,BGP.startdate,outFile);
	if (BGP.enddate.compare(BGP.startdate) == 0) { exit(1); }
	string nextdate = NextDate(BGP.startdate);
	while (nextdate.compare(BGP.enddate) != 0) {
		Traverse(BGP,nextdate,outFile);
		nextdate = NextDate(nextdate);
	}
	Traverse(BGP,BGP.enddate,outFile);
	if (!BGP.outfile.empty()) {
		outFile.close();
	}

}
void
JXFSBindingManager::Receive
(
    JBroadcaster*	sender,
    const Message&	message
)
{
    if (sender == itsEditDialog && message.Is(JXDialogDirector::kDeactivated))
    {
        itsEditDialog = NULL;
    }

    else if (sender == itsRunFileDialog && message.Is(JXDialogDirector::kDeactivated))
    {
        const JXDialogDirector::Deactivated* info =
            dynamic_cast<const JXDialogDirector::Deactivated*>(&message);
        assert(info != NULL);
        if (info->Successful())
        {
            assert( HasFiles() );

            JFSBinding::CommandType type;
            JBoolean singleFile, saveBinding;
            const JString& cmd = itsRunFileDialog->GetCommand(&type, &singleFile, &saveBinding);

            if (itsIgnoreBindingsFlag && itsRunFileIndex == 1)
            {
                JSize count = itsFileList->GetElementCount();
                for (JIndex i=1; i<=count; i++)
                {
                    JFSBinding* f = itsFileList->NthElement(i);
                    f->SetCommand(cmd, type, singleFile);
                }
            }
            else
            {
                JFSBinding* f = itsFileList->NthElement(itsRunFileIndex);
                f->SetCommand(cmd, type, singleFile);
            }

            if (saveBinding)
            {
                JFSBinding* f = itsFileList->NthElement(itsRunFileIndex);
                SaveBinding(f->GetPattern(), cmd, type, singleFile);
            }

            itsRunFileDialog = NULL;
            ProcessFiles();
        }
        else
        {
            delete itsFileList;
            itsFileList      = NULL;
            itsRunFileDialog = NULL;
        }
    }

    else if (sender == itsRunScriptDialog && message.Is(JXDialogDirector::kDeactivated))
    {
        const JXDialogDirector::Deactivated* info =
            dynamic_cast<const JXDialogDirector::Deactivated*>(&message);
        assert(info != NULL);
        if (info->Successful())
        {
            JFSBinding::CommandType type;
            const JString& cmd = itsRunScriptDialog->GetCommand(&type);
            Exec(itsScriptPath, cmd, type);
        }
        itsRunScriptDialog = NULL;
    }

    else if (sender == itsUpdateBindingListTask && message.Is(JXTimerTask::kTimerWentOff))
    {
        if (itsEditDialog == NULL && itsRunFileDialog == NULL)
        {
            itsBindingList->RevertIfModified();
        }
        else if (itsEditDialog != NULL)
        {
            itsEditDialog->CheckIfNeedRevert();
        }
    }

    else
    {
        JBroadcaster::Receive(sender, message);
    }
}
Ejemplo n.º 16
0
int
main(int ac, char *av[])
{
	int c;
	struct timeval tp;
#ifdef DEBUG
	char *optstr = "A:ab:def:G:ghikOpt:U:uwx:z";
#else	/* DEBUG */
	char *optstr = "A:ab:ef:G:ghikOpt:U:uwx:";
#endif	/* DEBUG */

	Program = av[0];

	gettimeofday(&tp, NULL);
	Now = tp.tv_sec;

	while ((c = getopt(ac, av, optstr)) != EOF) {
		switch (c) {
		case 'A':	/* arg (admin set) */
			OptFlags |= OPTA;
			ProcAdminArg(optarg);
			break;

		case 'a':
			OptFlags |= OPTa;
			AddRecord(SAM_QUOTA_ADMIN, -1);
			break;

		case 'b':	/* arg (block count) */
			OptFlags |= OPTb;
			ProcBlockArg(optarg);
			break;

#ifdef DEBUG
		case 'd':
			OptFlags |= OPTd;
			dflag++;
			break;
#endif	/* DEBUG */

		case 'e':
			OptFlags |= OPTe;
			eflag++;
			pflag++;
			break;

		case 'f':	/* arg (file count) */
			OptFlags |= OPTf;
			ProcFileArg(optarg);
			break;

		case 'G':	/* arg (group ID) */
			OptFlags |= OPTG;
			ProcGroupArg(optarg);
			break;

		case 'g':
			OptFlags |= OPTg;
			AddRecord(SAM_QUOTA_GROUP, getegid());
			break;

		case 'h':	/* help.  No return */
			Help(0);
			break;

		case 'i':
			OptFlags |= OPTi;
			iflag = INIT_LIMITS_ZERO;
			break;

		case 'k':
			OptFlags |= OPTk;
			kflag++;
			break;

		case 'O':	/* Don't print total counts */
			OptFlags |= OPTO;
			tflag = 0;
			break;

		case 'p':
			OptFlags |= OPTp;
			pflag++;
			break;

		case 't':	/* arg (grace period) */
			OptFlags |= OPTt;
			ProcTimeArg(optarg);
			break;

		case 'U':	/* arg (user ID) */
			OptFlags |= OPTU;
			ProcUserArg(optarg);
			break;

		case 'u':
			OptFlags |= OPTu;
			AddRecord(SAM_QUOTA_USER, geteuid());
			break;

		case 'w':
			OptFlags |= OPTw;
			wflag = 0;
			break;

		case 'x':	/* arg (expiry) */
			OptFlags |= OPTx;
			ProcExpireArg(optarg);
			break;

#ifdef DEBUG
		case 'z':
			OptFlags |= OPTz;
			iflag = INIT_ALL_ZERO;
			break;
#endif	/* DEBUG */

		default:
			Help(1);
		}
	}

	for (; optind < ac; optind++) {
		ProcFile(av[optind]);
	}

	/*
	 *	Check options for validity.
	 */
#define	TWOBITS(a, b, c) ((a & (b | c)) == (b | c))

	if (OptFlags & OPTMASK_Set) {
		if (NFiles == 0 || (OptFlags & (OPTa | OPTg | OPTu))) {
			fprintf(stderr,
			    "%s:  The options require a file.\n", Program);
			Help(1);
		}

	} else {	/* just reporting */
	}
	if (TWOBITS(OptFlags, OPTa, OPTA) || TWOBITS(OptFlags, OPTg, OPTG) ||
	    TWOBITS(OptFlags, OPTu, OPTU)) {
		fprintf(stderr, "%s:  Incorrect option usage.\n", Program);
		Help(1);
	}

	if (!Err)
		ProcessFiles();
	return (Err ? 10 : 0);
}
Ejemplo n.º 17
0
int main( int argc, char **argv )
{
	if( argc < 2 )
	{
		Usage();
	}
	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
	InitDefaultFileSystem();

	int i = 1;
	while( i < argc )
	{
		if( stricmp( argv[i], "-quiet" ) == 0 )
		{
			i++;
			g_Quiet = true;
			g_NoPause = true; // no point in pausing if we aren't going to print anything out.
		}
		if( stricmp( argv[i], "-nopause" ) == 0 )
		{
			i++;
			g_NoPause = true;
		}
		else
		{
			break;
		}
	}

	char pCurrentDirectory[MAX_PATH];
	if ( _getcwd( pCurrentDirectory, sizeof(pCurrentDirectory) ) == NULL )
	{
		fprintf( stderr, "Unable to get the current directory\n" );
		return -1;
	}

	Q_FixSlashes( pCurrentDirectory );
	Q_StripTrailingSlash( pCurrentDirectory );

	for( ; i < argc; i++ )
	{
		static char normalFileNameWithoutExtension[1024];
		char *pFileName;
		if ( !Q_IsAbsolutePath( argv[i] ) )
		{
			Q_snprintf( normalFileNameWithoutExtension, sizeof(normalFileNameWithoutExtension), "%s\\%s", pCurrentDirectory, argv[i] );
			pFileName = normalFileNameWithoutExtension;
		}
		else
		{
			pFileName = argv[i];
		}

		if( !g_Quiet )
		{
			printf( "file: %s\n", pFileName );
		}
		float bumpScale = -1.0f;
		int startFrame = -1;
		int endFrame = -1;
		LoadConfigFile( pFileName, &bumpScale, &startFrame, &endFrame );
		if( bumpScale == -1.0f )
		{
			fprintf( stderr, "Must specify \"bumpscale\" in config file\n" );
			Pause();
			continue;
		}
		if( ( startFrame == -1 && endFrame != -1 ) ||
			( startFrame != -1 && endFrame == -1 ) )
		{
			fprintf( stderr, "ERROR: If you use startframe, you must use endframe, and vice versa.\n" );
			Pause();
			continue;
		}
		if( !g_Quiet )
		{
			printf( "\tbumpscale: %f\n", bumpScale );
		}
		
		Q_StripExtension( pFileName, normalFileNameWithoutExtension, sizeof( normalFileNameWithoutExtension ) );
		ProcessFiles( normalFileNameWithoutExtension,
					  startFrame, endFrame,
					  bumpScale );
	}
	return 0;
}
Ejemplo n.º 18
0
int main (int argc, char *argv[])
{
  APIRET     rc = NO_ERROR;                   /* R�ckgabewert der Funktionen */
  PERFSTRUCT tsStart;
  PERFSTRUCT tsEnd;
  float      dSeconds;

  memset (&Options,0,sizeof(Options));                    /* Initialisierung */
  memset (&Globals,0,sizeof(Globals));                    /* Initialisierung */

  Globals.piobufInput = malloc(IOBUFFERSIZE);         /* allocate I/O buffer */
  if (Globals.piobufInput == NULL)                       /* check allocation */
    return (ERROR_NOT_ENOUGH_MEMORY);

  Globals.piobufOutput = malloc(IOBUFFERSIZE);        /* allocate I/O buffer */
  if (Globals.piobufOutput == NULL)                      /* check allocation */
    return (ERROR_NOT_ENOUGH_MEMORY);


  rc = ArgStandard (argc,                            /* CLI-Parameter parsen */
                    argv,
                    TabArguments,
                    &Options.fHelp);
  if (rc != NO_ERROR)
  {
    ToolsErrorDos(rc);                                /* print error message */
    exit(1);                                                /* abort program */
  }

  if (Options.fHelp)                         /* check if user specified help */
  {
    help();
    ArgHelp(TabArguments);
    return (NO_ERROR);
  }

  rc = RulesRead(Options.pszFileRules,
                 &Globals.pReplacementRoot);               /* scan the rules */
  if (rc == NO_ERROR)                             /* check if anything is OK */
  {
    if (Options.fQuiet != TRUE)                   /* check if output is OK ? */
      printf ("\n%u rules apply.",   /* print message about rules that apply */
              Globals.ulRules);

                             /* preload header and footer files if necessary */
    if (Options.fFileHeader == TRUE)
    {
                                                    /* memory map the header */
      rc = ToolsReadFileToBuffer (Options.pszFileHeader,
                                  &Globals.pBufferHeader,
                                  &Globals.ulHeaderSize);
      if (rc != NO_ERROR)                                /* check for errors */
        ToolsErrorDos(rc);                          /* display error message */
    }

    if (Options.fFileFooter == TRUE)
    {
                                                    /* memory map the header */
      rc = ToolsReadFileToBuffer (Options.pszFileFooter,
                                  &Globals.pBufferFooter,
                                  &Globals.ulFooterSize);
      if (rc != NO_ERROR)                                /* check for errors */
        ToolsErrorDos(rc);                          /* display error message */
    }
    
    if (!Options.fFileOutput)
    {
      // if nothing else is specified, write output back to the input file
      Options.pszFileOutput = Options.pszFileInput;
      Options.fFileOutput = TRUE;
    }
    

                            /* now process the files (wildcards shall apply) */
    ToolsPerfQuery(&tsStart);                       /* measure starting time */
    rc = ProcessFiles ();                               /* process the files */
    ToolsPerfQuery(&tsEnd);                           /* measure ending time */

    if (rc != NO_ERROR)                                  /* check for errors */
      ToolsErrorDos(rc);                            /* display error message */

    dSeconds = tsEnd.fSeconds - tsStart.fSeconds;      /* calculate duration */
    if (dSeconds == 0.0)                          /* prevent divison by zero */
      dSeconds = 0.001;                         /* assume this minimum value */

      /* @@@PH */

    if (Options.fQuiet != TRUE)                   /* check if output is OK ? */
      printf ("\n%10u files processed. (%12.3f per second)"
              "\n%10u lines processed. (%12.3f per second)"
              "\n%10u bytes processed. (%12.3f per second)",
              Globals.ulProcessedFiles,
              Globals.ulProcessedFiles / dSeconds,
              Globals.ulProcessedLines,
              Globals.ulProcessedLines / dSeconds,
              Globals.ulProcessedBytes,
              Globals.ulProcessedBytes / dSeconds);


    if (Globals.pBufferHeader != NULL)      /* check if memory was allocated */
      free (Globals.pBufferHeader);                      /* free that memory */

    if (Globals.pBufferFooter != NULL)      /* check if memory was allocated */
      free (Globals.pBufferFooter);                      /* free that memory */
  }

  free (Globals.piobufInput);                /* free allocated I/O buffering */
  free (Globals.piobufOutput);

  return (rc);                /* deliver return code to the operating system */
}
Ejemplo n.º 19
0
int main(int argc, char *argv[])
{
   int i;
   char *s,*c,*e;

   InitShell(argc,argv,lplex_version,lplex_vc_id);
   InitMem();
   InitMath();
   InitWave();
   InitLabel();
   InitWMap();
   InitCMap();
   InitLUtil();
   InitLModel();
   InitPCalc();
   InitPMerge();
   SetConfParms();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(EXIT_SUCCESS);

   nLModel = 1;
   for (i=1; i<=LM_NSIZE; i++) cutOff[i] = 0, wdThresh[i] = 0.0;
   CreateHeap(&permHeap, "permHeap", MSTAK, 1, 1.0, 4000, 20000);
   CreateHeap(&tempHeap, "tempHeap", MSTAK, 1, 1.0, 8000, 40000);
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1)
         HError(16619,"Bad switch %s; must be single letter",s);
      switch(s[0]){
         case 'c':
            i = GetChkedInt(2,LM_NSIZE,s);
	    cutOff[i] = GetChkedInt(1,1000,s);
	    break;
         case 'd':
            i = GetChkedInt(2,LM_NSIZE,s);
	    wdThresh[i] = GetChkedFlt(0.0,1E10,s);
	    break;
         case 'e':
	    if (NextArg() != STRINGARG)
	      HError(16619,"LPlex: Eq Class Name Expected");
	    c = GetStrArg();
	    if (NextArg() != STRINGARG)
	      HError(16619,"LPlex: Eq Label Name Expected");
	    e = GetStrArg();
	    AddEquiv(c,e);
	    break;
	 case 'i':
            if (NextArg()!=FLOATARG)
	       HError(16619,"LPlex: Interpolation weight expected");
	    lmInfo[nLModel].weight = GetChkedFlt(0.0,1.0,s);
            if (NextArg()!=STRINGARG)
	       HError(16619,"LPlex: Interpolation LM filename expected");
	    lmInfo[nLModel].fn = GetStrArg();
	    nLModel++;
	    break;
	 case 'n':
	    testInfo[numTests++] = GetChkedInt(1, 10, s); break;
	 case 'o':
	    printOOV = TRUE; break;
          case 's':
	    if (NextArg() != STRINGARG)
	       HError(16619,"LPlex: Prob Stream file name expected");
	    outStreamFN = GetStrArg();
	    break;
	 case 't':
	    streamMode = TRUE; break;
	 case 'u':
	    skipOOV = FALSE; break;
         case 'w':
	    if (NextArg() != STRINGARG)
	       HError(16619,"LPlex: Word list file name expected");
	    wlistFN = GetStrArg();
	    break;
         case 'z':
	    if (NextArg() != STRINGARG)
	       HError(16619,"LPlex: New null class name expected");
	    nulName = GetStrArg();
	    break;
	 case 'G':
	    if (NextArg() != STRINGARG)
	       HError(16619,"Label File format expected");
	    if((lff = Str2Format(GetStrArg())) == ALIEN)
	       HError(16619,"Warning ALIEN Label file format set");
	    break;
	 case 'I':
	    if (NextArg() != STRINGARG)
	       HError(16619,"MLF file name expected");
	    LoadMasterFile(GetStrArg()); break;
	 case 'T':
	    trace = GetChkedInt(0,077, s); break;
         default:
            HError(16619,"LPlex: Unknown switch %s",s);
      }
   }
#ifdef HTK_TRANSCRIBER
   if (trace&T_PROB) trace=trace^T_PROB;
#endif
   if (NextArg()!=STRINGARG)  /* load the language model */
      HError(16619, "Language model filename expected");
   lmInfo[0].fn = GetStrArg();

   Initialise();
   ProcessFiles();

   Exit(EXIT_SUCCESS);
   return EXIT_SUCCESS; /* never reached -- make compiler happy */
}
Ejemplo n.º 20
0
BOOL CAliasApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.
	BOOL bError = FALSE;

	if (!m_Quantize.Init())
		return(FALSE);

	Enable3dControls();
	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	static char BASED_CODE szFilter[] = "Targa Files|*.tga||";

	while (!bError)
	{
		char szSceneDir[MAX_PATH];
		char szGrayDir[MAX_PATH];
		char szColorDir[MAX_PATH];
		char szCompDir[MAX_PATH];
		char szWildCard[MAX_PATH];
		char szMsg[MAX_PATH];
		WIN32_FIND_DATA FindData;

		CFileDialog bgdlg(TRUE,
				"tga",
				"*.tga",
				OFN_HIDEREADONLY,
				szFilter,
				NULL);

		//fgdlg.m_ofn.Flags &= ~OFN_EXPLORER;
		bgdlg.m_ofn.lpstrTitle = "Select Scene Background File";

		int nResponse = bgdlg.DoModal();
		if (nResponse != IDOK)
		{
			DWORD dwErr = CommDlgExtendedError();
			break;

		}
		m_statusDlg.Create(IDD_STATUS);

		CString szBackFile = bgdlg.GetPathName();
		lstrcpy(szSceneDir, szBackFile);
		StripFile(szSceneDir);

		lstrcpy(szGrayDir, szSceneDir);
		lstrcat(szGrayDir, "GRAY\\");
		lstrcpy(szColorDir, szSceneDir);
		lstrcat(szColorDir, "COLOR\\");
		lstrcpy(szCompDir, szSceneDir);
		lstrcat(szCompDir, "COMP");
#ifndef CPO
		CreateDirectory(szCompDir, NULL);
#endif
		lstrcat(szCompDir, "\\");

		lstrcpy(szWildCard, szColorDir);
		lstrcat(szWildCard, "*.*");

		m_Quantize.Reset();

		// first count the number of files to be processed
		m_nTotal = m_nFiles = 0;
		HANDLE hFind = FindFirstFile(szWildCard, &FindData);
		if (!hFind)
		{
			wsprintf(szMsg, "No subdirectories found in %s", szGrayDir);
			MessageBox(NULL, szMsg, "Error", MB_ICONSTOP|MB_OK);
			continue;
		}
		while (hFind != INVALID_HANDLE_VALUE)
		{
			if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
				FindData.cFileName[0] != '.')
			{
				char szGrayAnimDir[MAX_PATH];
				char szColorAnimDir[MAX_PATH];
				char szCompAnimDir[MAX_PATH];
				lstrcpy(szGrayAnimDir, szGrayDir);
				lstrcat(szGrayAnimDir, FindData.cFileName);
				FixPath(szGrayAnimDir);
				lstrcpy(szColorAnimDir, szColorDir);
				lstrcat(szColorAnimDir, FindData.cFileName);
				FixPath(szColorAnimDir);
				lstrcpy(szCompAnimDir, szCompDir);
				lstrcat(szCompAnimDir, FindData.cFileName);
#ifndef CPO
				CreateDirectory(szCompAnimDir, NULL);
#endif
				FixPath(szCompAnimDir);
				if (!ProcessFiles(szGrayAnimDir, szColorAnimDir, szCompAnimDir, TRUE))
				{
					FindClose(hFind);
					bError = TRUE;
					break;
				}
			}
			if (!FindNextFile(hFind, &FindData))
			{
				FindClose(hFind);
				break;
			}
		}
		// now actually process all the files
		hFind = FindFirstFile(szWildCard, &FindData);
		if (!hFind)
		{
			wsprintf(szMsg, "No subdirectories found in %s", szGrayDir);
			MessageBox(NULL, szMsg, "Error", MB_ICONSTOP|MB_OK);
			continue;
		}
		while (hFind != INVALID_HANDLE_VALUE)
		{
			if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
				FindData.cFileName[0] != '.')
			{
				char szGrayAnimDir[MAX_PATH];
				char szColorAnimDir[MAX_PATH];
				char szCompAnimDir[MAX_PATH];
				lstrcpy(szGrayAnimDir, szGrayDir);
				lstrcat(szGrayAnimDir, FindData.cFileName);
				FixPath(szGrayAnimDir);
				lstrcpy(szColorAnimDir, szColorDir);
				lstrcat(szColorAnimDir, FindData.cFileName);
				FixPath(szColorAnimDir);
				lstrcpy(szCompAnimDir, szCompDir);
				lstrcat(szCompAnimDir, FindData.cFileName);
#ifndef CPO
				CreateDirectory(szCompAnimDir, NULL);
#endif
				FixPath(szCompAnimDir);
				if (!ProcessFiles(szGrayAnimDir, szColorAnimDir, szCompAnimDir))
				{
					FindClose(hFind);
					bError = TRUE;
					break;
				}
			}
			if (!FindNextFile(hFind, &FindData))
			{
				FindClose(hFind);
				break;
			}
		}

		FNAME szPath, szFileName;
		RGBQUAD StaticMap[256];
		RGBQUAD InitialMap[256];
		RGBQUAD PaletteMap[256];

		ZeroMemory(StaticMap, sizeof(StaticMap));
		ZeroMemory(PaletteMap, sizeof(PaletteMap));
		GetModuleFileName(m_hInstance, szPath, sizeof(szPath));
		StripFile(szPath);

		lstrcpy(szFileName, szPath);
		lstrcat(szFileName, "static.pal");
		int nStaticEntries = LoadPalette(szFileName, &StaticMap[10]);

		lstrcpy(szFileName, szPath);
		lstrcat(szFileName, "initial.pal");
		int nInitialEntries = LoadPalette(szFileName, InitialMap);
		int nEntries = m_Quantize.CreatePalette(PaletteMap, 236-nStaticEntries, InitialMap, nInitialEntries);
		if (nEntries)
		{
			char szPalFile[MAX_PATH];

			#ifdef GARBAGE
		 	lstrcpy(szPalFile, szSceneDir);
		 	lstrcat(szPalFile, "backgrnd.pal");
			SavePalette(szPalFile, PaletteMap, 256);
			PaletteMap[nEntries].rgbRed = m_rgbTrans.red;
			PaletteMap[nEntries].rgbGreen = m_rgbTrans.green;
			PaletteMap[nEntries].rgbBlue = m_rgbTrans.blue;
		 	lstrcpy(szPalFile, szSceneDir);
		 	lstrcat(szPalFile, "foregrnd.pal");
			SavePalette(szPalFile, PaletteMap, 256);
			#endif

			for (int i = 0; i < nEntries; ++i)
				StaticMap[i+nStaticEntries+10] = PaletteMap[i];
			CreateIdentityMap(StaticMap, 256);

		 	lstrcpy(szPalFile, szSceneDir);
		 	lstrcat(szPalFile, "final.pal");
			SavePalette(szPalFile, StaticMap, 256);
			nStaticEntries += 10;
			for (i = 0; i < nStaticEntries; ++i)
			{
#ifndef CPO
				if (StaticMap[i].rgbRed != m_rgbTrans.red ||
					StaticMap[i].rgbGreen != m_rgbTrans.green ||
					StaticMap[i].rgbBlue != m_rgbTrans.blue)
#endif
				{
					StaticMap[i].rgbRed =
					StaticMap[i].rgbGreen =
					StaticMap[i].rgbBlue = 0;
				}
			}
			for (i = 246; i < 256; ++i)
			{
#ifndef CPO
				if (StaticMap[i].rgbRed != m_rgbTrans.red ||
					StaticMap[i].rgbGreen != m_rgbTrans.green ||
					StaticMap[i].rgbBlue != m_rgbTrans.blue)
#endif
				{
					StaticMap[i].rgbRed =
					StaticMap[i].rgbGreen =
					StaticMap[i].rgbBlue = 0;
				}
			}
		 	lstrcpy(szPalFile, szSceneDir);
		 	lstrcat(szPalFile, "premiere.pal");
			SavePalette(szPalFile, StaticMap, 256);
		}
		m_statusDlg.DestroyWindow();
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
Ejemplo n.º 21
0
void CatalogImages::Impl::ProcessFiles(const String& dir, bool subdirs, const std::vector<bool>& scan_types,
                                       const String& title, const String& description, int img_size, bool folder_scan,
                                       int jpeg_compr)
{
    dir_stack_.clear();

    cur_dir_ = 0;
    root_dir_ = 0;

    ScanDir(dir, subdirs);

    if (root_dir_ == 0)
        return;

    if (parentWnd_)
        ::PostMessage(parentWnd_, MESSAGE, files_.size(), DIR_SCAN_DONE);

    //TODO: save header record with catalog info
    //no of images, types scanned, directory structure, etc...
    std::vector<uint8> header;
    PrepareHeader(header, dir, title, description, root_dir_.get(), folder_scan);
    uint64 header_offset= dbImages_.Append(header);

    tags_.clear();

    failed_.clear();

    // now write images
    ProcessFiles(img_size, jpeg_compr);

    // write special record with statistics

    //TODO:

    std::vector<uint8> stats;
    stats.reserve(200);
    MemPointer p;
//	p.SetResizeCallback(boost::bind(&vector<uint8>::resize, &stats, _1));
    p.SetResizeCallback(boost::bind(&ResizeBuffer, &stats, _1, &p));
    p.SetByteOrder(false);	// little endian
    p.PutUInt32('tats');	// stat
    p.PutUInt32(static_cast<uint32>(tags_.size()));
    for (TagMap::const_iterator it= tags_.begin(); it != tags_.end(); ++it)
    {
        p.WriteWString(it->first);

        const size_t count= it->second.size();
        p.PutUInt32(static_cast<uint32>(count));
        for (size_t i= 0; i < count; ++i)
            p.PutUInt64(it->second[i]);
    }
    p.PutUInt32(0);
    p.PutUInt32(0);
    p.PutUInt32(0);
    p.PutUInt32(0);

    uint64 stats_offset_= dbImages_.Append(stats);

    if (parentWnd_)
        ::PostMessage(parentWnd_, MESSAGE, 0, IMG_PROC_DONE);

    // update total amount of images in the catalog
    header_.img_count_ = static_cast<uint32>(counter_);
    header_.statistics_record_offset_ = stats_offset_;
    header_.Write(header);
    dbImages_.Update(header_offset, header);

}