Exemplo n.º 1
0
void testParseFile()
{
	packets results;
	//parseFile("c:\\Users\\David\\Documents\\packets.txt", -1, -1, results);
	//parseFile("c:\\Users\\David\\Documents\\packets.txt", -1, 30, results);
	parseFile("c:\\Users\\David\\Documents\\packets.txt", 2, 4, results);
}
Exemplo n.º 2
0
void KernelSourceParser::WorkerThread::run()
{
    QString currentFile;
    QMutexLocker lock(&_parser->_filesMutex);
    _stopExecution = false;

    while (!_stopExecution && !Console::interrupted() &&
           _parser->_filesIndex < _parser->_fileNames.size())
    {
        currentFile = _parser->_fileNames[_parser->_filesIndex++];
        _parser->_currentFile = currentFile;

        if (_parser->_filesIndex <= 1)
            _parser->operationProgress();
        else
            _parser->checkOperationProgress();
        lock.unlock();

        parseFile(currentFile);

        lock.relock();
        _parser->_bytesRead += QFileInfo(_parser->_srcDir, currentFile).size();
        _parser->_durationLastFileFinished = _parser->_duration;
    }
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
	char * fileName;

	fileName = NULL;

	if(argc < 2)
	{
		printf("Error: Please enter a file name.\n");
		return 1;
	}
	if(argv[1] == NULL)
	{
		printf("Error: No file name given.\n");
		return 1;
	}

	fileName = argv[1];

	printf("File = %s\n", fileName);
	parseFile(fileName);


	return 0;
}
Exemplo n.º 4
0
void QoreProgram::parseFileAndRun(const char* filename) {
   ExceptionSink xsink;

   parseFile(filename, &xsink);

   if (!xsink.isEvent()) {
      // get class name
      if (priv->exec_class) {
	 if (!priv->exec_class_name.empty())
	    runClass(priv->exec_class_name.c_str(), &xsink);
	 else {
	    char* c, *bn = q_basenameptr(filename);
	    if (!(c = strrchr(bn, '.')))
	       runClass(filename, &xsink);
	    else {
	       QoreString qcn; // for possible class name
	       qcn.concat(bn, c - bn);
	       runClass(qcn.getBuffer(), &xsink);
	    }
	 }
      }
      else
	 run(&xsink);
   }
}
Exemplo n.º 5
0
void UserController::onInit(InitEvent &evt)
{
	robotName = "robot_000";
    
	//m_kinect = connectToService("SIGKINECT");
	//m_hmd = connectToService("SIGHMD");
	parseFile("command.txt");
    Mission_complete = false;
	//printf("Reslutat %s", rooms[2]);
	rooms.clear();
	objects.clear();
	m_message = 10 ;

	cycle = 0;
    m_state =20;
	srand(time(NULL));

	//初期位置の設定
	SimObj *my = this->getObj(this->myname());
	m_posx = my->x();
	m_posy = my->y();
	m_posz = my->z();
	m_range = 0.1;
	m_maxsize = 15;
}
Exemplo n.º 6
0
ntlWorld::ntlWorld(string filename, bool commandlineMode) 
{
#ifndef ELBEEM_PLUGIN

		initDefaults();
#	ifdef NOGUI
		commandlineMode = true; // remove warning...
#	endif // NOGUI

		// load config
		setPointers( getRenderGlobals() );
		parseFile( filename.c_str() );
#	ifndef NOGUI
		// setup opengl display, save first animation step for start time 
		// init after parsing file...
		if(!commandlineMode) {
			mpOpenGLRenderer = new ntlOpenGLRenderer( mpGlob );
		}
#	endif // NOGUI
		finishWorldInit();

#else // ELBEEM_PLUGIN
	errFatal("ntlWorld::init","Cfg file parsing not supported for API version! "<<filename<<" "<<commandlineMode, SIMWORLD_INITERROR);
#endif // ELBEEM_PLUGIN
}
Exemplo n.º 7
0
int _tmain(int argc, char* argv[])
{
	char *inFile = NULL;
	outFormat format = NOTSET;
	int rowStart = -1;
	int rowEnd = -1;
	packets parsedList;

#ifdef _DEBUG
	testparseQueryString();
	testParseFile();
#endif

	printf("Content-Type: text/xml\n\n");

	if (!checkArgs(argc, argv, &inFile, format, rowStart, rowEnd))
	{
		printUsage();
		return -1;
	}

	parseFile(inFile, rowStart, rowEnd, parsedList);

	outputInfo(parsedList, format);

	return 0;
}
Exemplo n.º 8
0
SceneParser::SceneParser(const char* filename) {

  // initialize some reasonable default values
  group = NULL;
  camera = NULL;
  background_color = Vec3f(0.5,0.5,0.5);
  ambient_light = Vec3f(0,0,0);
  num_lights = 0;
  lights = NULL;
  num_materials = 0;
  materials = NULL;
  current_material = NULL;

  // parse the file
  assert(filename != NULL);
  const char *ext = &filename[strlen(filename)-4];
  assert(!strcmp(ext,".txt"));
  file = fopen(filename,"r");
  assert (file != NULL);
  parseFile();
  fclose(file); 
  file = NULL;

  // if no lights are specified, set ambient light to white 
  // (do solid color ray casting)
  if (num_lights == 0) {
    printf ("WARNING:  No lights specified\n");
    ambient_light = Vec3f(1,1,1);
  }
}
Exemplo n.º 9
0
int main(int argc,char* argv[])
{
	// Use a try/catch block for parser exceptions
	try
	{
		// if we have at least one command-line argument
		if (argc > 1 )
		{
			cerr << "Parsing..." << endl;

			// for each file specified on the command line
			for(int i=1; i< argc;i++)
			{
				cerr << "   " << argv[i] << endl;
				parseFile(argv[i]);
			}
		}
		else
			cerr << "Usage: " << argv[0]
			<< " <file name(s)>" << endl;
	}
	catch(exception& e) {
		cerr << "exception: " << e.what() << endl;
	}
}
Exemplo n.º 10
0
MeshModel *Loader_3DS::load( const string &filename,const Transform &t,int hint ){

	conv_tform=t;
	conv=flip_tris=false;
	if( conv_tform!=Transform() ){
		conv=true;
		if( conv_tform.m.i.cross(conv_tform.m.j).dot(conv_tform.m.k)<0 ) flip_tris=true;
	}

	collapse=!!(hint&MeshLoader::HINT_COLLAPSE);
	animonly=!!(hint&MeshLoader::HINT_ANIMONLY);

	if( !in.open( filename.c_str(),ios_base::in|ios_base::binary ) ){
		return 0;
	}

	MeshModel *root=parseFile();
	in.close();

	materials_map.clear();
	name_map.clear();
	id_map.clear();

	return root;
}
Exemplo n.º 11
0
int main(){
	exception e;
	VTDGen *vg = NULL;
	VTDNav *vn = NULL;
	AutoPilot *ap = NULL;
	UCSChar *string = NULL; 
	int i;
    
	Try{
		ap = createAutoPilot2();
		selectXPath(ap,L"/a/b/text()");
		vg = createVTDGen();
		if (parseFile(vg,FALSE,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/2/input.xml")){
			vn = getNav(vg);
			bind(ap,vn);
			while((i=evalXPath(ap))!=-1){
				string = toString(vn,i);
				wprintf(L"the text node value is %d ==> %s \n",i,string);
				free(string);
			}
			free(vn->XMLDoc);
		} else {
			free(vg->XMLDoc);
		}
	}Catch(e){// handle various types of exceptions here
	}
	freeAutoPilot(ap);
	freeVTDGen(vg);
	freeVTDNav(vn);
	return 0;
}
Exemplo n.º 12
0
//*****************************************************************************
//  CONSTRUCTOR: ossimNitfRpcModel
//  
//  Constructs given filename for NITF file
//  
//*****************************************************************************
ossimNitfRpcModel::ossimNitfRpcModel(const ossimFilename& nitfFile)
   :
   ossimRpcModel(),
   theDecimation(1.0)
{
   if (traceExec())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "DEBUG ossimNitfRpcModel::ossimNitfRpcModel(nitfFile): entering..."
         << std::endl;
   }
   if(!parseFile(nitfFile))
   {
      if (traceExec())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
            << "DEBUG ossimNitfRpcModel::ossimNitfRpcModel(nitfFile): Unable to parse file " << nitfFile
            << std::endl;
      }
      ++theErrorStatus;
   }

   if (traceExec())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "DEBUG ossimNitfRpcModel::ossimNitfRpcModel(nitfFile): returning..."
         << std::endl;
   }
}
Exemplo n.º 13
0
bool parseFile(Game& game, const char* filename)
{
  //bool value;
  FILE* in = fopen(filename, "r");
  //int size;
  if(!in)
    return false;

  parseFile(in);

  sexp_t* st = NULL;

  while((st = parse()))
  {
    if( !parseSexp(game, st) )
    {
      while(parse()); //empty the file, keep Lex happy.
      fclose(in);
      return false;
    }
    destroy_sexp(st);
  }

  fclose(in);

  return true;
}
Exemplo n.º 14
0
void HippoGridManager::loadFromFile()
{
	mDefaultGridsVersion = 0;
	// load user grid info
	parseFile(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml"), false);
	// merge default grid info, if newer. Force load, if list of grids is empty.
	parseFile(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "default_grids.xml"), !mGridInfo.empty());
	// merge grid info from web site, if newer. Force load, if list of grids is empty.
	if (gSavedSettings.getBOOL("CheckForGridUpdates"))
		parseUrl("http://imprudenceviewer.org/app/grids/", !mGridInfo.empty());

	std::string last_grid = gSavedSettings.getString("LastSelectedGrid");
	if (last_grid.empty()) last_grid = gSavedSettings.getString("DefaultGrid");
	setDefaultGrid(last_grid);
	setCurrentGrid(last_grid);
}
Exemplo n.º 15
0
ProjectSPtr ProjectParserMixin::parseProject(const ProjectParseContextSPtr& context)
{
    TokenizerPtr& tokenizer = context->tokenizer;

    context->mProject = boost::make_shared<Project>();

    FileSPtr file = parseFile(context);
    if (!file)
        return ProjectSPtr();

    if (!context->mProject->mainFile())
        context->mProject << file;

    CommentSPtr pStatementComment = lastComment(context);
    while (tokenizer->current())
    {
        if (tokenizer->check(Token::TYPE_IDENTIFIER))
        {
            parseProjectStatement(context, pStatementComment);
        }
        else
        {
            tokenizer->shift();
        }
        pStatementComment = lastComment(context);
    }

    if (context->mMessageCollector->severity() > Message::SEVERITY_WARNING)
        return ProjectSPtr();

    return context->mProject;
}
Exemplo n.º 16
0
int main(){
	exception e;
	VTDGen *vg = NULL;
	VTDNav *vn = NULL;
	AutoPilot *ap1 = NULL;
	FILE *f = NULL;
	UCSChar *string = NULL;
	int i;
	Try{			
		vg = createVTDGen();		
		if (parseFile(vg,TRUE,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/13/old_cd.xml")==FALSE){
			free(vg->XMLDoc);
			freeVTDGen(vg);
			return 0;
		}	
		ap1 = createAutoPilot2();
		selectXPath(ap1,L"/CATALOG/CD[PRICE=10.2]/*/text()");
		vn = getNav(vg);
		bind(ap1,vn);
		while((i=evalXPath(ap1))!=-1){
			overWrite(vn,i,"",0,0);		
		}
		f= fopen("d:/ximpleware_2.2_c/vtd-xml/codeGuru/13/new_cd.xml","wb");
		fwrite(vn->XMLDoc+vn->docOffset,1,vn->docLen,f);
		fclose(f);
		free(vn->XMLDoc);
	}Catch(e){// handle various types of exceptions here
	}
	freeAutoPilot(ap1);
	freeVTDGen(vg);
	freeVTDNav(vn);
	return 0;
}
Exemplo n.º 17
0
int main(){
	exception e;
	VTDGen *vg = NULL;
	VTDNav *vn = NULL;
	UCSChar *string = NULL;
	Try{
		vg = createVTDGen();
		if (parseFile(vg,TRUE,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/1/input.xml")){
			vn = getNav(vg);
			if (toElementNS(vn,FIRST_CHILD,L"someURL",L"b")){
				int i = getText(vn);
				if (i!=-1){
					string = toString(vn,i);
					wprintf(L"the text node value is %d ==> %s \n",i,string);
					free(string);
				}
			}
			free(vn->XMLDoc);
		} else {
			free(vg->XMLDoc);
		}
	}Catch(e){// handle various types of exceptions here
	}
	freeVTDGen(vg);
	freeVTDNav(vn);
	return 0;
}
Exemplo n.º 18
0
void CGICoreModule__WHILE__Process(Properties *x, const char *data){
   if (!x    ) return;
   if (!data ) return;

   while (x->getAsInt("NAME"))
      parseFile(data);
};
Exemplo n.º 19
0
void ConfigFile::setOption(const std::string &_option, const std::string &_val) {
    if (!m_fileIsParsed) {
        parseFile("vk_layer_settings.txt");
    }

    m_valueMap[_option] = _val;
}
Exemplo n.º 20
0
/*
	exploreDirectories travels through directories given a char* inputname.
		Recursive calls are initiated on file pointers until Files are reached.
		The base case handles files by calling parseFile.

	@param inputname : input directory name
*/
int exploreDirectories(char* inputname)
{

	/* enum value will keep record of current type */
	enum{File, Directory} type 		= Directory;
	
	void *fileptr					= opendir(inputname);
	struct dirent *entry;

	if(fileptr == NULL){
		type 		= File;
		fileptr 	= fopen(inputname, "r+");
		
		if(fileptr == NULL){
			perror(fileptr);
			return 0;
		}
	}

	/* Current recursive iteration is a directory */
	if(type == Directory){

		DIR *directory 	= (DIR *)fileptr;
		for(;;){
			entry 	= readdir(directory);

			/* Empty directory */
			if(entry == NULL){
				break;
			}

			/* Protection against recursing backwards */
			if(!strcmp(entry->d_name,".") || !strcmp(entry->d_name,"..")){
				continue;
			}

			/* Save filepath as string */
			char* next 	= (char *)malloc(strlen(inputname) + strlen(entry->d_name) + 2);
			strcpy(next, inputname);
			strcat(next, "/");
			strcat(next, entry->d_name);

			/* Recursive call */
			//printf("Current directory:\t%s\n",next);
			exploreDirectories(next);
			free(next);
		}
		closedir(directory);

	}
	/* Current recursive iteration is a file (Base case) */
	else{
		//printf(">>Exploring file:\t%s \n", inputname);
		FILE *file = (FILE *)fileptr;
		parseFile(file, inputname);
		fclose(file);
	}

	return 0;
}
void TatortTendencyParser::parseTestData(string inFilename, string delimiter, bool isHeaderPresent) {

	_testData.clear();

	parseFile(inFilename, delimiter, isHeaderPresent);

	Logger::getInstance()->log("start parsing test data to predict ...", LOG_DEBUG);

	vector<string> userIds = getColumn(0);
	vector<string> itemIds = getColumn(2);
	vector<string> detectiveIds = getColumn(4);
	vector<string> ratings = getColumn(11);

	for (int i = 0; i < _numOfDatasets; i++) {
		vector<int> testTupel;
		testTupel.push_back(stoi(userIds[i]));
		testTupel.push_back(stoi(itemIds[i]));
		testTupel.push_back(stoi(detectiveIds[i]));

		_testData.push_back(testTupel);
		_testRatings.push_back(stod(ratings[i]));
	}

	Logger::getInstance()->log("parsing test data done!", LOG_DEBUG);
}
Exemplo n.º 22
0
int main(int argc, char *argv[])
{
	int i;	
	
	if (argc < MIN_ARGS)
	{
		printf("ERROR: No file name, please provide the script with a least one file to run on.\n");
		return 1;
	}
	
	/*Parse the provided files one by one*/
	for (i=1; i < argc; i++)
	{
		/*Check fileName length*/
		if (strlen(argv[i]) > MAX_FILENAME_LEN)
		{
			printf("ERROR: Maximum allowed file name length is %d.\n", (MAX_FILENAME_LEN));
			return 1;
		}
		
		printf("------------ Parsing File: \"%s%s\" ------------\n\n", argv[i], INPUT_FILE_EXTENSION);
		parseFile(argv[i]);
	}

	return 0;
}
Exemplo n.º 23
0
void Parser::init(ParserContext *context)
{
#if 0
  if (!parseFile(context, ":/schema/XMLSchema.xsd")) {
      qWarning("Error parsing builtin file XMLSchema.xsd");
  }
#else
  Q_UNUSED(context);
#endif

    // From the XML schema XSD
    {
        Element schema(XMLSchemaURI);
        schema.setName(QLatin1String("schema"));
        schema.setType(QName(XMLSchemaURI, QLatin1String("anyType")));
        d->mElements.append(schema);
    }

    // Define xml:lang, since we don't parse xml.xsd
    {
        Attribute langAttr(NSManager::xmlNamespace());
        langAttr.setName(QLatin1String("lang"));
        langAttr.setType(QName(XMLSchemaURI, QLatin1String("string")));
        d->mAttributes.append(langAttr);
    }


  // From http://schemas.xmlsoap.org/wsdl/soap/encoding
  {
      ComplexType array(soapEncNs);
      array.setArrayType(QName(XMLSchemaURI, QString::fromLatin1("any")));
      array.setName(QLatin1String("Array"));
      d->mComplexTypes.append(array);
  }

  // From http://schemas.xmlsoap.org/soap/encoding/, so that <attribute ref="soap-enc:arrayType" arrayType="kdab:EmployeeAchievement[]"/>
  // can be resolved.
  {
      Attribute arrayTypeAttr(soapEncNs);
      arrayTypeAttr.setName(QLatin1String("arrayType"));
      arrayTypeAttr.setType(QName(XMLSchemaURI, QLatin1String("string")));
      d->mAttributes.append(arrayTypeAttr);
  }

  // Same thing, but for SOAP-1.2: from http://www.w3.org/2003/05/soap-encoding
  {
      ComplexType array(soap12EncNs);
      array.setArrayType(QName(XMLSchemaURI, QString::fromLatin1("any")));
      array.setName(QLatin1String("Array"));
      d->mComplexTypes.append(array);
  }
  {
      Attribute arrayTypeAttr(soap12EncNs);
      arrayTypeAttr.setName(QLatin1String("arrayType"));
      arrayTypeAttr.setType(QName(XMLSchemaURI, QLatin1String("string")));
      d->mAttributes.append(arrayTypeAttr);
  }

}
Exemplo n.º 24
0
void QoreProgram::parseFileAndRunClass(const char* filename, const char* classname) {
   ExceptionSink xsink;

   parseFile(filename, &xsink);

   if (!xsink.isEvent())
      runClass(classname, &xsink);
}
Exemplo n.º 25
0
int main ( int argc, char ** argv )
{
    	FILE * mainSVM = fopen ( argv[1], "r");
	instruction * chain = parseFile ( mainSVM );
	interpreteer * runner = initializeInterpreteer ( chain );
	printf("%d", runProgram ( runner ));
	return 0;
}
Exemplo n.º 26
0
//--------------------------------------------------------------
// constructor
mgCursorDefn::mgCursorDefn(
  const char* fileName)
{
  m_hotX = 0;
  m_hotY = 0;

  parseFile(fileName);
}
Exemplo n.º 27
0
//--------------------------------------------------------------
// constructor
ShapeFile::ShapeFile(
  const char* fileName)
{
  m_xmin = m_ymin = m_zmin = 0.0;
  m_xmax = m_ymax = m_zmax = 1.0;

  parseFile(fileName);
}
Exemplo n.º 28
0
ClientIdInterface::ClientIdInterface()
{
    m_keyChars = "[email protected]!?$";
    m_keyCharLen = strlen(m_keyChars);
    m_file.setFileName("client_ids.dat");
    srand(time(NULL));
    parseFile();
}
Exemplo n.º 29
0
AceSweParser::AceSweParser( string fileName )
  : FileParser( fileName, AceSweParser::tags )
{
  LOG_DEBUG( 11, "( " << fileName << " )" )

  parseFile();
  finalizeSeriesData();
}// end AceSweParser::AceSweParser( string )
Exemplo n.º 30
0
string EditorBase::GetAttributeFromInfoFile(const string &programPath, const string &entity, const string &attrib)
{
	wstring file = utf8::c(programPath).wstr();
	file += L"\\";
	file += _ENML_EDITOR_GENERAL_INFO;
	enml::File parseFile(enml::GetStringFromAnsiFile(file));
	return utf8::c(parseFile.Get(utf8::c(entity).wstr(), utf8::c(attrib).wstr())).str();
}