Beispiel #1
0
STATIC int loadFrame(LINEBUF *data, int numFields)
{
   register int nc;
   char *field, *stopChar;

   nc = -1;

   for (field = getNextLine(data);
      field != NULL && data->isComment;
      field = getNextLine(data)
   ) flushLine(data, NULL);

   if (field != NULL) {
      nc = 0;
      for (
         field = nextField(data, field);
         field != NULL;
         field = nextField(data, field)
      ) {
         if (nc == numFields) {
            nc = 0;
            break;
         }
         A[fields[nc]] = strtod(fieldData, &stopChar);
         if (stopChar == fieldData ||
            (*stopChar != 0 && !isspace(*stopChar))) {
            nc = 0;
            break;
         }
         nc++;
      }
   }
   return nc;
}
Beispiel #2
0
Image::Image(const char * path) {
	std::ifstream imageIs(path);
	if (!imageIs) {
		fprintf(stderr, "Loading image fail.\n");
		return;
	}

	std::string line;

	getNextLine(imageIs, line);
	auto vs = splitLine(line);
	width = std::stoi(vs[1]);

	getNextLine(imageIs, line);
	vs = splitLine(line);
	height = std::stoi(vs[1]);

	image = new uint32_t[width*height];

	for (int i = 0; i != height; ++i) {
		getNextLine(imageIs, line);
		//vs = splitLine(line);
		std::istringstream iss(line);
		for (int j = 0; j != width; ++j) {
			uint32_t value;
			iss >> value;
			image[i*width + j] = value;
		}
	}
	
}
//--------------------------------------------
// Function: populateNodes()				 *
// Purpose: Populate Node array				 *
// Returns: void							 *
//--------------------------------------------
	void Prog3Graph::populateNodes(char *filename)
	{
		
		inFile.open(filename);	
	    char line[80];
		 
		int inputData;
		

	    getNextLine(line, 80);		// priming read
        bool stillNextLine = true;
		
		

        // Continue while there is still data being read
        while(stillNextLine == true)
        { 
			
			int numEdges = 0;
			stringstream streamVar(line);
			streamVar >> inputData;	
		           					
			getNextLine(line, 80);
	
			
			

			getNextLine(line, 80);
			streamVar.str(std::string());
			streamVar.clear();
			streamVar << line;	// convert number of edges to int
			streamVar >> numEdges;

			insertNode(inputData, line, numEdges);

			for(;numEdges > 0; numEdges--)
			{
				getNextLine(line, 80);			
			}

			streamVar.str(std::string());
			streamVar.clear();
            stillNextLine = getNextLine(line, 80);
			
        }
		inFile.close();
            // Repeat while variable = true		    
    		    // Save line to nodeID
    		    // getNextLine
    		    // Save line to nodeData
    		    // getNextLine
    		    // save line to number of edges
    		    // do a for loop to skip that many lines (= edges)
    		    // variable = getNextLine
		     
		             
		//   - adds all nodes in file (calls insertNode(); maybe getNode()
		//     to check if it's already there too)
	}
