コード例 #1
0
ファイル: RTFCompData.cpp プロジェクト: killbug2004/WSProf
void RTFCompData::Write(CRtfWriter* fp, char cDelineator)
{
	unsigned long iOutSize = 0;
	unsigned long iTotSize = 0;
	RTFinflator rfi(pData,iSize+1);
	
	CQuickBuildString cqs;

	char* pInflated=new char[16385];
	THROW_IF_FAILED_TO_ALLOCATE_MEMORY(pInflated, _T("Failed to allocate Char buffer"));
	
	while (!rfi.IsFinished())
	{
		iOutSize=rfi.GetData(pInflated,16384);
		iTotSize+=iOutSize;
		cqs.Assign(pInflated,iOutSize);
		if (cDelineator != 0)	// non-delineator
			fp->WriteDelineatedStringDirect(cqs, cDelineator);
		else
			fp->WriteStringDirect(cqs);
	}

	CHECK_ALGORITHM_INTEGRITY(rfi.IsFinished());
	CHECK_ALGORITHM_INTEGRITY(iTotSize==iFullSize);
	::delete [] pInflated;
}
コード例 #2
0
ファイル: rcdfile.cpp プロジェクト: Qwertie-/FreeRCT
/**
 * Scan a file for Rcd meta-data, and add it to the collection if all is well.
 * @param fname Filename of the file to scan.
 * @return Error message, or \c nullptr if no error found.
 */
