예제 #1
0
bool Block::ProcessFile(File &file, Block &block)
{
	int64_t offset = file.tellRead();
  
	if(!ProcessFile(file, block.mDigest))
		return false;
	
	block.mFile = new File(file.name(), File::Read);
	block.mOffset = offset;
	block.mSize = file.tellRead() - offset;
	block.mFile->seekRead(offset);
	return true;
}
예제 #2
0
void LoadScript( const Seperator& cmd )
{
    const char* cmdName = cmd.arg( 0 ).c_str();

    if( 1 == cmd.argCount() )
    {
        sLog.Error( cmdName, "Usage: %s file [file] ...", cmdName );
        return;
    }

    for( size_t i = 1; i < cmd.argCount(); ++i )
        ProcessFile( cmd.arg( i ) );
}
예제 #3
0
파일: Unit1.cpp 프로젝트: Bindambc/MathApps
void __fastcall TForm1::mnuOpenClick(TObject *Sender){
    TOpenDialog* OpenDialog1 = new TOpenDialog(this);
    try{
        OpenDialog1->Title = "Open File...";
        OpenDialog1->Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
        OpenDialog1->DefaultExt = ".txt";
        OpenDialog1->Options << ofFileMustExist << ofPathMustExist << ofEnableSizing;
        if(!OpenDialog1->Execute()) return;
        ProcessFile(OpenDialog1->FileName);
    }__finally{
        delete OpenDialog1;
    }
}
예제 #4
0
 void OnFile(const Formats::Archived::File& file) const
 {
   const String& name = file.GetName();
   const std::size_t size = file.GetSize();
   if (size <= MaxSize)
   {
     ProcessFile(file);
   }
   else
   {
     Dbg("'%1%' is too big (%1%). Skipping.", name, size);
   }
 }