Beispiel #4
0
int graphLoad(GraphStruct * graph, FILE * gdata) {
	int numGlobalVertices, numGlobalEdges, numParts;
	int i, j, nnbors;

	/* Get the number of vertices */
	getNextLine(gdata, line, bufsize);
	sscanf(line, "%d", &numGlobalVertices);

	/* Get the number of edges  */
	getNextLine(gdata, line, bufsize);
	sscanf(line, "%d", &numGlobalEdges);

	/* Get the number of partitions  */
	getNextLine(gdata, line, bufsize);
	sscanf(line, "%d", &numParts);

	/* Allocate arrays to read in entire graph */
	graphInit(graph, numGlobalVertices, numGlobalEdges << 1, numParts);

	char * token;
	//TODO partition placement???
//	//read current partition mapping to physical cores in pairs of <partNO, coreID>
	for (i = 0; i < numParts; i++) {
		getNextLine(gdata, line, bufsize);
//		token = strtok(line, " ");
//		part = atoi(token);
//		token = strtok(NULL, " ");
//		memcpy(graph->partPlacement + part * 5, token, 5);
	}
//	graph->partPlacement[5 * numParts] = '\0';

	//each line is in the form of vtx_id  part_id vtx_wgt vtx_size  num_nbors  nbor_id  edge_wgt  nbor_id  edge_wgt
	for (i = 0; i < numGlobalVertices; i++) {
		getNextLine(gdata, line, bufsize);

		token = strtok(line, " ");
		graph->vertexGIDs[i] = atoi(token);
		token = strtok(NULL, " ");
		graph->partVector[i] = atoi(token);

		token = strtok(NULL, " ");
		graph->vertexWgts[i] = (float) atof(token);
		token = strtok(NULL, " ");
		graph->vertexSize[i] = atoi(token);
		token = strtok(NULL, " ");
		nnbors = atoi(token);

		graph->nborIndex[i + 1] = graph->nborIndex[i] + nnbors;
		for (j = graph->nborIndex[i]; j<graph->nborIndex[i + 1]; j++) {
			token = strtok(NULL, " ");
			graph->nborGIDs[j] = atoi(token);
			token = strtok(NULL, " ");
			graph->edgeWgts[j] = (float) atof(token);
		}
	}
	return 0;
}
//--------------------------------------------
// Function: populateEdges()				 *
// Purpose: Populate AdjMatrix				 *
// Returns: void							 *
//--------------------------------------------
	void Prog3Graph::populateEdges(char *filename)
	{
		// - reads through file
		// - adds all edges in file

		inFile.open(filename);	
	    char line[80];
		int inputData;

		getNextLine(line, 80);		// priming read
        bool stillNextLine = true;
		
		
		while(stillNextLine == true)
        { 
			int numEdges = 0;
			
			
			
			stringstream streamVar(line);
			streamVar >> inputData;	
			int aIndex = inputData;
			streamVar.str(std::string());
			streamVar.clear();
       
			getNextLine(line, 80);
			getNextLine(line, 80);
			streamVar << line;
			streamVar >> inputData;
			numEdges = inputData;
			streamVar.str(std::string());
			streamVar.clear();
			


			for(;numEdges > 0; numEdges--)
			{
				getNextLine(line, 80);
				stringstream streamVar(line);
				streamVar >> inputData;
				int bIndex = inputData;
				streamVar.str(std::string());
				streamVar.clear();
				insertEdge(aIndex, bIndex);
			}


            stillNextLine = getNextLine(line, 80);	
        }
		inFile.close();
	}
bool loadModels(const char* path, std::vector<Model>& out_models) {
	printf("Loading MODELS file %s...\n", path);
    
	FILE * file = fopen(path, "r");
	if( file == NULL ){
		printf("Impossible to open the file ! Are you in the right path ? See Tutorial 1 for details\n");
		getchar();
		return false;
	}
    
    char line[1024];
    out_models.clear();
    
    int numModels = 0;
    getNextLine(file, line);
    sscanf(line, "%d", &numModels);
    out_models.resize(numModels);
    
//    float sx,sy,sz, rx,ry,rz,ra, tx,ty,tz;
//    float ar,ag,ab, dr,dg,db, sr,sg,sb,ss;
    char str[1024];
    for (int i = 0; i < numModels; ++i) {
        Model m;
        // read obj file name
        getNextLine(file, line);
        sscanf(line, "%s\n", str);
        m.objFilename.assign(str);
        
        // read transformation
        getNextLine(file, line);
        sscanf(line, "%f %f %f %f %f %f %f %f %f %f\n",
               &m.sx, &m.sy, &m.sz,
               &m.rx, &m.ry, &m.rz, &m.ra,
               &m.tx, &m.ty, &m.tz );

        // read material
        getNextLine(file, line);
        sscanf(line, "%f %f %f %f %f %f %f %f %f %f\n",
               &m.ar, &m.ag, &m.ab,
               &m.dr, &m.dg, &m.db,
               &m.sr, &m.sg, &m.sb, &m.ss );

        getNextLine(file, line);
        sscanf(line, "%s\n", str);
        m.textureFilename.assign(str);
        
        out_models[i]=m;
    }
	return true;
}
Beispiel #7
0
	void VCFReader::processHeader(std::vector< graphite::Sample::SharedPtr >& bamSamplePtrs)
	{
		// for each line read and write it to the VCFWriter
		std::vector< std::string > headerLines;
		std::string line;
		std::string headerColumns = "";
		while (getNextLine(line) && line.c_str()[0] == '#')
		{
			if (line.find("#CHROM") == std::string::npos)
			{
				headerLines.emplace_back(line);
			}
			else
			{
				headerColumns = line;
			}
		}
		std::string columnLine = setSamplePtrs(headerColumns, bamSamplePtrs);
		headerLines.emplace_back(columnLine);
		// this->m_vcf_writer->setSamples(columnLine, this->m_sample_ptrs_map);
		this->m_vcf_writer->writeHeader(headerLines);
		if (line.size() > 0)
		{
			this->m_preloaded_variant = std::make_shared< Variant >(line, m_vcf_writer);
		}
	}