const char *RcdFileCollection::ScanFileForMetaInfo(const char *fname)
{
	RcdFileReader rcd_file(fname);
	if (!rcd_file.CheckFileHeader("RCDF", 2)) return "Wrong header";

	/* Load block. */
	if (!rcd_file.ReadBlockHeader() || (strcmp(rcd_file.name, "INFO") != 0)) {
		/* End reached or found a non-meta block, end scanning. */
		return "No INFO block found.";
	}

	/* Load INFO block. */
	if (rcd_file.version != 1) return "INFO block has wrong version";
	uint32 remaining = rcd_file.size;
	std::string build = GetString(rcd_file, 16, &remaining);
	std::string name = GetString(rcd_file, 64, &remaining);
	std::string uri = GetString(rcd_file, 128, &remaining);
	std::string website = GetString(rcd_file, 128, &remaining);
	std::string description = GetString(rcd_file, 512, &remaining);
	if (remaining != 0) return "Error while reading INFO text.";

	RcdFileInfo rfi(fname, uri, build);
	this->AddFile(rfi);
	return nullptr; // Success.
}
コード例 #3
0
FindFiles::IIList &FindFilesInMappedDirs::loadItems() {
	FindFiles::clear();
	RecursiveFileIterator rfi(&std::cerr);

	const TPKGS::PathPairSet &pmap = tss.t.getInstallPathMap();
	for(TPKGS::PathPairSet::const_iterator a = pmap.begin(); a != pmap.end(); a++) {
		rfi.addPathToVisit(a->second.string());
	}

	rfi.run(*this);
	return result;
}
コード例 #4
0
ファイル: ptrfun07.cpp プロジェクト: ABratovic/open-watcom-v2
int main()
{
    pfd(2.0);
    CHECK_GOOD(3);
    pfi(2);
    CHECK_GOOD(3+4);
    rfi(2);
    CHECK_GOOD(3+4+4);
    rfd(2.0);
    CHECK_GOOD(3+4+4+3);
    return errors != 0;

}
コード例 #5
0
ファイル: radio.c プロジェクト: suborb/reelvdr
void cPluginRadio::Replaying(const cControl *Control, const char *Name, const char *FileName, bool On)
{
    IsRadioOrReplay = 0;
    radioAudio->DisableRadioTextProcessing();

    if (S_Activate == false) return;

    bool isRadio = false;

    if (On && FileName != NULL) {
        char *vdrfile;
        // check VDR PES-Recordings
        asprintf(&vdrfile, "%s/001.vdr", FileName);
        if (file_exists(vdrfile)) {
#if VDRVERSNUM >= 10703
            cFileName fn(FileName, false, true, true);
#else
            cFileName fn(FileName, false, true);
#endif
            cUnbufferedFile *f = fn.Open();
            if (f) {
                uchar b[4] = { 0x00, 0x00, 0x00, 0x00 };
                ReadFrame(f, b, sizeof (b), sizeof (b));
                fn.Close();
                isRadio = (b[0] == 0x00) && (b[1] == 0x00) && (b[2] == 0x01) && (0xc0 <= b[3] && b[3] <= 0xdf);
                }
            }
#if VDRVERSNUM >= 10703
        // check VDR TS-Recordings
        asprintf(&vdrfile, "%s/info", FileName);
        if (file_exists(vdrfile)) {
            cRecordingInfo rfi(FileName);
            if (rfi.Read()) {
                if (rfi.FramesPerSecond() > 0 && rfi.FramesPerSecond() < 18) // max. seen 13.88 @ ARD-RadioTP 320k
                    isRadio = true;
                }
            }
#endif
        free(vdrfile);
        }

    if (isRadio) {
        if (!file_exists(ReplayFile))
            dsyslog("radio: replay-image not found '%s'", ReplayFile);
        else
            radioImage->SetBackgroundImage(ReplayFile);
        radioAudio->EnableRadioTextProcessing(Name, 0, true);
        IsRadioOrReplay = 2;
        }
}
コード例 #6
0
FindFiles::IIList &FindFilesInInstallDirs::loadItems(const Path &installDirsFile) {
	FindFiles::clear();
	RecursiveFileIterator rfi(&std::cerr);

	std::ifstream installFolderFileStream;
	installFolderFileStream.exceptions(std::ios::badbit);
	installFolderFileStream.open(installDirsFile.c_str(), std::ios::in);
	std::string line;
	while(!!getline(installFolderFileStream, line)) {
		boost::trim(line);
		if(!line.empty()) {
			rfi.addPathToVisit(line);
		}
	}

	rfi.run(*this);
	return result;
}
コード例 #7
0
ファイル: RTFCompData.cpp プロジェクト: killbug2004/WSProf
BYTE* RTFCompData::GetUncompressedDataAsBytes(long* lBufferLength) const
{
	// unpack it, but also turn it into bytes, from the text representation, eg 0100055EFF etc
	(*lBufferLength) = 0;
	long lLength = iFullSize / 2;

	BYTE* byteBuffer = new BYTE[1 + lLength];
	THROW_IF_FAILED_TO_ALLOCATE_MEMORY(byteBuffer, _T("Failed to allocate byte buffer"));
	BYTE b;

	unsigned long iOutSize = 0;
	unsigned long iTotSize = 0;
	RTFinflator rfi(pData,iSize+1);
	
	char* pInflated=new char[16385];
	THROW_IF_FAILED_TO_ALLOCATE_MEMORY(pInflated, _T("Failed to allocate Char buffer"));

	while (!rfi.IsFinished())
	{
		iOutSize=rfi.GetData(pInflated,16384);

		for (unsigned long i = 0, j = 0; i < iOutSize; i++,j++)
		{
			if (isdigit(pInflated[i])) b = pInflated[i] - '0';
			else b = pInflated[i] - 'a' + 10;	// always lower
			i++;
			b <<= 4;
			if (isdigit(pInflated[i])) b |= pInflated[i] - '0';
			else b |= pInflated[i] - 'a' + 10;	// always lower

			byteBuffer[(iTotSize/2)+j] = b;
		}

		iTotSize+=iOutSize;
	}

	CHECK_ALGORITHM_INTEGRITY(rfi.IsFinished());
	CHECK_ALGORITHM_INTEGRITY(iTotSize==iFullSize);
	::delete [] pInflated;

	(*lBufferLength) = lLength;
	return byteBuffer;
}
コード例 #8
0
int main()
{
    if( fv(rfc()) == fv(rfi()) ) fail(__LINE__);
    _PASS;
}