Example #1
0
int main(int argc, char * argv[])
{
    if (argc < 3) {
        std::cout << "usage: file_tag file type [ name | name=value ... ]" << std::endl;
        return 1;
    }

    std::string file = argv[1];
    std::string type = argv[2];

    boost::system::error_code ec;

    std::map<std::string, std::string> get_values;
    std::map<std::string, std::string> set_values;

    for (int i = 3; i < argc; ++i) {
        char * equal = strchr(argv[i], '=');
        if (equal) {
            *equal++ = 0;
            set_values[argv[i]] = equal;
        } else {
            get_values[argv[i]] = "";
        }
    }

    if (!get_values.empty() || set_values.empty()) {
        framework::system::FileTag ft(file, type);
        ec = ft.get_all(get_values);
        for (std::map<std::string, std::string>::const_iterator iter = get_values.begin(); iter != get_values.end(); ++iter) {
            std::cout << iter->first << ": " << iter->second << std::endl;
        }
        if (ec) {
            std::cerr << file << ": " << ec.message() << std::endl;
        }
    }

    if (!set_values.empty()) {
        framework::system::FileTag ft(file, type);
        ec = ft.set_all(set_values);
        for (std::map<std::string, std::string>::const_iterator iter = set_values.begin(); iter != set_values.end(); ++iter) {
            std::cout << iter->first << ": " << iter->second << std::endl;
        }
        if (ec) {
            std::cerr << file << ": " << ec.message() << std::endl;
        }
    }

    return ec.value();
}
tmp<volScalarField> SpalartAllmarasIDDES::dTilda(const volScalarField& S) const
{
    volScalarField alpha = this->alpha();
    volScalarField expTerm = exp(sqr(alpha));

    volScalarField fHill =
        2*(pos(alpha)*pow(expTerm, -11.09) + neg(alpha)*pow(expTerm, -9.0));

    volScalarField fStep = min(2*pow(expTerm, -9.0), scalar(1));
    volScalarField fHyb = max(1 - fd(S), fStep);
    volScalarField fAmp = 1 - max(ft(S), fl(S));
    volScalarField fRestore = max(fHill - 1, scalar(0))*fAmp;

    // IGNORING ft2 terms
    volScalarField Psi = sqrt
    (
        min
        (
            scalar(100),
            (1 - Cb1_/(Cw1_*sqr(kappa_)*fwStar_)*fv2())/max(SMALL, fv1())
        )
    );

    return max
    (
        dimensionedScalar("SMALL", dimLength, SMALL),
        fHyb*(1 + fRestore*Psi)*y_
      + (1 - fHyb)*CDES_*Psi*delta()
    );
}
Example #3
0
int main(int argc, char* argv[])
{
    setlocale(LC_ALL, "RUS");

    if(!CheckOptions(argc, argv))
    {
        return -1;
    }

    MyObserver obs;
    /*
      FileTransfer::SingleFileTransfer ft(
        "https://*****:*****@10.27.11.125/folder/test1/nz_freedos_1-flat.vmdk?dcPath=ha%2ddatacenter&dsName=datastore1",
        "https://*****:*****@10.27.11.125/folder/test1/test.dat?dcPath=ha-datacenter&dsName=datastore1",
        &obs);
    */
    std::vector<std::string> srcs;
    srcs.push_back("https://*****:*****@10.27.11.125/folder/test1/nz_freedos_1-flat.vmdk?dcPath=ha%2ddatacenter&dsName=datastore1");
    srcs.push_back("https://*****:*****@10.27.11.125/folder/test1/nz_freedos_1-flat.vmdk?dcPath=ha%2ddatacenter&dsName=datastore1");
    srcs.push_back("https://*****:*****@10.27.11.125/folder/test1/nz_freedos_1-flat.vmdk?dcPath=ha%2ddatacenter&dsName=datastore1");

    std::vector<std::string> trgs;
    trgs.push_back("https://*****:*****@10.27.11.125/folder/test1/test.dat?dcPath=ha-datacenter&dsName=datastore1");
    trgs.push_back("https://*****:*****@10.27.11.125/folder/test1/test1.dat?dcPath=ha-datacenter&dsName=datastore1");
    trgs.push_back("https://*****:*****@10.27.11.125/folder/test1/test2.dat?dcPath=ha-datacenter&dsName=datastore1");

    FileTransfer::MultipleFileTransfer ft(srcs, trgs, &obs);

    ft.Start();
    ft.Wait();

    return 0;
}
Example #4
0
void SyncRefsDir(const char *dir, const String& rel, Progress& pi)
{
	SyncRefsRunning++;
	for(FindFile pff(AppendFileName(dir, "*.*")); pff && !IdeExit; pff.Next()) {
		if(pff.IsFolder() && *pff.GetName() != '.') {
			if(SyncRefsShowProgress)
				pi.Step();
			TopicLink tl;
			tl.package = rel + pff.GetName();
			String pdir = AppendFileName(dir, pff.GetName());
			for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff && !IdeExit; ff.Next()) {
				if(ff.IsFolder()) {
					String group = GetFileTitle(ff.GetName());
					tl.group = group;
					String dir = AppendFileName(pdir, ff.GetName());
					LSLOW();
					for(FindFile ft(AppendFileName(dir, "*.tpp")); ft && !IdeExit; ft.Next()) {
						if(ft.IsFile()) {
							String path = AppendFileName(dir, ft.GetName());
							tl.topic = GetFileTitle(ft.GetName());
							String link = TopicLinkString(tl);
							if(SyncRefsShowProgress)
								pi.SetText("Indexing topic " + tl.topic);
							SyncTopicFile(link);
						}
						if(!SyncRefsFinished && !SyncRefsShowProgress && !IdeExit)
							Ctrl::ProcessEvents();
					}
				}
			}
			SyncRefsDir(pdir, tl.package + '/', pi);
		}
	}
	SyncRefsRunning--;
}
Example #5
0
void PackCom::unpack(OutputFile *fo)
{
    ibuf.alloc(file_size);
    obuf.allocForUncompression(ph.u_len);

    // read whole file
    fi->seek(0,SEEK_SET);
    fi->readx(ibuf,file_size);

    // get compressed data offset
    int e_len = ph.buf_offset + ph.getPackHeaderSize();
    if (file_size <= e_len + (off_t)ph.c_len)
        throwCantUnpack("file damaged");

    // decompress
    decompress(ibuf+e_len,obuf);

    // unfilter
    Filter ft(ph.level);
    ft.init(ph.filter, getCallTrickOffset());
    ft.unfilter(obuf,ph.u_len);

    // write decompressed file
    if (fo)
        fo->write(obuf,ph.u_len);
}
Example #6
0
void PackCom::pack(OutputFile *fo)
{
    // read file
    ibuf.alloc(file_size);
    obuf.allocForCompression(file_size);
    fi->seek(0,SEEK_SET);
    fi->readx(ibuf,file_size);

    // prepare packheader
    ph.u_len = file_size;
    // prepare filter
    Filter ft(ph.level);
    ft.addvalue = getCallTrickOffset();
    // compress
    const unsigned overlap_range = ph.u_len < 0xFE00 - ft.addvalue ? 32 : 0;
    compressWithFilters(&ft, overlap_range, NULL_cconf);

    const int lsize = getLoaderSize();
    MemBuffer loader(lsize);
    memcpy(loader,getLoader(),lsize);

    const unsigned calls = ft.id % 3 ? ft.lastcall - 2 * ft.calls : ft.calls;
    patchLoader(fo, loader, lsize, calls);

    // verify
    verifyOverlappingDecompression();

    // finally check the compression ratio
    if (!checkFinalCompressionRatio(fo))
        throwNotCompressible();
}
Example #7
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    QVBoxLayout* vbox = new QVBoxLayout;
    QWidget *widge = new QWidget;
    QFont ft("Courier New", 10);

    m_output = new Sabre::Output;

    m_btnDataDirectory = new QPushButton(tr("Choose Data Directory ..."), this);
    m_result = new QTextEdit(this);
    m_input = new QLineEdit(this);

    connect(m_btnDataDirectory, SIGNAL(clicked()), this, SLOT(onChangeDataDirectory()));

    m_result->setLineWrapMode(QTextEdit::NoWrap);
    m_result->setWordWrapMode(QTextOption::NoWrap);
    m_result->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    m_result->setReadOnly(true);
    m_result->setFont(ft);

    vbox->addWidget(m_btnDataDirectory);
    vbox->addWidget(m_input);
    vbox->addWidget(m_result);

    widge->setLayout(vbox);

    restoreSettings();

    connect(m_input, SIGNAL(returnPressed()), this, SLOT(onInput()));
    connect(m_output, SIGNAL(textChanged(QString)), this, SLOT(onOutputChanged(QString)));

    setCentralWidget(widge);
}
Example #8
0
int sc_main(int argc, char* argv[]) {
	sc_signal<char> i1, i2, i3;
	sc_signal<char>d1, o1, o2, o3, o4;
	sc_signal<bool>sr;
	sc_signal<bool>clk;
	change_case cc("cc");
	filter ft("ft");
	m_bus mb("mb");
	driver dr("dr");
	monitor mon("mon");
	UART ur("ur");
	arbiter ar("ar");
	dr.d_char(d1);
	cc.char_in(d1);
	cc.char_out(o1);
	ft.char_in(d1);
	ft.char_out(o2);
	ar.selector(sr);
	ar.clk(clk);
	mb.char_in1(o1);
	mb.char_in2(o2);
	mb.char_out(o3);
	mb.selector(sr);
	ur.char_in(o3);
	ur.char_out(o4);
	mon.clk(clk);
	mon.m_char(o4);
	sc_start();
	return 0;
}
Example #9
0
void VssClient::DoResync(DWORD dwResyncFlags)
{
    FunctionTracer ft(DBG_INFO);

    CComPtr<IVssBackupComponentsEx3> pVssObjectEx3;

    CHECK_COM(m_pVssObject->QueryInterface(__uuidof(IVssBackupComponentsEx3), (void**)&pVssObjectEx3));

    // Iterate resync pairs and add them to the recovery set
    for ( map<VSS_ID,wstring,ltguid>::iterator pair = m_resyncPairs.begin();
          pair != m_resyncPairs.end();
          ++pair )
    {
        if ( pair->second.size() )
        {
            CHECK_COM(pVssObjectEx3->AddSnapshotToRecoverySet( pair->first, 0, (PWCHAR)pair->second.c_str() ));
        }
        else
        {
            CHECK_COM(pVssObjectEx3->AddSnapshotToRecoverySet( pair->first, 0 ));
        }
    }

    // Perform resync
    CComPtr<IVssAsync>  pAsync;

    CHECK_COM(pVssObjectEx3->RecoverSet(dwResyncFlags, &pAsync));

    WaitAndCheckForAsyncOperation(pAsync);

    ft.WriteLine(L"Resync done.");

}
void EncoreSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const&) const {
	agi::vfr::Framerate fps = AskForFPS(false, true);
	if (!fps.IsLoaded()) return;

	// Convert to encore
	AssFile copy(*src);
	copy.Sort();
	StripComments(copy.Line);
	RecombineOverlaps(copy.Line);
	MergeIdentical(copy.Line);
	StripTags(copy.Line);
	ConvertNewlines(copy.Line, "\r\n");


	// Encode wants ; for NTSC and : for PAL
	// The manual suggests no other frame rates are supported
	char sep = fps.NeedsDropFrames() ? ';' : ':';
	SmpteFormatter ft(fps, sep);

	// Write lines
	int i = 0;
	TextFileWriter file(filename, "UTF-8");
	for (LineList::const_iterator cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) {
		if (AssDialogue *current = dynamic_cast<AssDialogue*>(*cur)) {
			++i;
			file.WriteLineToFile(wxString::Format("%i %s %s %s", i, ft.ToSMPTE(current->Start), ft.ToSMPTE(current->End), current->Text));
		}
	}
}
Example #11
0
void GatherTpp::GatherRefLinks(const char *upp)
{
	for(FindFile pff(AppendFileName(upp, "*.*")); pff; pff.Next()) {
		if(pff.IsFolder()) {
			String package = pff.GetName();
			String pdir = AppendFileName(upp, package);
			TopicLink tl;
			tl.package = package;
			for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff; ff.Next()) {
				if(ff.IsFolder()) {
					String group = GetFileTitle(ff.GetName()	);
					tl.group = group;
					String dir = AppendFileName(pdir, ff.GetName());
					for(FindFile ft(AppendFileName(dir, "*.tpp")); ft; ft.Next()) {
						if(ft.IsFile()) {
							String path = AppendFileName(dir, ft.GetName());
							tl.topic = GetFileTitle(ft.GetName());
							String link = TopicLinkString(tl);
							ScanTopicIterator sti(&reflink);
							sti.link = link;
							ParseQTF(ReadTopic(LoadFile(path))).Iterate(sti);
						}
					}
				}
			}
		}
	}
}
Example #12
0
void PackVmlinuzI386::unpack(OutputFile *fo)
{
    // no uncompression support for this format, so that
    // it is possible to remove the original deflate code (>10 KiB)

    // FIXME: but we could write the uncompressed "vmlinux" image

    ibuf.alloc(ph.c_len);
    obuf.allocForUncompression(ph.u_len);

    fi->seek(setup_size + ph.buf_offset + ph.getPackHeaderSize(), SEEK_SET);
    fi->readx(ibuf, ph.c_len);

    // decompress
    decompress(ibuf, obuf);

    // unfilter
    Filter ft(ph.level);
    ft.init(ph.filter, physical_start);
    ft.cto = (unsigned char) ph.filter_cto;
    ft.unfilter(obuf, ph.u_len);

    // write decompressed file
    if (fo)
    {
        throwCantUnpack("build a new kernel instead :-)");
        //fo->write(obuf, ph.u_len);
    }
}
void ut_max_jump_test(void)
{
	al::AudioIO io(64, 44100, 0, 0, 2, 2, al::AudioIO::DUMMY); // Dummy Audio Backend
	al::Decorrelation dec(1024, 1, 1, false);
	for (int i = 0 ; i < 10; i++) {
		dec.configure(io, -1, 0.1);
		float *ir = dec.getIR(0);
		float data[1026];
		memcpy(data + 1, ir, 1024*sizeof(float));

		gam::RFFT<float> ft(1024);
		ft.forward(data, true);
		float prev_phase =  atan(data[3]/data[2]);
		for (int j = 2; j < 510; j++) {
			float amp = 1024 * sqrt(pow(data[j*2 + 1], 2) + pow(data[j*2], 2));
//			std::cout << amp << std::endl;
			assert(fabs(amp - 1.0) < 0.000001);
			float phs = atan(data[j*2 + 1]/data[j*2]);
			float delta = fabs(phs - prev_phase);
//			std::cout << prev_phase << " ... " << phs << " delta " << delta << std::endl;
			while (delta >= M_PI/2.0) {
				delta -= M_PI;
			}
			assert(delta <= 0.1);
			prev_phase = phs;
		}
	}

}
Example #14
0
TEST_F(FunctionTypeTests,
FunctionWithoutParametersDoesNotHaveParameters) {
	ShPtr<FunctionType> ft(FunctionType::create());
	EXPECT_FALSE(ft->hasParams());
	EXPECT_EQ(0, ft->getNumOfParams());
	EXPECT_EQ(ft->param_begin(), ft->param_end());
}
Example #15
0
void VssClient::BreakSnapshotSetEx(VSS_ID snapshotSetID, DWORD dwBreakExFlags)
{
    FunctionTracer ft(DBG_INFO);

    ft.WriteLine(L"- Calling BreakSnapshotSetEx on " WSTR_GUID_FMT L" ...", GUID_PRINTF_ARG(snapshotSetID));

    if (!(dwBreakExFlags & VSS_BREAKEX_FLAG_MASK_LUNS)                &&
        !(dwBreakExFlags & VSS_BREAKEX_FLAG_MAKE_READ_WRITE)          &&
        !(dwBreakExFlags & VSS_BREAKEX_FLAG_REVERT_IDENTITY_ALL)    &&
        !(dwBreakExFlags & VSS_BREAKEX_FLAG_REVERT_IDENTITY_NONE))
        ft.WriteLine(L"- No BreakSnapshotSetEx flags, can use -mask, -rw, -forcerevert, or -norevert");


    CComPtr<IVssBackupComponentsEx2> pVssObjectEx;
    CHECK_COM(m_pVssObject->QueryInterface(__uuidof(IVssBackupComponentsEx2), (void**)&pVssObjectEx));

    CComPtr<IVssAsync>  pAsync;

    CHECK_COM(pVssObjectEx->BreakSnapshotSetEx(snapshotSetID, dwBreakExFlags, &pAsync));

    // Waits for the async operation to finish and checks the result
    WaitAndCheckForAsyncOperation(pAsync);

    ft.WriteLine(L"BreakEx done.");

}
Example #16
0
LOCAL_C void ProfileAllThreads()
	{
	TFindThread ft(_L("*"));
	TFullName fullname;
	test.Console()->ClearScreen();
	FOREVER
		{
		TInt r=ft.Next(fullname);
		if (r!=KErrNone)
			break;
		RThread t;
		r=t.Open(ft);
		if (r==KErrNone)
			{
			TProfileData data;
			r=Profile.Read(t,data);
			if (r==KErrNone)
				{
				while(fullname.Length()<40)
					fullname.Append(TChar(' '));
				test.Printf(_L("%S T=%9d C=%9d Y=%9d\n"),
					&fullname,data.iTotalCpuTime,data.iMaxContinuousCpuTime,data.iMaxTimeBeforeYield);
				}
			t.Close();
			}
		}
	}