Beispiel #8
0
bool TextReaderBase::readIntoBuffer()
{
    if(isEOF()){
        return false;
    }

    QString line = getNextLine();
    linePos=0;


    buffer=line;
    bufferPos=0;
    /*
    buffer.append(line);
    ++lineCountInBuffer;

    if(lineCountInBuffer>5){
        int newLineIx=buffer.indexOf('\n');
        buffer.remove(0, newLineIx+1);
        bufferPos-=newLineIx+1;

        --lineCountInBuffer;
    }*/

    return true;
}
Beispiel #9
0
int* getRow(int rowIndex, int* returnSize) 
{
    int size = rowIndex+1;    
    *returnSize = size;

    int* prevLine = malloc(size*sizeof(int));
    int* curLine = malloc(size*sizeof(int));
    int* tempLine;
//	初始化第一行
    for (int i=0; i<size; ++i)
    {
    	*(prevLine+i)=0;
    }
    *prevLine=1;

    while (0==*(prevLine+size-1))
    {
    	getNextLine(prevLine,curLine,size);
    	tempLine=curLine;
    	curLine=prevLine;
    	prevLine=tempLine;
    }
    // free(curLine);
    return prevLine;
}
Beispiel #10
0
	bool VCFReader::getNextVariants(std::vector< Variant::SharedPtr >& variantPtrs, uint32_t spacing)
	{
		variantPtrs.clear();
		std::string nextLine;
		while (this->m_preloaded_variant != nullptr)
		{
			bool inTheZone = !(this->m_region_ptr != nullptr &&
				!(this->m_region_ptr->getReferenceID() == this->m_preloaded_variant->getChromosome() &&
				  this->m_region_ptr->getStartPosition() <= this->m_preloaded_variant->getPosition() &&
				  this->m_preloaded_variant->getPosition() <= this->m_region_ptr->getEndPosition()));

			bool isNextVariantCloseEnough = (variantPtrs.size() == 0) ? true : ((this->m_preloaded_variant->getChromosome() ==  variantPtrs[variantPtrs.size()-1]->getChromosome()) && (this->m_preloaded_variant->getPosition() -  variantPtrs[variantPtrs.size()-1]->getPosition()) < spacing); // if we are outside the region then break out

			if (!inTheZone || !isNextVariantCloseEnough)
			{
				break;
			}

			variantPtrs.emplace_back(this->m_preloaded_variant);
			if (!getNextLine(nextLine)) // if we are at the eof then set the variant to nullptr
			{
				this->m_preloaded_variant = nullptr;
				break;
			}
			this->m_preloaded_variant = std::make_shared< Variant >(nextLine, this->m_vcf_writer);
		}
		return variantPtrs.size() > 0;
	}
Beispiel #11
0
	void VCFReader::setRegion(Region::SharedPtr regionPtr)
	{
		if (regionPtr == nullptr)
		{
			return;
		}
		this->m_region_ptr = regionPtr;
		std::string nextLine;
		while (this->m_preloaded_variant != nullptr)
		{
			// as soon as we are inside the region then break out
			if (this->m_region_ptr->getReferenceID() == this->m_preloaded_variant->getChromosome() &&
				  this->m_region_ptr->getStartPosition() <= this->m_preloaded_variant->getPosition() &&
				  this->m_preloaded_variant->getPosition() <= this->m_region_ptr->getEndPosition())
			{
				break;
			}
			if (!getNextLine(nextLine)) // if we are at the eof then set the variant to nullptr
			{
				this->m_preloaded_variant = nullptr;
				break;
			}
			this->m_preloaded_variant = std::make_shared< Variant >(nextLine, this->m_vcf_writer);
		}
	}