예제 #5
0
int CBam2GraphApp::Run(void)
{
    SetDiagPostLevel(eDiag_Info);
    // Get arguments
    const CArgs& args = GetArgs();

    if ( args["file"] ) {
        ProcessFile(args["file"].AsString());
    }
    else if ( args["srz"] ) {
        ProcessSrz(args["srz"].AsString());
    }
    return 0;
}
예제 #6
0
// 遍历文件以及子文件夹,这里不处理子文件夹
bool CLogMgr::BrowseDir(const TCHAR *dir,const TCHAR *filespec)
{
	// 遍历文件
	CFileFind logFind;
	CString strDir = dir;
	strDir.Format(_T("%s\\%s"), dir, filespec);

	try
	{
		// 查找第一个文件
		BOOL IsFinded=(BOOL)logFind.FindFile(strDir); 
		while(IsFinded) 
		{  
			IsFinded=(BOOL)logFind.FindNextFile();
			if(!logFind.IsDots()) 
			{ 
				TCHAR foundFileName[_MAX_FILE_PATH]; 
				memset(foundFileName, 0, _MAX_FILE_PATH);

				CString strFileName = logFind.GetFileName();
				T_STRNCPY(foundFileName, strFileName.GetBuffer(_MAX_FILE_PATH), (_MAX_FILE_PATH - 1));
				strFileName.ReleaseBuffer();

				if(logFind.IsDirectory()) // 如果是目录不处理
				{ 
					continue;
				} 
				else // 查找到文件
				{ 
					TCHAR filename[_MAX_FILE_PATH];
					memset(filename, 0x00, _MAX_FILE_PATH*sizeof(TCHAR));
					T_STRCPY(filename,dir);
					T_STRCAT(filename,foundFileName);

					CTime lastWriteTime;
					logFind.GetLastWriteTime(lastWriteTime);
					if (!ProcessFile(filename, (time_t)lastWriteTime.GetTime()))
						return false;
				} 
			} 
		} 
		logFind.Close(); 
	}
	catch (...)
	{
		return false;
	}

	return true;
}
예제 #7
0
int main(int argc, char* argv[])
{
	if( argc != 2 )
	{
		cout << endl << "INFO    :: UnrealScript TextBuffer Exporter";
		cout << endl << "        :: Copyright(C) 2004 Switch` [email protected]";
		cout << endl;
		cout << endl << "USAGE   :: CookieCutter.exe UnrealPackage";
		cout << endl << "EXAMPLE :: CookieCutter.exe Core.u";
		cout << endl;
		return 0;
	}

	ProcessFile(argv[1]);
	return 0;
}
예제 #8
0
int main(int argc, char* argv[])
{
	if (argc < 2)
	{
		wxFprintf(stderr, _T("Usage : ExpandXar <input file> <output file>\n"));
		return 1;
	}

#if wxUSE_UNICODE
	wxChar **wxArgv = new wxChar *[argc + 1];
	
	{
		int n;

		for (n = 0; n < argc; n++ )
		{
			wxMB2WXbuf warg = wxConvertMB2WX(argv[n]);
			wxArgv[n] = wxStrdup(warg);
		}

		wxArgv[n] = NULL;
	}
#else // !wxUSE_UNICODE
	#define wxArgv argv
#endif // wxUSE_UNICODE/!wxUSE_UNICODE

	int RetVal = 0;

	if (!ProcessFile(wxArgv[1], wxArgv[2]))
	{
		RetVal = 1;
	}

#if wxUSE_UNICODE
	{
		for ( int n = 0; n < argc; n++ )
			free(wxArgv[n]);

		delete [] wxArgv;
	}
#endif // wxUSE_UNICODE

	wxUnusedVar(argc);
	wxUnusedVar(argv);
	
	return RetVal;
}
JBoolean
CBCtagsUser::ProcessFile
	(
	const JCharacter*		fileName,
	const CBTextFileType	fileType,
	JString*				result,
	CBLanguage*				lang
	)
{
	if (!StartProcess(fileType, lang))
		{
		result->Clear();
		return kJFalse;
		}

	*itsCmdPipe << fileName << endl;

	JBoolean found;
	*result = JReadUntil(itsResultFD, kDelimiter, &found);
	if (found)
		{
		return kJTrue;
		}
	else if (itsTryRestartFlag)
		{
		DeleteProcess();

		itsTryRestartFlag = kJFalse;
		const JBoolean ok = ProcessFile(fileName, fileType, result, lang);
		itsTryRestartFlag = kJTrue;
		return ok;
		}
	else
		{
		DeleteProcess();
		itsIsActiveFlag = kJFalse;

		if (!CBInUpdateThread())
			{
			(JGetUserNotification())->ReportError(
				"ctags is not responding correctly, "
				"so some features will not work.");
			}

		return kJFalse;
		}
}
void
CBSymbolList::ParseFile
	(
	const JCharacter*		fileName,
	const CBTextFileType	fileType,
	const JFAID_t			id
	)
{
	JString data;
	CBLanguage lang;
	if (ProcessFile(fileName, fileType, &data, &lang))
		{
		std::istrstream input(data.GetCString(), data.GetLength());
		ReadSymbolList(input, lang, fileName, id);
		itsChangedDuringParseFlag = kJTrue;
		}
}
예제 #11
0
bool CGenericProcessingMachine::Run(void)
{
    if (!PreProcess()) return false;
//
    bool result = true;
    CString source_directory;
    CString target_directory;
    if (PSC().VarDefined(GPM_VAR_NAME_INDIR))
    {
        source_directory = CheckLastChar(PSC().VarNamed(GPM_VAR_NAME_INDIR).GetString(),'/');
        PSC().VarNamed(GPM_VAR_NAME_INDIR).SetString(source_directory);
    }
    if (PSC().VarDefined(GPM_VAR_NAME_OUTDIR))
    {
        target_directory = CheckLastChar(PSC().VarNamed(GPM_VAR_NAME_OUTDIR).GetString(),'/');
        PSC().VarNamed(GPM_VAR_NAME_OUTDIR).SetString(target_directory);
    }
    bool do_rename_outfile = ((!PSC().VarDefined(GPM_VAR_NAME_LIST))&&(PSC().VarDefined(GPM_VAR_NAME_OUT)));
    bool do_create_outlist = ((PSC().VarDefined(GPM_VAR_NAME_LIST))&&(PSC().VarDefined(GPM_VAR_NAME_OUT)));
//if ((ILST().GetCount()>1)||(!PSC().VarDefined(GPM_VAR_NAME_OUT)))
    for (int i = 0; i < ILST().GetCount(); i++)
    {
        m_FileIndex = i;
        if (ILST().GetString(i).GetLength()==0) continue;
        CString source_file_name = source_directory + ILST().GetString(i);
        CString target_name = TargetName(i,ILST().GetString(i));
        if (do_rename_outfile)
        {
            target_name = PSC().VarNamed(GPM_VAR_NAME_OUT).GetString();
        }
        CString target_file_name = target_directory + target_name;
        result = result && ProcessFile(source_file_name,target_file_name);
        if (!target_file_name.IsEmpty())
        {
            OLST().Insert(target_name);
        }
    }
    if (do_create_outlist)
    {
        OLST().SaveToFile(PSC().VarNamed(GPM_VAR_NAME_OUT).GetString());
    }
//
    result = result && PostProcess();
    return result;
}
예제 #12
0
파일: Favorite.cpp 프로젝트: Fale/sqlyog
wyBool 
FavoriteBase::AddToTreeView(HWND handle ,HTREEITEM  root, wyBool isfile)
{
	wyInt32				res;
	wyWChar				filename[MAX_PATH + 1]= {0};
	wyString			parentpath , path;
	HANDLE				hfile;
	HTREEITEM			child;
	WIN32_FIND_DATA		wfdd;

	if(SelItemPath(handle, root, parentpath) == wyFalse)
         return wyFalse;

	path.AddSprintf("%s\\*", parentpath.GetString());
    hfile = FindFirstFile(path.GetAsWideChar(), &wfdd); 		

	if(hfile == INVALID_HANDLE_VALUE) 
		return wyFalse;
	
    do
	{	 
		if (wcscmp(L".", wfdd.cFileName) == 0 || wcscmp(L"..", wfdd.cFileName) == 0)
            res = ::FindNextFile(hfile , &wfdd);
	    else
		{	
			//wcscpy(filename , wfdd.cFileName);
			wcsncpy(filename, wfdd.cFileName, MAX_PATH);
			filename[MAX_PATH] = '\0';
			
			if(wfdd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 
			{								
				child = AddItem(handle, root, filename, NDIR);
				AddToTreeView(handle, child, isfile);
               	//::SendMessage(handle, TVM_EXPAND, (WPARAM)TVE_EXPAND, (LPARAM)child);
			}
			else if(isfile)
				ProcessFile(handle, root, filename);
									
            res = ::FindNextFile(hfile , &wfdd);
		}
	}while(res);

	FindClose(hfile);			
	return wyTrue;
}
예제 #13
0
bool SpeechRec::ProcessFileListLine(data_format inpf, data_format outpf, char *line, FILE *fp_mlf)
{
	char file1[1024];
	char file2[1024];
	char sep[256];

	if(sscanf(line, "%[^ \n\r\t]%[ \t]%[^ \n\r\t]", file1, sep, file2) != 3)
	{
		if(sscanf(line, "%s", file1) != 1)
		{
			char msg[1024];
			sprintf(msg, "Invalid line in file list: %s\n", line);
			MERROR(msg);
			return false;
		}
		// compose target file name
		strcpy(file2, file1);
		switch(outpf)
		{
			case dfParams:
				ChangeFileSuffix(file2, C.GetString("params", "suffix"));
				break;
			case dfPosteriors:
				ChangeFileSuffix(file2, C.GetString("traps", "suffix"));
				break;
			case dfStrings:
				if(fp_mlf)
					CreateLabelFileNameForMLF(file1, file2);
				else
					ChangeFileSuffix(file2, C.GetString("labels", "suffix"));
				break;
			case dfWaveform:
				break;
			case dfUnknown:
				assert(0);
		}
	}

	// process one file
	if(!ProcessFile(inpf, outpf, file1, file2, fp_mlf))
		return false;

	return true;
}
예제 #14
0
ForceInline Void main2(Int argc, WChar **argv)
{
    FILE *fp;
    LPVoid lpBuffer, lpEndOfBuffer;
    UInt32 BufferSize, FileSize;

    ConvertScriptToUnicode(argc, argv);
    return;

    BufferSize = 0x1000;
    lpBuffer = malloc(BufferSize);
    _wsetlocale(LC_CTYPE, L"");
    for (Int32 i = 1; i != argc; ++i)
    {
        fp = _wfopen(*++argv, L"rb+");
        if (!fp)
        {
            _wperror(*argv);
            continue;
        }

        FileSize = fsize(fp);
        if (FileSize > BufferSize)
        {
            BufferSize = FileSize;
            lpBuffer = realloc(lpBuffer, BufferSize);
        }

        fread(lpBuffer, FileSize, 1, fp);
        fclose(fp);
        if (*(PUInt16)lpBuffer != 0xFEFF)
        {
            wprintf(L"%s\nsupport unicode only\n\n", *argv);
            fclose(fp);
            continue;
        }

        lpEndOfBuffer = (PByte)lpBuffer + FileSize;
        ProcessFile((PByte)lpBuffer + 2, lpEndOfBuffer, *argv);
    }

    free(lpBuffer);
}
예제 #15
0
void main() {

    struct _finddata_t c_file;
    long hFile;

    /* Find first .c file in current directory */
    if( (hFile = _findfirst( "*.htm", &c_file )) == -1L )
       printf( "No *.htm files in current directory!\n" );
    else {

     do {
       ProcessFile (c_file.name);
   
            /* Find the rest of the .c files */
      } while( _findnext( hFile, &c_file ) == 0 );
     _findclose( hFile );
   }

}
void HeadersDetectorDlg::ThreadProc()
{
    m_Progress = 0;
    for (FilesList::iterator it = m_Project->GetFilesList().begin(); it != m_Project->GetFilesList().end(); ++it)
    {
        if ( m_Thread.TestDestroy() || m_Cancel )
            break;

        ProjectFile* file = *it;
        {
            wxCriticalSectionLocker lock(m_Section);
            m_Progress++;
            m_FileName = file ? file->relativeFilename : _T("");
        }

        ProcessFile( file, m_Headers );
    }
    m_Finished = true;
}
예제 #17
0
void CLyricGetter::RunEx()
{
	std::string uid = SallyAPI::System::SystemHelper::GenerateUniqueID();
	std::string tempFile = SallyAPI::System::SallyHelper::GetMediaDirectory(m_pAppBase);
	tempFile.append(uid);
	tempFile.append(".xml");

	// cleanup
	DeleteFile(tempFile.c_str());

	if (!ProcessFile(tempFile))
	{
		SallyAPI::GUI::SendMessage::CParameterKeyValue parameter(this->GetId(), m_strErrorText);
		m_pParent->SendMessageToParent(m_pParent, 0, GUI_APP_LYRICS_LOADED, &parameter);
	}

	// cleanup
	DeleteFile(tempFile.c_str());
}
예제 #18
0
int Execution::RunScan(const wxArrayString& FilesToProcess,
                       const wxArrayString& Groups)
{
  // Running the scan
  m_Execute = true;
  int HeadersAdded = 0;
  m_Progress->SetRange((int)FilesToProcess.GetCount());
  for ( size_t i=0; i<FilesToProcess.GetCount(); i++ )
  {
    m_Progress->SetValue((int)i);
    if ( !m_Execute )
      return HeadersAdded;
    HeadersAdded += ProcessFile(FilesToProcess[i],Groups);
  }
  m_Progress->SetValue((int)FilesToProcess.GetCount());
  m_Execute = false;

  return HeadersAdded;
}// RunScan
예제 #19
0
파일: main.c 프로젝트: Ribtoks/heap
int main()
{
    FuncFactory stringFunctions;

    SkipList* list = 0;

    FILE* out = 0;

    InitStringFactoryStruct(&stringFunctions);
    list = CreateSkipList(&stringFunctions);

    memset(filename, '\0', MAX_FILENAME_LENGTH*sizeof(char));

    printf("Enter filename :> ");
    gets(filename);


    ProcessFile(filename, list);

    printf("\nAll words:\n");


    PrintList(list);

    if (AskUser("Print results to file?"))
    {
        if ((out = fopen("results.txt", "w+")) == NULL)
        {
            printf("Cannot open file. Press any key to exit.\n");
            getchar();
            exit(-1);
        }

        PrintListToFile(out, FilePrinter, list);
    }

    CleanupList(list);

    printf("Done.\n\nPress any key to exit...");
    getchar();
    return 0;
}
예제 #20
0
static void
Process(JSContext *cx, JSObject *obj, const char *filename, JSBool forceTTY)
{
    FILE *file;

    if (forceTTY || !filename || strcmp(filename, "-") == 0) {
        file = stdin;
    } else {
        file = fopen(filename, "r");
        if (!file) {
            JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL,
                                 JSSMSG_CANT_OPEN,
                                 filename, strerror(errno));
            gExitCode = EXITCODE_FILE_NOT_FOUND;
            return;
        }
    }

    ProcessFile(cx, obj, filename, file, forceTTY);
}
예제 #21
0
int main(int argc, char *argv[])
{
    if (argc > 1)
    {
        char* fontName = argv[1];

        ProcessFile(fontName);

    }
    else
    {
        fprintf(stderr, "No arguments passed to program.\n");
    }

    fprintf(stderr, "Program End.\n");

    char buf[128];
    scanf(buf, "%s");

}
예제 #22
0
bool BiopMessage::Process(DSMCCCacheModuleData *cachep, DSMCCCache *filecache,
                          unsigned char *data, unsigned long *curp)
{
    // Parse header
    if (! ProcessMsgHdr(data, curp))
    {
        VERBOSE(VB_DSMCC,"[biop] Invalid biop header, "
                "dropping rest of module");

        /* not valid, skip rest of data */
        return false;
    }

    // Handle each message type
    if (strcmp(m_objkind, "fil") == 0)
    {
        VERBOSE(VB_DSMCC,"[biop] Processing file");
        return ProcessFile(cachep, filecache, data, curp);
    }
    else if (strcmp(m_objkind, "dir") == 0)
    {
        VERBOSE(VB_DSMCC,"[biop] Processing directory");
        return ProcessDir(false, cachep, filecache, data, curp);
    }
    else if (strcmp(m_objkind, "srg") == 0)
    {
        VERBOSE(VB_DSMCC,"[biop] Processing gateway");
        return ProcessDir(true, cachep, filecache, data, curp);
    }
    else
    {
        /* Error */
        VERBOSE(VB_DSMCC, QString("Unknown or unsupported format %1%2%3%4")
                .arg(m_objkind[0]).arg(m_objkind[1])
                .arg(m_objkind[2]).arg(m_objkind[3]));
        return false;
    }
}
CBLanguage
CBFnMenuUpdater::UpdateMenu
	(
	const JCharacter*		fileName,
	const CBTextFileType	fileType,
	const JBoolean			sort,
	const JBoolean			includeNS,
	const JBoolean			pack,
	JXTextMenu*				menu,
	JArray<JIndex>*			lineIndexList
	)
{
	menu->RemoveAllItems();
	lineIndexList->RemoveAll();

	if (pack)
		{
		menu->SetDefaultFontSize(JGetDefaultFontSize()-2, kJFalse);
		menu->CompressHeight(kJTrue);
		}
	else
		{
		menu->SetDefaultFontSize(JGetDefaultFontSize(), kJFalse);
		menu->CompressHeight(kJFalse);
		}

	JString data;
	CBLanguage lang;
	if (ProcessFile(fileName, fileType, &data, &lang))
		{
		std::istrstream input(data.GetCString(), data.GetLength());
		ReadFunctionList(input, CBGetLanguage(fileType),
						 sort, includeNS, menu, lineIndexList);
		}
	return lang;
}
예제 #24
0
void Merge_MuonJet(TString type, int id = 0, int N = 1){

  gROOT->Reset();
  
  type.ToLower();
  if (type=="mc") MC = true; else
    if (type=="data") MC = false; else
      {cout<<"Choose mc or data"<<endl; return; }

  TString sample = "QCDPPb";//bJetPPb
  TString name,outname;
  
  if (MC) {name = Form("%s_AccCut.root",sample.Data());outname = "QCDPPb_genmuonmerged.root"; }
  else {name =  "jettrig_weight_AccCut.root"; outname = "jettrig_weight_AccCut_muons.root"; }


  vector<TString> newbranches = {"Njetmuon/I:jetmuonpt/F,jetmuoneta/F,jetmuonphi/F,jetmuonptrel/F,jetmuonip3d/F"};

  ProcessFile(name, outname, "jet", vector<TString> ({"muon"}), vector<TString> {"nref","Glb_nptl"}, newbranches, ProcessEvent, id, N);



  //  ProcessFile(name, outname, "jet", vector<TString> ({"QCDPPb_AccCut.root:m=muon","evt"}), jetbranches, newbranches, ProcessEvent);  
}
예제 #25
0
int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar *DestPath,wchar *DestName)
{
  return(ProcessFile(hArcData,Operation,NULL,NULL,DestPath,DestName));
}
예제 #26
0
INT EncDiskDecrypt(const CHAR * FileName, const CHAR * PrivateKey, INT ThreadNum)
{
    PCRYPT_CONTEXT Context = NULL;
    CHAR * Pass = NULL;
    HANDLE hFile = INVALID_HANDLE_VALUE;
    LARGE_INTEGER FileSize;
    INT Ret = -1;

    if((Pass = AskPass(CHECK_PASS, "Enter the password for the key:", NULL)) == NULL)
        goto err;

    if((Context = ReadKeyFile(PrivateKey, Pass)) == NULL) {
        goto err;
    }

    // open file
    hFile = CreateFile(
        FileName,
        GENERIC_READ | GENERIC_WRITE,
        0,
        NULL,
        OPEN_EXISTING,
        0,
        NULL
        );
    if(hFile == INVALID_HANDLE_VALUE) {
        PrintLastError("EncDiskDecrypt:");
        goto err;
    }

    if(!GetFileSizeEx(hFile, &FileSize)) {
        PrintLastError("EncDiskDecrypt:");
        goto err;
    }
    
    CloseHandle(hFile);
    hFile = INVALID_HANDLE_VALUE;
    // file size should be n * CRYPT_CLUSTER_SIZE

    if(FileSize.QuadPart % CRYPT_CLUSTER_SIZE != 0) {
        PrintMessage("%s\n", "EncDiskDecrypt: invalid disk image");
        goto err;
    }

    if(ProcessFile(FileName, Context, NULL, ThreadNum)!= 0) {
        goto err;
    }
    
    Ret = 0;
    PrintMessage("%s\n", "EncDiskDecrypt: success!");
err:
    if(NULL != Pass) {
        free(Pass);
        Pass = NULL;
    }
    if(NULL != Context) {
        free(Context);
        Context = NULL;
    }
    if(INVALID_HANDLE_VALUE != hFile) {
        CloseHandle(hFile);
        hFile = INVALID_HANDLE_VALUE;
    }
    return Ret;
}
예제 #27
0
future<ContainerPtr>
ContentModuleManager::LoadContentAtPath(const string& path, launch policy)
{
    std::unique_lock<std::mutex>(_mutex);
    
    if (_known_modules.empty())
    {
        // special case for when we don't have any Content Modules to rely on for an initialized result
        return make_ready_future<ContainerPtr>(ContainerPtr(nullptr));
    }
    
    future<ContainerPtr> result;
    bool found = false;
    for (auto& item : _known_modules)
    {
        auto modulePtr = item.second;
        result = modulePtr->ProcessFile(path, policy);
        
        // check the state of the future -- has it already been set?
        future_status status = result.wait_for(std::chrono::system_clock::duration(0));
        
        /*
         Following 'if-else' clauses which have 'result.then' make a malfunction
         while Content Module processing for DRM implementation.
         But there is no problem to handle both plain and encrypted resources 
         with next clauses which are detouring result.then
         */
        
        /*
        // if it's ready, the call to get() will never block
        if (status == future_status::ready) {
			// unpack the future
			ContainerPtr container = result.get();

            if (bool(container)) {
                // we have a valid container already
				result = make_ready_future(container);
                result = result.then([modulePtr](future<ContainerPtr> fut) {
                    ContainerPtr ptr = fut.get();
                    modulePtr->RegisterContentFilters();
                    return ptr;
                });
                break;
            } else {
                continue;       // no container, so try the next module
            }
        } else {
            // it must be 'timeout' or 'deferred', which means the module is attempting to process the file
            // we take this to mean that we stop looking and return the result
            result = result.then([modulePtr](future<ContainerPtr> fut) {
                ContainerPtr ptr = fut.get();
                modulePtr->RegisterContentFilters();
                return ptr;
            });
            break;
        }
        */
        
        if (status == future_status::ready) {
            ContainerPtr container = result.get();
            
            if (bool(container)) {
                modulePtr->RegisterContentFilters();
                found = true;
                break;
            } else {
                continue;
            }
        } else {
            modulePtr->RegisterContentFilters();
            found = true;
            break;
        }
    }
    
    if ( !found && result.__future_ == nullptr )
    {
        throw std::invalid_argument("Unsupported DRM EPUB");
    }
    
    return result;
}
예제 #28
0
int main(int argc, char **argv)
{
	// read options for all files from udx.ini, 
	// in source file dir, in lib dir, or in prog file dir
	ProcessIni();
	
	bool processed = false;
	char **nextarg = NULL;

	for (int arg = 1; arg < argc; arg++) {
		if (*argv[arg] != '-') {
			// args are file(s) to process, or stdin
			if (nextarg) {
				*nextarg = argv[arg];
				nextarg = NULL;
			}
			else {
				ProcessFile(argv[arg]);
				processed = true;
			}
		}
		else switch (*(argv[arg] + 1)) {
			// switches apply to following args until changed
			// options are -f (full), -m (minimize),
			// -o output, -e errorfile, -h or -? (help)
			case 'f':
				DoFull = true;
				DoMin = false;
				break;

			case 'm':
				DoFull = false;
				DoMin = true;
				break;

			case 'o':
				OutArg = argv[arg] + 2;
				if (*OutArg == '\0')
					nextarg = &OutArg;
				break;

			case 'e':
				ErrArg = argv[arg] + 2;
				if (*ErrArg == '\0')
					nextarg = &ErrArg;
				break;

			case 'h':
			case '?':
				ShowHelp();
				return 0;

			// use -n + letter for No, just -letter for Yes:
			case 'n':
				switch (*(argv[arg] + 2)) {
					// -p para tags in block elems
					case 'p':
						DoPara = false;
						break;

					// -b blank lines for para breaks
					case 'b':
						DoBlank = false;
						break;

					// -s short tags + a (all), l (list), p (pair), t (table)
					case 's':
						switch (*(argv[arg] + 3)) {
							case 'a':
								DoListShort = false;
								DoPairShort = false;
								DoTableShort = false;
								break;

							case 'l':
								DoListShort = false;
								break;

							case 'p':
								DoPairShort = false;
								break;

							case 't':
								DoTableShort = false;
								break;

							default:
								break;
						}
						break;

					// -w wiki symbols
					case 'w':
						DoWiki = false;
						break;

					default:
						break;
				}
				break;

			// -p para tags in block elems
			case 'p':
				DoPara = true;
				break;

			// -b blank lines for para breaks
			case 'b':
				DoBlank = true;
				break;

			// -s short tags + a (all), l (list), p (pair), t (table)
			case 's':
				switch (*(argv[arg] + 3)) {
					case 'a':
						DoListShort = true;
						DoPairShort = true;
						DoTableShort = true;
						break;

					case 'l':
						DoListShort = true;
						break;

					case 'p':
						DoPairShort = true;
						break;

					case 't':
						DoTableShort = true;
						break;

					default:
						break;
				}
				break;

			// -w wiki symbols
			case 'w':
				DoWiki = true;
				break;

			default:
				break;
		}
	}
	if (!processed)
		ProcessFile(NULL);


	return 0;
}
예제 #29
0
int main(int argc,char *argv[])
{
    int a,b,c;
    FILE *outfile = NULL, *infile = NULL;
    char *outfile_name=NULL,*infile_name=NULL;
    char tmp[20];
    int vflag=0,oflag=0,hflag=0,lflag=0,plusflag=0,minusflag=0;
#ifdef LICENSE
    license_struct lstr;
#endif
    while ((c = getopt(argc, argv, "lhvo:")) != -1) {
	switch (c) {
	case 'o':/*set outfile*/
	    outfile_name=optarg;
	    oflag = 1;
	    break;
	case 'v':/*print version*/
	    vflag=1;
	    break;
	case 'h':/*print help (usage)*/
	    hflag=1;
	    break;
	case 'l':/*list event types*/
	    lflag=1;
	    break;
	default:
	    Usage(argv[0]);
	    return EXIT_FAILURE;
	}
    }
    if (oflag + vflag + hflag + lflag > 1) {
	Usage(argv[0]);
	return EXIT_FAILURE;
    } else if (vflag) {
        fputs("Log Filter for the TTCN-3 Test Executor\n"
	    "Product number: " PRODUCT_NUMBER "\n"
	    "Build date: " __DATE__ " " __TIME__ "\n"
	    "Compiled with: " C_COMPILER_VERSION "\n\n"
	    COPYRIGHT_STRING "\n\n", stderr);
#ifdef LICENSE
	print_license_info();
#endif
	return EXIT_SUCCESS;
    } else if (hflag) {
	Usage(argv[0]);
	return EXIT_SUCCESS;
    } else if(lflag) {
	ListTypes();
	return EXIT_SUCCESS;
    }
#ifdef LICENSE
    init_openssl();
    load_license(&lstr);
    if (!verify_license(&lstr)) {
      free_license(&lstr);
      free_openssl();
      exit(EXIT_FAILURE);
    }
    if (!check_feature(&lstr, FEATURE_LOGFORMAT)) {
	fputs("The license key does not allow the filtering of log files.\n",
	    stderr);
	return 2;
    }
    free_license(&lstr);
    free_openssl();
#endif
/*
switches: -v -o -h -l
filter parameters: parameter+ or parameter-
*/
    for(a=0;a<MaxType;a++)Wflags[a]=0;
    for(a=1;a<argc;a++) {
	if(*argv[a]=='-'){if(*(argv[a]+1)=='o')a++;continue;}/*switch*/
	if(*(argv[a]+strlen(argv[a])-1)=='-') {/*type to ignore*/
	    for(b=0,c=0;b<MaxType;b++)
		if(0==strncmp(EventTypeNames[b],argv[a],
			strlen(EventTypeNames[b]))&&strlen(EventTypeNames[b])==
			strlen(argv[a])-1) {
		    Wflags[b]=DontWrite;
		    c=1;
		}
	    if(!c) {/*Undefined type*/
		strncpy(tmp,argv[a],sizeof(tmp)-1);
		if(strlen(argv[a])>sizeof(tmp)-1)
		    for(c=2;c<5;c++)tmp[sizeof(tmp)-c]='.';
		else tmp[strlen(argv[a])-1]='\0';
		tmp[sizeof(tmp)-1]='\0';
		if(strlen(tmp))fprintf(stderr,"Warning: %s is not a valid "
		    "event-type name.\n",tmp);
		else fprintf(stderr,"Warning: `-\' without an event-type "
		    "name.\n");
	    }
	    Wothers=Write;
	    minusflag=1;
	    continue;
	}
	if(*(argv[a]+strlen(argv[a])-1)=='+') {/*type to write out*/
	    for(b=0,c=0;b<MaxType;b++)
		if(0==strncmp(EventTypeNames[b],argv[a],
			strlen(EventTypeNames[b]))&&strlen(EventTypeNames[b])==
			strlen(argv[a])-1) {
		    Wflags[b]=Write;
		    c=1;
		}
	    if(!c) {/*Undefined type*/
		strncpy(tmp,argv[a],sizeof(tmp)-1);
		if(strlen(argv[a])>sizeof(tmp)-1)
		    for(c=2;c<5;c++)tmp[sizeof(tmp)-c]='.';
		else tmp[strlen(argv[a])-1]='\0';
		tmp[sizeof(tmp)-1]='\0';
		if(strlen(tmp))fprintf(stderr,"Warning: %s is not a valid "
		    "event-type name.\n",tmp);
		else fprintf(stderr,"Warning: `+\' without an event-type "
		    "name.\n");
	    }
	    Wothers=DontWrite;
	    plusflag=1;
	    continue;
	}
	if(infile_name!=NULL) {/*only one input file at once*/
	    fprintf(stderr,"Error: more than one input file specified.\n");
	    return EXIT_FAILURE;
	}
	infile_name=argv[a];
    }
    if(minusflag&&plusflag) {/*type1+ and type2- at the same time could cause
		types that are not defined what to do with, to act based on the
		last filter definition. Thus it is not allowed.*/
	fprintf(stderr,"Error: include and exclude at the same time.\n");
	return EXIT_FAILURE;
    }
    if(infile_name==NULL)infile=stdin;/*if no infile specified use stdin*/
    else {
	infile=fopen(infile_name,"r");
	if(infile==NULL) {
	    fprintf(stderr,"Error opening %s : %s\n",infile_name,
		strerror(errno));
	    return EXIT_FAILURE;
	}
    }
    if(oflag) {
	outfile=fopen(outfile_name,"w");
	if(outfile==NULL) {
	    fprintf(stderr,"Error creating %s : %s\n",outfile_name,
		strerror(errno));
	    return EXIT_FAILURE;
	}
    } else outfile=stdout;/*if no outfile specified use stdout*/
    a=ProcessFile(outfile,infile);/*filter infile to outfile*/
    if(a==ERR_INVALID_LOG) {
	if(infile_name!=NULL)fprintf(stderr,"Error: the file %s is not a valid "
	    "log file.\n",infile_name);
	else fprintf(stderr,"Error: invalid format received from standard "
	    "input.\n");
	return EXIT_FAILURE;
    } else if(a==ERR_WRITE) {
	if(errno)fprintf(stderr,"Error writing to output: %s\n",
	    strerror(errno));
	else fprintf(stderr,"Error writing to output\n");
	return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;
}
예제 #30
0
파일: GenTEImage.c 프로젝트: Kohrara/edk
int
main (
  int   Argc,
  char  *Argv[]
  )
/*++

Routine Description:
  

Arguments:

  Argc            - standard C main() argument count

  Argv            - standard C main() argument list

Returns:

  0             success
  non-zero      otherwise

--*/
// GC_TODO:    ] - add argument and description to function comment
{
  INT8    *Ext;
  UINT32  Status;

  SetUtilityName (UTILITY_NAME);
  //
  // Parse the command line arguments
  //
  if (ParseCommandLine (Argc, Argv)) {
    return STATUS_ERROR;
  }
  //
  // If dumping an image, then do that and quit
  //
  if (mOptions.Dump) {
    DumpImage (mOptions.InFileName);
    goto Finish;
  }
  //
  // Determine the output filename. Either what they specified on
  // the command line, or the first input filename with a different extension.
  //
  if (!mOptions.OutFileName[0]) {
    strcpy (mOptions.OutFileName, mOptions.InFileName);
    //
    // Find the last . on the line and replace the filename extension with
    // the default
    //
    for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;
         (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');
         Ext--
        )
      ;
    //
    // If dot here, then insert extension here, otherwise append
    //
    if (*Ext != '.') {
      Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);
    }

    strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);
  }
  //
  // Make sure we don't have the same filename for input and output files
  //
  if (_stricmp (mOptions.OutFileName, mOptions.InFileName) == 0) {
    Error (NULL, 0, 0, mOptions.OutFileName, "input and output file names must be different");
    goto Finish;
  }
  //
  // Process the file
  //
  ProcessFile (mOptions.InFileName, mOptions.OutFileName);
Finish:
  Status = GetUtilityStatus ();
  return Status;
}