Example #17
0
double regularize(int nnodes,
                         int ndims,
                         double* fvalues_0, 
                         int nweights, 
                         int* rows, 
                         int* cols, 
                         double* weights, 
                         double* fvalues, 
                         double p, 
                         double lambda, 
                         int itermax, 
                         double dftol,
                         int* iter,
                         bool* fixed
                         ){

    Graph graph(nnodes);
    for (int n = 0; n<nweights; n++) graph.addEdge(rows[n],cols[n],weights[n],false);
    Graph::neighbour_iterator ni;
    MatrixCArray<double> f0(ndims,nnodes,fvalues_0);
	MatrixCArray<double> ft(ndims,nnodes,fvalues);
	
    Regularizer reg(graph);
    
    if (fixed) reg.init(f0,ft,fixed);
    else       reg.init(f0,ft);

    double df = reg.compute(p,lambda,itermax,dftol);
    *iter = (int)reg.getIter();

    return df;
}
Example #18
0
// Initialize a file descriptor from a 
void VssDependency::Initialize(
        IVssWMDependency * pDependency
        )
{
    FunctionTracer ft(DBG_INFO);

    VSS_ID guidWriterId;
    CHECK_COM(pDependency->GetWriterId(&guidWriterId));

    CComBSTR bstrLogicalPath;
    CHECK_COM(pDependency->GetLogicalPath(&bstrLogicalPath));

    CComBSTR bstrComponentName;
    CHECK_COM(pDependency->GetComponentName(&bstrComponentName));

    // Initialize local data members
    writerId = Guid2WString(guidWriterId);
    logicalPath = BSTR2WString(bstrLogicalPath);
    componentName = BSTR2WString(bstrComponentName);

    // Compute the full path
    fullPath = AppendBackslash(logicalPath) + componentName;
    if (fullPath[0] != L'\\')
        fullPath = wstring(L"\\") + fullPath;
}
Example #19
0
// Convert a component type into a string
inline wstring VssWriter::GetStringFromRestoreMethod(VSS_RESTOREMETHOD_ENUM eRestoreMethod)
{
    FunctionTracer ft(DBG_INFO);

    ft.Trace(DBG_INFO, L"Interpreting constant %d", (int)eRestoreMethod);
    switch (eRestoreMethod)
    {
    CHECK_CASE_FOR_CONSTANT(VSS_RME_UNDEFINED);
    CHECK_CASE_FOR_CONSTANT(VSS_RME_RESTORE_IF_NOT_THERE);
    CHECK_CASE_FOR_CONSTANT(VSS_RME_RESTORE_IF_CAN_REPLACE);
    CHECK_CASE_FOR_CONSTANT(VSS_RME_STOP_RESTORE_START);
    CHECK_CASE_FOR_CONSTANT(VSS_RME_RESTORE_TO_ALTERNATE_LOCATION);
    CHECK_CASE_FOR_CONSTANT(VSS_RME_RESTORE_AT_REBOOT);
#ifdef VSS_SERVER
    CHECK_CASE_FOR_CONSTANT(VSS_RME_RESTORE_AT_REBOOT_IF_CANNOT_REPLACE);
#endif
    CHECK_CASE_FOR_CONSTANT(VSS_RME_CUSTOM);
    CHECK_CASE_FOR_CONSTANT(VSS_RME_RESTORE_STOP_START);
                    
    default:
        ft.WriteLine(L"Unknown constant: %d",eRestoreMethod);
        _ASSERTE(false);
        return wstring(L"Undefined");
    }
}
Example #20
0
// Print summary/detalied information about this component
void VssComponent::Print(bool bListDetailedInfo)
{
    FunctionTracer ft(DBG_INFO);

    // Print writer identity information
    ft.WriteLine(L"    - Component \"%s\"\n"
        L"       - Name: '%s'\n"
        L"       - Logical Path: '%s'\n"
        L"       - Full Path: '%s'\n"
        L"       - Caption: '%s'\n"
        L"       - Type: %s [%d]\n"
        L"       - Is Selectable: '%s'\n"
        L"       - Is top level: '%s'\n"
        L"       - Notify on backup complete: '%s'",
        (writerName + L":" + fullPath).c_str(),
        name.c_str(),
        logicalPath.c_str(),
        fullPath.c_str(),
        caption.c_str(),
        GetStringFromComponentType(type).c_str(), type,
        BOOL2TXT(isSelectable),
        BOOL2TXT(isTopLevel),
        BOOL2TXT(notifyOnBackupComplete)
        );

    // Compute the affected paths and volumes
    if (bListDetailedInfo)
    {
        ft.WriteLine(L"       - Components:");
        for(unsigned i = 0; i < descriptors.size(); i++)
            descriptors[i].Print();
    }

    // Print the affected paths and volumes
    ft.WriteLine(L"       - Affected paths by this component:");
    for(unsigned i = 0; i < affectedPaths.size(); i++)
        ft.WriteLine(L"         - %s", affectedPaths[i].c_str());

    ft.WriteLine(L"       - Affected volumes by this component:");
    for(unsigned i = 0; i < affectedVolumes.size(); i++)
    {
        wstring wsLocalVolume;

        if (GetDisplayNameForVolumeNoThrow(affectedVolumes[i], wsLocalVolume))
            ft.WriteLine(L"         - %s [%s]", affectedVolumes[i].c_str(), wsLocalVolume.c_str());
        else
            ft.WriteLine(L"         - %s [Not valid for local machine]", affectedVolumes[i].c_str());

    }


    // Print dependencies on Windows Server 2003
#ifdef VSS_SERVER

    ft.WriteLine(L"       - Component Dependencies:");
    for(unsigned i = 0; i < dependencies.size(); i++)
        dependencies[i].Print();

#endif 
}
Example #21
0
// Prints the writer to the console
void VssWriter::Print(bool bListDetailedInfo)
{
    FunctionTracer ft(DBG_INFO);

    // Print writer identity information
    ft.WriteLine(L"\n"
        L"* WRITER \"%s\"\n"
        L"    - WriterId   = %s\n"
        L"    - InstanceId = %s\n"
        L"    - Supports restore events = %s\n"
        L"    - Writer restore conditions = %s\n"
        L"    - Restore method = %s\n"
        L"    - Requires reboot after restore = %s\n",
        name.c_str(),
        id.c_str(),
        instanceId.c_str(),
        BOOL2TXT(supportsRestore),
        GetStringFromRestoreConditions(writerRestoreConditions).c_str(),
        GetStringFromRestoreMethod(restoreMethod).c_str(),
        BOOL2TXT(rebootRequiredAfterRestore)
        );

    // Print exclude files
    ft.WriteLine(L"    - Excluded files:");
    for(unsigned i = 0; i < excludedFiles.size(); i++)
        excludedFiles[i].Print();

    // Enumerate components
    for(unsigned i = 0; i < components.size(); i++)
        components[i].Print(bListDetailedInfo);
}
Example #22
0
void VssClient::GatherWriterMetadataToScreen()
{
    FunctionTracer ft(DBG_INFO);

    ft.WriteLine(L"(Gathering writer metadata...)");

    // Gathers writer metadata
    // WARNING: this call can be performed only once per IVssBackupComponents instance!
    CComPtr<IVssAsync>  pAsync;
    CHECK_COM(m_pVssObject->GatherWriterMetadata(&pAsync));

    // Waits for the async operation to finish and checks the result
    WaitAndCheckForAsyncOperation(pAsync);

    // Get the list of writers in the metadata  
    unsigned cWriters = 0;
    CHECK_COM(m_pVssObject->GetWriterMetadataCount(&cWriters));

    // Enumerate writers
    for (unsigned iWriter = 0; iWriter < cWriters; iWriter++)
    {
        CComBSTR bstrXML;
        // Get the metadata for this particular writer
        VSS_ID idInstance = GUID_NULL;
        CComPtr<IVssExamineWriterMetadata> pMetadata;
        CHECK_COM(m_pVssObject->GetWriterMetadata(iWriter, &idInstance, &pMetadata));

        CHECK_COM(pMetadata->SaveAsXML(&bstrXML));
        wprintf(L"\n--[Writer %u]--\n%s\n", iWriter, (LPCWSTR)(bstrXML));
    }

    wprintf(L"--[end of data]--\n");
}
Example #23
0
// Convert a writer status into a string
wstring VssClient::GetStringFromWriterStatus(VSS_WRITER_STATE eWriterStatus)
{
    FunctionTracer ft(DBG_INFO);

    ft.Trace(DBG_INFO, L"Interpreting constant %d", (int)eWriterStatus);
    switch (eWriterStatus)
    {
    CHECK_CASE_FOR_CONSTANT(VSS_WS_STABLE);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_WAITING_FOR_FREEZE);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_WAITING_FOR_THAW);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_WAITING_FOR_POST_SNAPSHOT);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_WAITING_FOR_BACKUP_COMPLETE);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_IDENTIFY);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_PREPARE_BACKUP);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_PREPARE_SNAPSHOT);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_FREEZE);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_THAW);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_POST_SNAPSHOT);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_BACKUP_COMPLETE);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_PRE_RESTORE);
    CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_POST_RESTORE);

    default:
        ft.WriteLine(L"Unknown constant: %d",eWriterStatus);
        _ASSERTE(false);
        return wstring(L"Undefined");
    }
}
Example #24
0
// Initialize from a IVssWriterComponentsExt
void VssWriter::InitializeComponentsForRestore(IVssWriterComponentsExt * pWriterComponents)
{
    FunctionTracer ft(DBG_INFO);

    // Erase the current list of components for this writer
    components.clear();

    // Enumerate the components from the BC document
    unsigned cComponents = 0;
    CHECK_COM(pWriterComponents->GetComponentCount(&cComponents));

    // Enumerate components
    for(unsigned iComponent = 0; iComponent < cComponents; iComponent++)
    {
        // Get component
        CComPtr<IVssComponent> pComponent;
        CHECK_COM(pWriterComponents->GetComponent(iComponent, &pComponent));

        // Add this component to the list of components
        VssComponent component;
        component.Initialize(name, pComponent);

        ft.WriteLine(L"- Found component available for restore: \"%s\"", component.fullPath.c_str());

        components.push_back(component);
    }
}
Example #25
0
// Initialize the list of writers and components for restore
void VssClient::InitializeWriterComponentsForRestore()
{
    FunctionTracer ft(DBG_INFO);

    ft.WriteLine(L"Initializing writer components for restore ...");

    // Get the list of writers in the metadata  
    unsigned cWriters = 0;
    CHECK_COM(m_pVssObject->GetWriterComponentsCount(&cWriters));

    // Enumerate writers
    for (unsigned iWriter = 0; iWriter < cWriters; iWriter++)
    {
        // Get the selected components for this particular writer
        CComPtr<IVssWriterComponentsExt> pWriterComponents;
        CHECK_COM(m_pVssObject->GetWriterComponents(iWriter, &pWriterComponents));
        
        // Get writer identity. 
        // Ignore this writer if the real writer is not present in the system
        VSS_ID idInstance = GUID_NULL;
        VSS_ID idWriter = GUID_NULL;
        CHECK_COM(pWriterComponents->GetWriterInfo(
            &idInstance, 
            &idWriter
            ));

        wstring id = Guid2WString(idWriter);
        wstring instanceId = Guid2WString(idInstance);

        // Try to discover the name based on an existing writer (identical ID and instance ID).
        // Otherwise, ignore it!
        bool bFound = false;
        for (unsigned i = 0; i < m_writerList.size(); i++)
        {
            // Do Not check for instance ID ... 
            if (id != m_writerList[i].id)
                continue; 

            // Copy the information from the existing writer in the system
            VssWriter   writer = m_writerList[i];

            ft.WriteLine(L"- Writer %s is present in the Backup Components document and on the system. Considering for restore ...",
                writer.name.c_str());

            // Adding components
            writer.InitializeComponentsForRestore(pWriterComponents);

            // Add this writer object to the writer components list 
            m_writerComponentsForRestore.push_back(writer);

            // We found the writer!
            bFound = true;
        }

        if (!bFound)
        {
            ft.WriteLine(L"- Writer with ID %s is not present in the system! Ignoring ...", id.c_str());
        }
    }
}
Example #26
0
void PackTmt::unpack(OutputFile *fo)
{
    Packer::handleStub(fi,fo,adam_offset);

    ibuf.alloc(ph.c_len);
    obuf.allocForUncompression(ph.u_len);

    fi->seek(adam_offset + ph.buf_offset + ph.getPackHeaderSize(),SEEK_SET);
    fi->readx(ibuf,ph.c_len);

    // decompress
    decompress(ibuf,obuf);

    // decode relocations
    const unsigned osize = ph.u_len - get_le32(obuf+ph.u_len-4);
    upx_byte *relocs = obuf + osize;
    const unsigned origstart = get_le32(obuf+ph.u_len-8);

    // unfilter
    if (ph.filter)
    {
        Filter ft(ph.level);
        ft.init(ph.filter, 0);
        ft.cto = (unsigned char) ph.filter_cto;
        if (ph.version < 11)
            ft.cto = (unsigned char) (get_le32(obuf+ph.u_len-12) >> 24);
        ft.unfilter(obuf, ptr_diff(relocs, obuf));
    }
bool
AGActivities::generateTrips(AGHousehold& hh) {
    int iteration = 0;
    bool generated = false;
    std::list<AGTrip> temporaTrips;
    while (!generated && iteration < REBUILD_ITERATION_LIMIT) {
        if (!temporaTrips.empty()) {
            temporaTrips.clear();
        }
        // Work and school activities
        AGWorkAndSchool ws(&hh, &(myCity->statData), &temporaTrips);
        generated = ws.generateTrips();
        if (!generated) {
            hh.regenerate();
            ++iteration;
            continue;
        }
        addTrips(ws.getPartialActivityTrips(), &temporaTrips);

        // free time activities
        AGFreeTime ft(&hh, &(myCity->statData), &temporaTrips, nbrDays);
        generated = ft.generateTrips();
        if (!generated) {
            hh.regenerate();
            ++iteration;
            continue;
        }
        addTrips(ft.getPartialActivityTrips(), &temporaTrips);
        //cout << "after this hh: " << temporaTrips.size() << " we have: " << trips.size() << endl;
        //trips of all activities generated:
        addTrips(temporaTrips, &trips);
    }
    return generated;
}
Example #28
0
int main (int argc, char** argv)
{
    std::string configFileName;
    namespace po = boost::program_options;
    po::options_description desc("Parameters");
    desc.add_options()
                ("help,h", "This help message")
                ("config,c", po::value<std::string>(&configFileName)->default_value(""), "Configuration file");

    po::variables_map vm;
    po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
    po::notify(vm);

    if (vm.count("help"))
    {
        std::cout << "File Templater" << std::endl << std::endl << desc << std::endl;
        return 0;
    }
    // create object
    BasketBit::FileTemplater ft(configFileName);
    if (!ft.initialize())
    {
        std::cerr << "Could not initialize File Templater" << std::endl;
        exit(1);
    }
    if (!ft.create())
    {
        std::cerr << "Could not create templated files" << std::endl;
        exit(1);
    }
    std::cout << "Done!" << std::endl;

    return 0;
}
Example #29
-1
File: font.cpp Project: Try/Tempest
void Tempest::FontElement::update() {
  lt = ft().letterBox[key];
  if( !lt ){
    lt = new Leters();
    ft().letterBox[key] = lt;
    }
  }
Example #30
-1
File: font.cpp Project: Try/Tempest
void Tempest::FontElement::init(const Str &name, int sz ) {
  key.name = findFontName(name);
  key.size = sz;

  lt = ft().letterBox[key];
  if( !lt ){
    lt = new Leters();
    ft().letterBox[key] = lt;
    }
  }