bool ProgressiveChronFileReader::getNextValue(ChronItem_t& Value)
{
  std::vector<std::string> Values;
  openfluid::core::DateTime DT;
  double Val;

  while (getNextLine(Values))
  {
    if (Values.size() == 2)
    {
      if (DT.setFromString(Values.front(),m_DateFormat) &&
          openfluid::tools::convertString(Values.back(),&Val))
      {
        Value.first = DT;
        Value.second = Val;
        return true;
      }
      else
        throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                                  "wrong data in " + m_FileName);
    }
  }

  return false;
}
Beispiel #13
0
void OTMLParser::parse()
{
    if(!in.good())
        throw OTMLException(doc, "cannot read from input stream");

    while(!in.eof())
        parseLine(getNextLine());
}
Beispiel #14
0
long countData(LINEBUF *IFS)
{
    register long numDataLines = 0L;

    /* I don't recommend counting a non-rewindable stream! */
    if (IFS->norewind) return -1L;

    rewindBuf(IFS);
    while (getNextLine(IFS) != NULL) {
        if (! IFS->isComment) ++numDataLines;
        while (!IFS->fullLineRead)
            getNextLine(IFS);
    }
    rewindBuf(IFS);

    return numDataLines;
}
   /*
   * Read and execute commands from a specified command file.
   */
   void McSimulation::readCommands(std::istream &in)
   {
      if (!isInitialized_) {
         UTIL_THROW("McSimulation is not initialized");
      }

      std::string    command;
      std::string    filename;
      std::ifstream  inputFile;
      std::ofstream  outputFile;

      #ifndef UTIL_MPI
      std::istream&     inBuffer = in;
      #else
      std::stringstream inBuffer;
      std::string       line;
      #endif

      bool readNext = true;
      while (readNext) {

         // iffdef UTIL_MPI, read a line and copy to stringstream inBuffer
         // ifndef UTIL_MPI, inBuffer is simply a reference to istream in.

         #ifdef UTIL_MPI
         // Read a command line, and broadcast if necessary.
         if (!hasIoCommunicator() || isIoProcessor()) {
            getNextLine(in, line);
         }
         if (hasIoCommunicator()) {
            bcast<std::string>(communicator(), line, 0);
         }

         // Copy the command line to inBuffer.
         inBuffer.clear();
         for (unsigned i=0; i < line.size(); ++i) {
            inBuffer.put(line[i]);
         }
         #endif

         inBuffer >> command;
         Log::file() << command;

         if (isRestarting_) {

            if (command == "RESTART") {
               int endStep;
               inBuffer >> endStep;
               Log::file() << "  " << iStep_ << " to " 
                           << endStep << std::endl;
               simulate(endStep, isRestarting_);
               isRestarting_ = false;
            } else {
               UTIL_THROW("Missing RESTART command");
            }

         } else {
bool loadBuildings(const char* path, char* out_name, std::vector<Building>& out_buildings) {
    printf("Loading BUILDINGS file %s...\n", path);
    
    FILE * file = fopen(path, "r");
    if( file == NULL ){
        printf("Impossible to open the file ! Are you in the right path ? See Tutorial 1 for details\n");
        getchar();
        return false;
    }
    
    char name[1024];
    getNextLine(file, name);
    printf("Campus name = %s\n", name);
    out_name = name;
           
    char line[1024];
    out_buildings.clear();
    
    int numBuildings = 0;
    getNextLine(file, line);
    sscanf(line, "%d", &numBuildings);
    out_buildings.resize(numBuildings);
    printf("Expecting %d buildings\n", numBuildings);
    
    char str[1024];
    for (int i = 0; i < numBuildings; ++i) {
        Building b;
        
        // read .models name, followed by the transformation
        getNextLine(file, line);
        sscanf(line, "%s %f %f %f %f %f %f %f %f %f %f %f %f %f\n",
               str,
               &b.sx, &b.sy, &b.sz,
               &b.rx, &b.ry, &b.rz, &b.ra,
               &b.ox, &b.oy, &b.oz,
               &b.tx, &b.ty, &b.tz );

        b.modelsFilename.assign(str);
        
        out_buildings[i]=b;
    }
    return true;

}
    void processCommand()
    {
        if (!haveMoreLines())
            return;

        getNextLine();

        localSend("502 Command not implemented\r\n");
        processCommand();
    }
Beispiel #18
0
char *flushLine(LINEBUF *IFS, FILE *stream)
{
    char *returnValue = IFS->buffer;

    if (!IFS->fullLineRead) do {
            returnValue = getNextLine(IFS);
            if (stream != NULL && returnValue != NULL) fputs(IFS->buffer, stream);
        } while (!IFS->fullLineRead);
    return returnValue;
}
Beispiel #19
0
static char *getNextLine( int in, int newfile, const char *filename, unsigned lineno )
{
    static wio_ssize_t  rd;
    static char         *offset;
    static char         *start;
    static char         *endbuf;
    static int          finalread;
    static int          done = 0;

    if( done ) {
        done = 0;
        return( NULL );
    }
    if( newfile ) {
        rd = read( in, IObuffer, IObsize );
        if( -1 == rd )
            errorExit( "I/O error" );
        start = offset = IObuffer;
        endbuf = IObuffer + rd;
        finalread = ( rd != IObsize );
    }
    for( ; ; ) {
        wio_size_t const    len = ( ( endbuf - start ) - ( offset - start ) );
        char * const        lf = memchr( offset, '\n', len );
        char * const        line = start;

        if( lf != NULL ) {
            if( lf > IObuffer && lf[-1] == '\r' ) lf[-1] = '\0';
            *lf = '\0';
            offset = start = lf + 1;
            return( line );
        }
        if( finalread ) {
            endbuf[1] = '\0';
            done = 1;
            return( start );
        }
        if( len >= IObsize ) {
            free( IObuffer );
            IObsize += IObsize >> 1;
            IObuffer = malloc( IObsize );
            if( IObuffer == NULL || -1 == lseek( in, -rd, SEEK_CUR ) )
                errorExit( "line too long: len (%lu) >= IObsize (%lu) at \"%s\":%u",
                    (unsigned long)len, (unsigned long)IObsize, filename, lineno );
            return getNextLine( in, newfile, filename, lineno );
        }
        memmove( IObuffer, offset, len );
        start = IObuffer;
        offset = IObuffer + len;
        rd = read( in, offset, IObsize - len );
        if( -1 == rd )
            errorExit( "I/O error" );
        finalread = ( rd != IObsize - len );
        endbuf = offset + rd;
    }
Beispiel #20
0
bool Mal4sLog::parseCommitEntry(RCommit& commit) {

    std::string line;
    std::vector<std::string> entries;

    if(!getNextLine(line)) return false;

    //custom line
    if(!mal4s_regex.match(line, &entries)) return false;

    long timestamp       = atol(entries[0].c_str());

    std::string username = (entries[1].size()>0) ? entries[1] : "Unknown";
    std::string action   = (entries[2].size()>0) ? entries[2] : "A";

    //if this file is for the same person and timestamp
    //we add to the commit, else we save the lastline
    //and return false
    if(commit.files.empty()) {
        commit.timestamp = timestamp;
        commit.username  = username;
    } else {
        if(commit.timestamp != timestamp || commit.username  != username) {
            lastline = line;
            return false;
        }
    }

    if(entries.size()>=6 && entries[5].size()>0) {
	commit.userimagename = entries[5];
    } else commit.userimagename = commit.username;

    std::vector<std::string> displayData;

    //Extra fields for display on hover.
    if(entries.size()>=7 ) {
	displayData = split(entries[6], '|');
    }

    bool has_colour = false;
    vec3 colour;

    if(entries.size()>=5 && entries[4].size()>0) {
        has_colour = true;
        colour = parseColour(entries[4]);
    }

    if(has_colour) {
        commit.addFile(entries[3], action, colour, commit.username, commit.userimagename, displayData);
    } else {
        commit.addFile(entries[3], action, commit.username, commit.userimagename, displayData);
    }

    return true;
}
Beispiel #21
0
int main()
{	
	char* line;
	line = getNextLine();
	Hashtable table = tableCreate();
	char* author;
	author = findAuthor(line);
	tableInsert(table, author, line);
	free(author);
	printf("%s\n",line);
	
	char* line2;
	while(line2 = getNextLine())
	{
		if(strcmp(line,line2) == 0)		//if line2 = prev line..print ibid
		{
			printf("%s\n","ibid.");
		}
		else
		{
			author = findAuthor(line2);
			char* authorLine;
			authorLine = (char*)tableSearch(table, author);
			if(authorLine != NULL && !strcmp(authorLine, line2))
			{
				printf("%s%s\n","op. cit. ",author);
			}
			else
			{
				tableInsert(table, author, line2);
				printf("%s\n",line2);
			}
			free(author);
		}
		free(line);
		line = strdup(line2);
		free(line2);
	}
	free(line);
	tableDestroy(table);
	return 0;
}
bool ProgressiveColumnFileReader::getNextLine(std::vector<std::string>& Values)
{
  std::string TmpStr;

  if (getNextLine(TmpStr))
  {
    Values = openfluid::tools::splitString(TmpStr,m_ColSeparators,false);
    return true;
  }
  return false;
}
Beispiel #23
0
STATIC char *loadFieldPart(LINEBUF *data, char *field)
{
   while (field != NULL) {
      while (isspace(*field))
         field++;
      if (*field != 0)
         break;
      field = (data->fullLineRead ? NULL : getNextLine(data));
   }
   return field;
}
bool readObjVertices(
    FileHandle &fptr,
    VertContainer* verts,
    hduBoundBox3Df* vertBox
    )
{
    char line[STRING_LENGTH];

    while (getNextLine(fptr,line))
    {
        if (strlen(line) > STRING_LENGTH-2)
        {
            throw MsgIDError("readOBJvertices maximum single line length exceeded.");
        }
        
        char identifier[STRING_LENGTH];
        if (sscanf(line,"%s",identifier) != 1)
        {
            continue;
        }
        // All vertex info must be in the form 
        // "v <x> <y> <z>", e.g. "v 1.2 2.1 5.56".
        if (stringis_noCase(identifier,"v"))
        {
            float x,y,z;
            if (sscanf(line,"%*[^ ]%f %f %f",&x,&y,&z) != 3)
            {
                throw MsgIDError("readOBJvertices bad vertex count");
            }
            Vertex v(x,y,z);
            verts->push_back(v);
            vertBox->Union(v);
        }

        // Ignore the following identifiers, since we don't parse
        // those in V1.  These are here just for future reference as
        // place holders.
        if (stringis_noCase(identifier,"vt"))
        {
            float u,v;
            if (sscanf(line,"%*[^ ]%f %f",&u,&v) != 2)
            {
                throw MsgIDError("readOBJvertices bad texture vertex count");
            }
            // textures.push_back(hduVector3Df(u,v,0));
        }
        if (stringis_noCase(identifier,"vn"))
        {
            ;
        }
    }

    return TRUE;
}    
Beispiel #25
0
bool DBHandler::fillInfoVector()
{
	dbInfo pushMe;
	bool ret = false;
	for (int i = 0; i < 9; ++i)
		getNextLine();
	while (getNextLine() == true)
	{
		std::string tmp = getInfoAtPos(1);
		if (tmp.size()==1)
			continue;
		pushMe.offset = stoul(tmp);
		tmp = getInfoAtPos(3);
		pushMe.dataSize = stoul(tmp);
		tmp = getInfoAtPos(4);
		pushMe.hash = tmp.substr(2);
		tmp = getInfoAtPos(5);
		pushMe.dataChecksum = tmp.substr(2);
		tmp = getInfoAtPos(6);
		pushMe.headerChecksum = tmp.substr(2);
		pushMe.md5Sum = "DEFAULT";
		pushMe.absoluteFileName = outputPath +"0x"+ pushMe.hash;
		pushMe.foundInEDB=false;
		dbVec.push_back(pushMe);
		if (pushMe.dataSize > 0)
		{
			ret = true;
		}
	}
	for (size_t i = 0; i < dbVec.size(); ++i)
	{
		if (dbVec.at(i).dataSize>0)
		{
			std::string fileN = outputPath;
			fileN += "/0x";
			fileN += dbVec.at(i).hash;
			hashHandler.insert(fileN, &dbVec.at(i));
		}
	}
	return ret;
}
void handleArray(string line){

	if(contains(line, "<callArray>")){
		if (contains(getNextLine(), "<identifier>")) {
			string id = getCurrLine();
			
			handleExpression(getNextLine());//looks inside [...]
			handleIdentifier(id);//pushes array name on stack
			writeArithmetic("+");//offset array
			//writePop("pointer", 1); //set point to correct place in memory
//			writePush("that", 0); //place array[offset] on stack
			while ( !contains(getCurrLine(), "</callArray>")) {
				incFilePtr();
			}
		}else{
			error("expected to get array name <identifier> at this point");
		}
	}else{
		error("expected callArray");
	}
}
Beispiel #27
0
int movie(char *command, const char *frameFile)
{
   int failed = TRUE;
   double step;
   LINEBUF frameData[1];
   register int j;
   static const char noDataMsg[] = "/** Data file does not define any fields **/";

   if (*command == 'R' || *command == 'D' || *command == 'I') {
      loadData(infile);
      if (npnts < 1) return TRUE;

      step = (qmax - qmin) / (double) (npnts - 1);
      for (j = 0; j < npnts; j++)
         xtemp[j] = (double) j * step + qmin;

      if (extend(xtemp, npnts, lambda, lamdel, thedel) == NULL)
         return TRUE;
   }
   if (openBuf(frameFile, "r", frameData, FBUFFLEN) == NULL)
      noFile(frameFile);
   else {
      int frames;
      long headerOffset;

      frames = countData(frameData);
      headerOffset = locateHeader(frameData);
      if (headerOffset == -1)
         puts(noDataMsg);
      else {
         int numFields;

         setNextLine(frameData, headerOffset);
         getNextLine(frameData);
         numFields = loadFields(frameData, frameData->buffer+1);
         if (numFields == 0)
            puts(noDataMsg);
         else if (numFields > 0) {
            FILE *gnuPipe;

            genva(fields, 1, fitlist);
            gnuPipe = popen("gnuplot", "w");
            if (gnuPipe != NULL) {
               failed = runMovie(npnts, frames, numFields, frameData, gnuPipe, command);
               pclose(gnuPipe);
            }
         }
      }
      closeBuf(frameData, 0);
   }
   return failed;
}
Beispiel #28
0
//
// Ignoring comments the next line must be an activityId
//
int
passThruCfg::getActId()
{
    string n, v, tmp;

    getNextLine(&n,&v);
    tmp = "activityId";
    if (n != tmp) {
        printf("*Error* expected 'activityId' got %s\n",n.c_str());
        exit(1);
    }
    return atoi(v.c_str());
}
Beispiel #29
0
bool ShaderLoader::load()
{
    std::string line;

    // check '#version' header
    if (!getNextLine(line)) {
        return false;
    }
    m_source << line << std::endl;
    if (false == regex_match(line, regex("[ \t]*#version.*"))) {
        LOG::put(LOG::error, LOG::opengl) << m_file[0] << ":0 :: Missing #version ...";
        return false;
    }

    addDefines();

    while (getNextLine(line)) {
        if (regex_search(line, regex("^[ \t]*#[ \t]*include[ \t]+.*"))) {
            smatch m;
            bool res;
            res = regex_search(line, m, regex("^[ \t]*#[ \t]*include[ \t]+([\"<])(.*)([\">])[ \t]*$"));
            if (!res) {
                LOG::put(LOG::error, LOG::opengl) << m_file.back() << ":" << m_line.top() - 1
                                                  << " :: ill-formed include-statement";
                return false;
            } else {
                path incFile(m_path.top());
                incFile /= m[2].str();
                addFile(incFile);
            }
        } else {
            m_source << line << std::endl;
        }
    }

    return true;
}
Beispiel #30
0
//
// Read the next command from the configuration file.
// Validate the parameters assoicated with the command.
// Update the val in the paramsTable.
//
int
passThruCfg::getNxtCmd()
{


    // Read the next command, its activity ID and
    // parameters.  Validate the parameters and
    // save the associated values
    string pName, pVal;
    int idx;


    if (!nxtCmd) {
        thisCmd = getCmd();
        thisActId = getActId();

    } else if (nxtCmd == -1) {
        // nothing left to read in the file.
        printf("Finished reading '%s' \n",fName.c_str());
        return 0;
    } else {
        thisCmd = nxtCmd;
        thisActId = nxtActId;
        nxtCmd = nxtActId = 0;
    }
    while (!nxtCmd) {
        getNextLine(&pName,&pVal);


        // The file contains no more data. Return the
        // previously read cmd and activity
        if (configFile.eof()) {
            nxtCmd = -1;
            continue;
        }


        if (pName == "Command") {
            nxtCmd = atoi(pVal.c_str());
            nxtActId = getActId();
           break;
        }

        idx = getIdx(pName,thisCmd);
        paramsTable[idx].val = pVal;

    }
    return (thisCmd);
}