void Fidelity::Engine::SimulationXmlReader::readFSX()
{
	while(!atEnd()) {
		readNext();

		if(isEndElement()) {
			break;
		}

		// Evaluate child tags
		if(isStartElement()) {
			// We expect these children for the root tag
			if (name() == "description") {
				readDescription();
			}
			else if (name() == "globals") {
				readGlobals();
			}
			else if (name() == "engine") {
				readEngine();
			}
			else if (name() == "plugins") {
				readPlugins();
			}
			else if (name() == "setup") {
				readSetup();
			}
			else {
				unknownElement();
			}
		}
	}
}
Beispiel #2
0
void XbelReader::readFolder(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("folder"));

    BookmarkNode *folder = new BookmarkNode(BookmarkNode::Folder, parent);
    folder->expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no"));

    while (!atEnd()) {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement()) {
            if (name() == QLatin1String("title"))
                readTitle(folder);
            else if (name() == QLatin1String("desc"))
                readDescription(folder);
            else if (name() == QLatin1String("folder"))
                readFolder(folder);
            else if (name() == QLatin1String("bookmark"))
                readBookmarkNode(folder);
            else if (name() == QLatin1String("separator"))
                readSeparator(folder);
            else
                skipUnknownElement();
        }
    }
}
Beispiel #3
0
void ERFFile::load() {
	Common::File erf;
	open(erf);

	readHeader(erf);

	if ((_id != kERFID) && (_id != kMODID) && (_id != kHAKID) && (_id != kSAVID))
		throw Common::Exception("Not an ERF file");

	if ((_version != kVersion1) && (_version != kVersion2))
		throw Common::Exception("Unsupported ERF file version %08X", _version);

	if ((_version == kVersion2) && !_utf16le)
		throw Common::Exception("ERF file version 2.0, but not UTF-16LE");

	try {

		ERFHeader erfHeader;

		readERFHeader  (erf, erfHeader);
		readDescription(erf, erfHeader);

		if (!_noResources)
			readResources(erf, erfHeader);

		if (erf.err())
			throw Common::Exception(Common::kReadError);

	} catch (Common::Exception &e) {
		e.add("Failed reading ERF file");
		throw e;
	}

}
Beispiel #4
0
int ERFFile::init(int n)
{
	if(!reading()) return errcode = 6;
	if(n == -1) n = initstages;
	if((n > 0) && !inited[0] && readHeader()) return errcode;
	if((n > 1) && !inited[1] && readDescription()) return errcode;
	if((n > 2) && !inited[2] && readKeyList()) return errcode;
	return errcode = 0;
}
Beispiel #5
0
void XbelReader::readBookmarkNode(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("bookmark"));
    BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark, parent);
    bookmark->url = attributes().value(QLatin1String("href")).toString();
    while (readNextStartElement()) {
        if (name() == QLatin1String("title"))
            readTitle(bookmark);
        else if (name() == QLatin1String("desc"))
            readDescription(bookmark);
        else
            skipCurrentElement();
    }
    if (bookmark->title.isEmpty())
        bookmark->title = QObject::tr("Unknown title");
}
Beispiel #6
0
void KreImporter::parseFile( const QString &filename )
{
	QFile * file = 0;
	bool unlink = false;
	kDebug() << "loading file:" << filename ;

	if ( filename.right( 4 ) == ".kre" ) {
		file = new QFile( filename );
		kDebug() << "file is an archive" ;
		KTar* kre = new KTar( filename, "application/x-gzip" );
		kre->open( QIODevice::ReadOnly );
		const KArchiveDirectory* dir = kre->directory();
		QString name;
		QStringList fileList = dir->entries();
		for ( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) {
			if ( ( *it ).right( 6 ) == ".kreml" ) {
				name = *it;
			}
		}
		if ( name.isEmpty() ) {
			kDebug() << "error: Archive doesn't contain a valid Krecipes file" ;
			setErrorMsg( i18n( "Archive does not contain a valid Krecipes file" ) );
			return ;
		}
		QString tmp_dir = KStandardDirs::locateLocal( "tmp", "" );
		dir->copyTo( tmp_dir );
		file = new QFile( tmp_dir + name );
		kre->close();
		unlink = true; //remove file after import
	}
	else {
		file = new QFile( filename );
	}

	if ( file->open( QIODevice::ReadOnly ) ) {
		kDebug() << "file opened" ;
		QDomDocument doc;
		QString error;
		int line;
		int column;
		if ( !doc.setContent( file, &error, &line, &column ) ) {
			kDebug() << QString( "error: \"%1\" at line %2, column %3" ).arg( error ).arg( line ).arg( column ) ;
			setErrorMsg( i18n( "\"%1\" at line %2, column %3" , error , line, column ) );
			return ;
		}

		QDomElement kreml = doc.documentElement();

		if ( kreml.tagName() != "krecipes" ) {
			setErrorMsg( i18n( "This file does not appear to be a *.kreml file" ) );
			return ;
		}

		// TODO Check if there are changes between versions
		QString kreVersion = kreml.attribute( "version" );
		kDebug() << "KreML version" << kreVersion ;

		QDomNodeList r = kreml.childNodes();
		QDomElement krecipe;

		for ( int z = 0; z < r.count(); z++ ) {
			krecipe = r.item( z ).toElement();
			QDomNodeList l = krecipe.childNodes();
			if ( krecipe.tagName() == "krecipes-recipe" ) {
				Recipe recipe;
				for ( int i = 0; i < l.count(); i++ ) {
					QDomElement el = l.item( i ).toElement();
					if ( el.tagName() == "krecipes-description" ) {
						readDescription( el.childNodes(), &recipe );
					}
					if ( el.tagName() == "krecipes-ingredients" ) {
						readIngredients( el.childNodes(), &recipe );
					}
					if ( el.tagName() == "krecipes-instructions" ) {
						recipe.instructions = el.text().trimmed();
					}
					if ( el.tagName() == "krecipes-ratings" ) {
						readRatings( el.childNodes(), &recipe );
					}
				}
				add
					( recipe );
			}
			else if ( krecipe.tagName() == "krecipes-category-structure" ) {
				CategoryTree * tree = new CategoryTree;
				readCategoryStructure( l, tree );
				setCategoryStructure( tree );
			}
		}
	}
	if ( unlink ) {
		file->remove
		();
	}
}
Beispiel #7
0
int loadElf(int cpuf, int fd, unsigned int *entry_p, unsigned int *stack_p, int verbose)
{
   unsigned char buf[BUF_SIZE];
   int ReadBytes = 0, err = 0;

   //EntryPoint
   err = lseek(fd, 0x18, SEEK_SET);
   if(err < 0)
   {
      printf("error lseek(0x18) loadElf\n");
      return 1;
   }

   err = read(fd, &buf, 4);
   if(err != 4)
   {
      printf("error read(4) loadElf\n");
      return 1;
   }

   *entry_p = buf[0]|buf[1]<<8|buf[2]<<16|buf[3]<<24;
   //printf("EntryPoint is 0x%08X\n", *entry_p);

   //seek to the table address field
   err = lseek(fd, 0x20, SEEK_SET);
   if(err < 0)
   {
      printf("error lseek(0x18) loadElf\n");
      return 1;
   }

   err = read(fd, &buf, 4);
   if(err != 4)
   {
      printf("error read(4) loadElf\n");
      return 1;
   }

   unsigned int TableAddress = buf[0]|buf[1]<<8|buf[2]<<16|buf[3]<<24;
   //printf("TableAddress is 0x%08X\n", TableAddress);

   err = lseek(fd, TableAddress, SEEK_SET);
   if(err < 0)
   {
      printf("error lseek(TableAdress) loadElf\n");
      return 1;
   }

   while( (ReadBytes = read(fd, &buf, 10 * sizeof(int))) == (10 * sizeof(int)) ) {

      unsigned int IncreasingNumber   = buf[0]  | buf[1]<<8  | buf[2]<<16  | buf[3]<<24;
      unsigned int Flags              = buf[4]  | buf[5]<<8  | buf[6]<<16  | buf[7]<<24;
      unsigned int DontKnow2          = buf[8]  | buf[9]<<8  | buf[10]<<16 | buf[11]<<24;

      unsigned int DestinationAddress = buf[12] | buf[13]<<8 | buf[14]<<16 | buf[15]<<24;
      unsigned int SourceAddress      = buf[16] | buf[17]<<8 | buf[18]<<16 | buf[19]<<24;
      unsigned int Size               = buf[20] | buf[21]<<8 | buf[22]<<16 | buf[23]<<24;

      unsigned int DontKnow3          = buf[24] | buf[25]<<8 | buf[26]<<16 | buf[27]<<24;
      unsigned int DontKnow4          = buf[28] | buf[29]<<8 | buf[30]<<16 | buf[31]<<24;

      unsigned int Alignment          = buf[32] | buf[33]<<8 | buf[34]<<16 | buf[35]<<24;

      unsigned int DontKnow5          = buf[36] | buf[37]<<8 | buf[38]<<16 | buf[39]<<24;

      if(DestinationAddress == 0x00 && SourceAddress != 0x00) {
         //Source Address is address of description
         err = readDescription(fd, SourceAddress, Size);
         if(err != 0) return 1;
         break; //Exit While
      } else {
         //Add Index to Table
         addIndex(DestinationAddress, SourceAddress, Size, Alignment,
                  Flags, DontKnow2);
      }

   }
   if(ReadBytes != 10 * sizeof(int))
   {
      printf("error ReadBytes\n");
      return 1;
   }
	
   //printTable();

   err = sectionToSlave(cpuf, fd, entry_p);
   if(err != 0) return 1;

   //printf("start address = 0x%08X\n", *entry_p);

   return 0;
}