Пример #1
0
int main (int argc, char *argv[])
{
   char *p, *q;
   int isCode = 0;         /* If isCode == TRUE, we are in a region of
                              valid code; otherwise not. */

   Init (argc, argv);

   while (NULL != fgets (Line, MaxChar, fin)) { /* Not EOF and no error */
      if (isCode) {
         isCode = ProcessLine (Line);
      } else {
         /* search for "\def\code" and drop that line: it is not valid code
            but the definition of the TEX command \code */
         if (strstr (Line, "\\def\\code"))
            ;                             
         else if ((p = strstr (Line, "\\code"))) {
            /* search for "\code". If "\code" is found on a line with a %
               before it, then it is a TEX comment and we do not consider
               it as starting a region of valid code; */
            *p = '\0';
            q = strchr (Line, '%');
            if (NULL == q)
               /* otherwise, it is valid code: process rest of line */
               isCode = ProcessLine (p + L1);
         }
      }
   }

   fprintf (fout, "\n");
   fclose (fout);
   fclose (fin);
   return 0;
}
Пример #2
0
size_t nwxProcess::ProcessIO(size_t nLimit)
{
  size_t nRtn = 0;
  bool bInputClosed = false;
  if(!m_bPaused)
  {
    if(!IsInputOpened())
    {
      if(m_sBuffer.Len())
      {
        m_sBuffer += "\n";
        ProcessLine(m_sBuffer.utf8_str(),m_sBuffer.Len(),false);
        m_sBuffer.Empty();
      }
      bInputClosed = true;
    }
    else 
    {
      while(IsInputAvailable() && (nRtn < nLimit))
      {
        nRtn += ProcessIO(GetInputStream(),m_sBuffer,false);
      }
    }
    if(!IsErrorOpened())
    {
      if(m_sBufferError.Len())
      {
        m_sBufferError += "\n";
        ProcessLine(m_sBufferError.utf8_str(),m_sBufferError.Len(),true);
        m_sBufferError.Empty();
      }
      if(bInputClosed && m_bRunning)
      {
    	  m_bRunning = false;
    	      // we are sometimes not notified when process ends
#ifndef __WXMSW__
    	  // need to clean up zombie because wx sometimes
    	  // fails to do this on the macintosh
    	  int nStatLoc;
    	  pid_t nPID;
    	  nPID = waitpid((pid_t)m_nPID,&nStatLoc,0);
    	  OnTerminate(m_nPID,nStatLoc);
#endif
      }
    }
    else 
    {
      while(IsErrorAvailable() && (nRtn < nLimit))
      {
        nRtn += ProcessIO(GetErrorStream(),m_sBufferError,true);
      }
    }
  }
  return nRtn;
}
/************************************************************************
Function  : Main

Returns   : zero on successful execution
               3 on an error condition

The main routine allocates memory for the input and output buffers.
Characters are then read from the input buffer building the line buffer
that will be sent to the filter processor.  Lines are read and filtered
until the end of input is reached.
************************************************************************/
int main(void)
{
   char c;
   int i, Type;
   unsigned long core;

   setmode(1,O_BINARY);               /* set standard out to binary mode */
   NoLines = FALSE;                   /* No lines have been read yet */
   core = farcoreleft();              /* get available memory */
   if (core > 64000U)                 /* limit buffers to total of 64000 */
      BufSize = 64000U;               /* bytes */
   else
      BufSize = (unsigned)core;
   if ((InBuffer = malloc(BufSize)) == NULL) /* allocate buffer space */
      exit(3);                        /* abort if error occured */
   CurInPtr = InBuffer;               /* split buffer */
   BufSize = BufSize/2;               /* between input and output buffers */
   OutBuffer = InBuffer + BufSize;
   CurOutPtr = OutBuffer;
   LinePtr = Line;                    /* set line buffer pointer */
   CurBufLen = 0;                     /* and reset buffer size to zero */
   Put(PipeId,PipeIdLen);             /* Identify process to message window */
   while ((c = NextChar()) != 0)      /* read characters */
   {
      if ((c == 13) || (c == 10))     /* build line until new line is seen */
      {
         *LinePtr = 0;
         ProcessLine(Line);           /* then filter the line */
         LinePtr = Line;
      }
      /* characters are added to line only up to 132 characters */
      else if ((FP_OFF(LinePtr) - FP_OFF(&Line)) < 132)
      {
         *LinePtr = c;
         LinePtr++;
      }
   }
   *LinePtr = 0;
   ProcessLine(Line);                  /* filter last line */
   if (NoLines)                        /* if no lines */
   {
      Type = MsgNewLine;               /* send something to the */
      i = 1;                           /* message window */
      Put((char *)&Type,1);
      Put((char *)&i,2);
      Put((char *)&i,2);
      Put(" ",2);
   }
   EndMark = MsgEoFile;                /* indicate end of input to */
   Put(&EndMark,1);                    /* message window */
   flushOut((unsigned)(CurOutPtr-OutBuffer));  /* flush out remaining buffer */

   return  0;                          /* everything went ok */
}
Пример #4
0
static int ProcessLine (char *line)
{
   /* Process a line (or part of a line) of valid code. If at the end of the
      line, we are still in a region of valid code, then return 1; otherwise,
      return 0. */

   char *p, *rest;
   int code;

   p = strstr (line, "\\endcode");   /* search for "\endcode" */
   if (p) {                          /* if found */
      *p = '\0';                     /* code ends here */
      rest = p + L2;                 /* step over "\endcode" */
      p = strstr (rest, "\\code");   /* search for "\code" */
      if (p) {
         p += L1;                    /* step over "\code" */
         rest = calloc (MaxChar, sizeof (char));
         strncpy (rest, p, MaxChar);
         ProcessCode (line);
         code = ProcessLine (rest);
         free (rest);
         return code;
      } else {
         ProcessCode (line);
         return 0;
      }
   } else {
      ProcessCode (line);
      return 1;
   }
}
Пример #5
0
/** This function is called when we receive data from a remote
 * server.
 */
void TreeSocket::OnDataReady()
{
	Utils->Creator->loopCall = true;
	std::string line;
	while (GetNextLine(line))
	{
		std::string::size_type rline = line.find('\r');
		if (rline != std::string::npos)
			line = line.substr(0,rline);
		if (line.find('\0') != std::string::npos)
		{
			SendError("Read null character from socket");
			break;
		}

		try
		{
			ProcessLine(line);
		}
		catch (CoreException& ex)
		{
			ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Error while processing: " + line);
			ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, ex.GetReason());
			SendError(ex.GetReason() + " - check the log file for details");
		}

		if (!getError().empty())
			break;
	}
	if (LinkState != CONNECTED && recvq.length() > 4096)
		SendError("RecvQ overrun (line too long)");
	Utils->Creator->loopCall = false;
}
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
BOOL CPreprocessor::ProcessNormalLine(CPreprocessorTokenParser* pcParser)
{
	CPPLine*	pcLine;
	BOOL		bResult;

	if (pcParser->HasTokens())
	{
		pcLine = CPPLine::Construct(mpcStack->Add(sizeof(CPPLine)));
		pcLine->Init(pcParser->Line(), pcParser->Column());
		bResult = ProcessLine(&pcLine->mcTokens, pcParser, FALSE, 0);
		if (bResult)
		{
			if (pcLine->TokenLength() > 0)
			{
				mpcPost->Add((CPPToken**)&pcLine);
			}
			return TRUE;
		}
		return FALSE;
	}
	else
	{
		return TRUE;
	}
}
Пример #7
0
void *GPSLoop(void *some_void_ptr)
{
	unsigned char Line[100];
	int id, Length;
	struct i2c_info bb;
	struct TGPS *GPS;

	GPS = (struct TGPS *)some_void_ptr;
	
	Length = 0;

    while (1)
    {
        int i;
		unsigned char Character;

		printf ("SDA/SCL = %d/%d\n", Config.SDA, Config.SCL);
		
		if (OpenI2C(&bb, 0x42, Config.SDA, Config.SCL, 10, 100))		// struct, i2c address, SDA, SCL, us clock delay, timeout ms
		{
			printf("Failed to open I2C\n");
			exit(1);
		}
	
		SetFlightMode(&bb);

        while (!bb.Failed)
        {
            Character = I2CGetc(&bb);

			if (Character == 0xFF)
			{
				delayMilliseconds (100);
			}
            else if (Character == '$')
			{
				Line[0] = Character;
				Length = 1;
			}
            else if (Length > 90)
			{
				Length = 0;
            }
            else if ((Length > 0) && (Character != '\r'))
            {
               	Line[Length++] = Character;
               	if (Character == '\n')
               	{
               		Line[Length] = '\0';
					// puts(Line);
               		ProcessLine(&bb, GPS, Line, Length);
					delayMilliseconds (100);
               		Length = 0;
               	}
            }
		}
		
		ResetI2C(&bb);
	}
}
Пример #8
0
void ProcessTelemetryMessage(int Channel, char *Message)
{
	if (strlen(Message+1) < 150)
	{
		int i;
		unsigned char *startmessage, *endmessage;

		ChannelPrintf(Channel, 4, 1, "Telemetry %d bytes       ", strlen(Message+1));

		endmessage = Message;
								
		startmessage = endmessage;
		endmessage = strchr(startmessage, '\n');

		if (endmessage != NULL)
		{
			*endmessage = '\0';

			LogTelemetryPacket(startmessage);
			
			UploadTelemetryPacket(startmessage);

			ProcessLine(Channel, startmessage);
		
			LogMessage("Ch %d: %s\n", Channel, startmessage);
		}
		
		// DoPositionCalcs(Channel);
		
		Config.LoRaDevices[Channel].TelemetryCount++;								
	}
}
/***********************************************************************
Function  : main

Returns   : zero for successful execution
	    3    if an error is encountered

The main routine allocates buffers for the input and output buffer.
Characters are then read from the input buffer building the line buffer
that will be sent to the filter processor.  Lines are read and filtered
until the end of input is reached.
***********************************************************************/
int main( void )
{
   char c;
   unsigned long core;

   setmode(1,O_BINARY);               /* set output stream to binary mode */
   core = farcoreleft();
   if (core > 64000U)
      BufSize = 64000U;
   else BufSize = (unsigned)core;     /* get available memory */
                                      /* stay under 64K */
   if ((CurInPtr = malloc(BufSize)) == NULL) /* allocate buffer space */
      exit(3);
#if 0
   processor = NULL;                  /* set current processor to none */
#endif

   InBuffer = CurInPtr;               /* input buffer is first half of space */
   BufSize = BufSize/2;               /* output buffer is 2nd half */
   OutBuffer = InBuffer + BufSize;
   CurOutPtr = OutBuffer;             /* set buffer pointers */
   LinePtr = Line;
   CurBufLen = 0;
   Put(PipeId,PipeIdLen);             /* send ID string to message window */
   while ((c = NextChar()) != 0)      /* read characters */
   {
      if ((c == 13) || (c == 10))     /* build until line end */
      {
         *LinePtr = 0;
         ProcessLine(Line);           /* filter the line */
         LinePtr = Line;
      }
      /* characters are added to buffer up to 132 characters max */
      else if ((FP_OFF(LinePtr) - FP_OFF(&Line)) < 132)
      {
         *LinePtr = c;                /* add to line buffer */
         LinePtr++;
      }
   }
   *LinePtr = 0;
   ProcessLine(Line);                 /* filter last line */
   EndMark = MsgEoFile;
   Put(&EndMark,1);                   /* indicate end of input to
                                         the message window */
   flushOut((unsigned)(CurOutPtr-OutBuffer));     /* flush the buffer */
   return 0;                          /* return OK */
}
Пример #10
0
	//==================================================================================
	// returns true if entire file was parsed, false if it aborted for some reason
	//==================================================================================
	int32  InPlaceParser::Parse(InPlaceParserInterface *callback)
	{
		int32 ret = 0;
		ph_assert( callback );
		if ( mData )
		{
			int32 lineno = 0;

			char *foo   = mData;
			char *begin = foo;

			while ( *foo )
			{
				if ( isLineFeed(*foo) )
				{
					++lineno;
					*foo = 0;
					if ( *begin ) // if there is any data to parse at all...
					{
						bool snarfed = callback->preParseLine(lineno,begin);
						if ( !snarfed )
						{
							int32 v = ProcessLine(lineno,begin,callback);
							if ( v )
								ret = v;
						}
					}

					++foo;
					if ( *foo == 10 )
						++foo; // skip line feed, if it is in the carraige-return line-feed format...
					begin = foo;
				}
				else
				{
					++foo;
				}
			}

			lineno++; // lasst line.

			int32 v = ProcessLine(lineno,begin,callback);
			if ( v )
				ret = v;
		}
		return ret;
	}
Пример #11
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
void SeparationsMatrixFacility::init(xmlNodePtr cur)
{
  FacilityModel::init(cur);

  /// move XML pointer to current model
  cur = XMLinput->get_xpath_element(cur,"model/SeparationsMatrixFacility");
  /// initialize any SeparationsMatrixFacility-specific datamembers here

  // all facilities require commodities - possibly many
  string new_commod;

  // Hack Force!!
  // Forcing Separations Matrix to know ahead of time the number of streams to be processed.
  int nodeForce_ = 1;

  // get incommodities
  xmlNodeSetPtr nodes = XMLinput->get_xpath_elements(cur,"incommodity");

  for (int i=0;i<nodes->nodeNr;i++)
  {
    xmlNodePtr commod = nodes->nodeTab[i];

    new_commod = XMLinput->get_xpath_content(cur,"incommodity");
    in_commod_.push_back(new_commod);
  }

  // get inventory size
  inventory_size_ = strtod(XMLinput->get_xpath_content(cur,"inventorysize"), NULL);

  // get capacity
  capacity_ = strtod(XMLinput->get_xpath_content(cur,"capacity"), NULL);

  // get stream
  nodes = XMLinput->get_xpath_elements(cur,"stream");
  // See nodeForce Hack Above

  for (int i=0;i<nodeForce_;i++)
  {

    xmlNodePtr stream = nodes->nodeTab[i];

    string new_commod = XMLinput->get_xpath_content(stream,"outcommodity");
    out_commod_.push_back(new_commod);

    int stream_Z = strtol(XMLinput->get_xpath_content(stream,"z"), NULL, 10);
    double stream_eff = strtod(XMLinput->get_xpath_content(stream,"eff"), NULL);
    stream_set_.insert(make_pair(new_commod, make_pair(stream_Z, stream_eff)));
    LOG(LEV_DEBUG2) << "Name = " << new_commod;
    LOG(LEV_DEBUG2) << "Z = " << stream_Z;
    LOG(LEV_DEBUG2) << "Eff = " << stream_eff;
  };

  inventory_ = deque<pair<string,Material*> >();
  stocks_ = deque<pair<string,Material*> >();
  ordersWaiting_ = deque<msg_ptr>();
  ordersExecuting_ = ProcessLine();

  outstMF_ = 0;
}
Пример #12
0
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
void CPreprocessor::ExpandDefined(CPPAbstractHolder* pcHolder, CDefine* pcDefine, BOOL bAllowDefined, int iDepth)
{
	CPreprocessorTokenParser	cParser;

	cParser.Init(&pcDefine->mcReplacement);
	ProcessLine(&pcHolder->mcTokens, &cParser, bAllowDefined, iDepth);
	cParser.Kill();
}
Пример #13
0
void HeartGeometryInformation<SPACE_DIM>::GetNodesAtSurface(
        const std::string& surfaceFile,
        std::vector<unsigned>& rSurfaceNodes,
        bool indexFromZero) const
{
    // Open the file defining the surface
    std::ifstream file_stream;
    unsigned offset=0;
    if (indexFromZero == false)
    {
        offset=1;
    }

    file_stream.open(surfaceFile.c_str());
    if (!file_stream.is_open())
    {
        EXCEPTION("Wrong surface definition file name " + surfaceFile);
    }

    // Temporary storage for the nodes, helps discarding repeated values
    std::set<unsigned> surface_original_node_index_set;

    // Loop over all the triangles and add node indexes to the set
    std::string line;
    getline(file_stream, line);
    do
    {
        ProcessLine(line, surface_original_node_index_set, offset);

        getline(file_stream, line);
    }
    while(!file_stream.eof());
    file_stream.close();

    // Make vector big enough
    rSurfaceNodes.reserve(surface_original_node_index_set.size());

    if (mpMesh->rGetNodePermutation().empty())
    {
        // Copy the node indexes from the set to the vector as they are
        for(std::set<unsigned>::iterator node_index_it=surface_original_node_index_set.begin();
            node_index_it != surface_original_node_index_set.end();
            node_index_it++)
        {
            rSurfaceNodes.push_back(*node_index_it);
        }
    }
    else
    {
        // Copy the original node indices from the set to the vector applying the permutation
        for(std::set<unsigned>::iterator node_index_it=surface_original_node_index_set.begin();
            node_index_it != surface_original_node_index_set.end();
            node_index_it++)
        {
            rSurfaceNodes.push_back(mpMesh->rGetNodePermutation()[*node_index_it]);
        }
    }
}
Пример #14
0
void Commands::LoadCommands()
{
	std::ifstream infile(COMMANDS_LOCATION);
	std::string line;
	while (std::getline(infile, line))
	{
		ProcessLine(line);
	}
}
Пример #15
0
nsresult nsEudoraAddress::ImportAddresses( PRUint32 *pBytes, PRBool *pAbort,
                                          const PRUnichar *pName, nsIFile *pSrc,
                                          nsIAddrDatabase *pDb, nsString& errors)
{
  // Open the source file for reading, read each line and process it!

  EmptyAliases();
  nsCOMPtr<nsIInputStream> inputStream;
  nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), pSrc);
  if (NS_FAILED(rv)) {
    IMPORT_LOG0( "*** Error opening address file for reading\n");
    return rv;
  }

  PRUint32 bytesLeft = 0;

  rv = inputStream->Available(&bytesLeft);
  if (NS_FAILED(rv)) {
    IMPORT_LOG0( "*** Error checking address file for eof\n");
    inputStream->Close();
    return rv;
  }

  nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(inputStream, &rv));
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool more = PR_TRUE;

  while ((!(*pAbort) && more && NS_SUCCEEDED( rv)))
  {
    nsCString line;
    rv = lineStream->ReadLine(line, &more);
    if (NS_SUCCEEDED( rv))
    {
      PRInt32  len = line.Length();
      ProcessLine( line.get(), len, errors);
      if (pBytes)
        *pBytes += (len / 2);
    }
  }
  rv = inputStream->Close();

  if (more)
  {
    IMPORT_LOG0( "*** Error reading the address book, didn't reach the end\n");
    return( NS_ERROR_FAILURE);
  }
  // Run through the alias array and make address book entries...
#ifdef IMPORT_DEBUG
  DumpAliasArray( m_alias);
#endif

  BuildABCards( pBytes, pDb);

  return pDb->Commit(nsAddrDBCommitType::kLargeCommit);
  }
Пример #16
0
long FindMatch(char * Input, char * Match, char * Delimiter, long Field, 
		long * CurrentLine, long * CurrentOffset) {

	long Result = 0; 

	// Process each line until we find a match
	while (!(Result = ProcessLine (Input, Match, Delimiter, Field, CurrentLine, CurrentOffset))

	return Result;
}
bool nsImportScanFileLines::ScanBuffer(bool *pDone)
{
  // m_pos, m_bytesInBuf, m_eof, m_pBuf are relevant

  uint32_t    pos = m_pos;
  uint32_t    max = m_bytesInBuf;
  uint8_t *    pChar = m_pBuf + pos;
  uint32_t    startPos;

  while (pos < max) {
    if (m_needEol) {
      // Find the next eol...
      while ((pos < max) && (*pChar != ImportCharSet::cCRChar) && (*pChar != ImportCharSet::cLinefeedChar)) {
        pos++;
        pChar++;
      }
      m_pos = pos;
      if (pos < max)
        m_needEol = false;
      if (pos == max) // need more buffer for an end of line
        break;
    }
    // Skip past any eol characters
    while ((pos < max) && ((*pChar == ImportCharSet::cCRChar) || (*pChar == ImportCharSet::cLinefeedChar))) {
      pos++;
      pChar++;
    }
    m_pos = pos;
    if (pos == max)
      break;
    // Make sure we can find either the eof or the
    // next end of line
    startPos = pos;
    while ((pos < max) && (*pChar != ImportCharSet::cCRChar) && (*pChar != ImportCharSet::cLinefeedChar)) {
      pos++;
      pChar++;
    }

    // Is line too big for our buffer?
    if ((pos == max) && !m_eof) {
      if (!m_pos) { // line too big for our buffer
        m_pos = pos;
        m_needEol = true;
      }
      break;
    }

    if (!ProcessLine(m_pBuf + startPos, pos - startPos, pDone)) {
      return false;
    }
    m_pos = pos;
  }

  return true;
}
Пример #18
0
nsresult nsEudoraAddress::ImportAddresses( PRUint32 *pBytes, PRBool *pAbort, const PRUnichar *pName, nsIFileSpec *pSrc, nsIAddrDatabase *pDb, nsString& errors)
{
	// Open the source file for reading, read each line and process it!
	
	EmptyAliases();
	
	nsresult rv = pSrc->OpenStreamForReading();
	if (NS_FAILED( rv)) {
		IMPORT_LOG0( "*** Error opening address file for reading\n");
		return( rv);
	}
	
	char *pLine = new char[kEudoraAddressBufferSz];
	PRBool	wasTruncated;
	PRBool	eof = PR_FALSE;
	rv = pSrc->Eof( &eof);
	if (NS_FAILED( rv)) {
		IMPORT_LOG0( "*** Error checking address file for eof\n");
		pSrc->CloseStream();
		return( rv);
	}
	
	while (!(*pAbort) && !eof && NS_SUCCEEDED( rv)) {
		wasTruncated = PR_FALSE;
		rv = pSrc->ReadLine( &pLine, kEudoraAddressBufferSz, &wasTruncated);
		if (wasTruncated)
			pLine[kEudoraAddressBufferSz - 1] = 0;
		if (NS_SUCCEEDED( rv)) {
			PRInt32	len = strlen( pLine);
			ProcessLine( pLine, len, errors);
			rv = pSrc->Eof( &eof);
			if (pBytes)
				*pBytes += (len / 2);
		}
	}
	
	rv = pSrc->CloseStream();
	
	delete [] pLine;

	if (!eof) {
		IMPORT_LOG0( "*** Error reading the address book, didn't reach the end\n");
		return( NS_ERROR_FAILURE);
	}
	
	// Run through the alias array and make address book entries...
	#ifdef IMPORT_DEBUG
	DumpAliasArray( m_alias);
	#endif
	
	BuildABCards( pBytes, pDb);
	
  rv = pDb->Commit(nsAddrDBCommitType::kLargeCommit);
	return rv;
}
Пример #19
0
int  InPlaceParser::Parse(InPlaceParserInterface *callback) // returns true if entire file was parsed, false if it aborted for some reason
{
	assert( callback );
	if ( !mData ) return 0;

	int ret = 0;

	int lineno = 0;

	char *foo   = mData;
	char *begin = foo;


	while ( *foo )
	{
		if ( *foo == 10 || *foo == 13 )
		{
			lineno++;
			*foo = 0;

			if ( *begin ) // if there is any data to parse at all...
			{
				int v = ProcessLine(lineno,begin,callback);
				if ( v ) ret = v;
			}

			foo++;
			if ( *foo == 10 ) foo++; // skip line feed, if it is in the carraige-return line-feed format...
			begin = foo;
		}
		else
		{
			foo++;
		}
	}

	lineno++; // lasst line.

	int v = ProcessLine(lineno,begin,callback);
	if ( v ) ret = v;
	return ret;
}
Пример #20
0
 void OnStdout(const char* buffer, int length) {
     for (int i = 0; i < length; i++) {
         char c = buffer[i];
         if (c == '\n') {
             ProcessLine(line_);
             line_.clear();
         } else {
             line_.append(1, c);
         }
     }
 }
Пример #21
0
static void BaseParseReturn(char *start)
{
  /* cancel the timeout. */
  devCancelTimeout(base_device.dev);

  /* parse the characters in the buffer and update state */

  if (strcmp(start, "") != 0)
    ProcessLine (start);

}
Пример #22
0
void IRCServer::readIRCServer() {

    QString message = QString::fromUtf8(this->readAll());
    QString currentChan = tab->tabText(tab->currentIndex());

    QStringList list = message.split("\r\n");

    foreach(QString msg, list) {
        if (msg.trimmed() != "") {
            ProcessLine(msg, currentChan);
        }
    }
}
Пример #23
0
	void SettingsFile::LoadSettings(SettingsFile::StringVector& lines, const std::string& file_name)
	{
		// The line number.
		unsigned int line_number = 1;
		// Process each line...
		StringVector::const_iterator end = lines.end();
		for(StringVector::const_iterator i = lines.begin(); i != end; ++i)
		{
			// Process this line.
			ProcessLine(*i, file_name, line_number);
			// Move to the next line.
			++line_number;
		}
	}
Пример #24
0
BOOL CReg::LoadRegFromMem(LPBYTE buf, DWORD size, BOOL bMerge)
{_STTEX();
	DWORD i = 0;

	// Lose old record
	if ( !bMerge ) Destroy();

	// Sanity check
	if ( buf == NULL || size == 0 ) return FALSE;

	// No key currently
	m_pCurKey = NULL;

	i = SkipWhiteSpace( buf, size, i );

	// Read in first line tag
	if ( i < size && buf[ i ] > ' ' && buf[ i ] <= '~' && buf[ i ] != '[' )
	{
		// I really don't know what to do with this tag
		i = NextLine( buf, size, i );

	} // end if

	// Process file
	while ( i < size && buf[ i ] != 0 )
	{
		// Skip white space
		i = SkipWhiteSpace( buf, size, i );

		if ( i < size && buf[ i ] == ';' ) i = NextLine( buf, size, i );

		// Process this line if not a comment
		else if ( i < size && buf[ i ] != 0 )
		{
			DWORD skip = ProcessLine( &buf[ i ], size - i );

			// Did we read a valid line
			if ( skip != 0 ) i += skip;

			// Just skip invalid line
			else i = NextLine( buf, size, i );

		} // end if

	} // end while

	return TRUE;
}
Пример #25
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
void SeparationsMatrixFacility::copy(SeparationsMatrixFacility* src)
{
  FacilityModel::copy(src);

  in_commod_ = src->in_commod_;
  out_commod_ = src->out_commod_;
  inventory_size_ = src->inventory_size_;
  capacity_ = src->capacity_;

  inventory_ = deque<InSep>();
  stocks_ = deque<OutSep>();
  ordersWaiting_ = deque<msg_ptr>();
  ordersExecuting_ = ProcessLine();

  outstMF_ = 0;
}
Пример #26
0
int LoadText_Direct(const char* path) {
	std::vector<double> items;
	int nrows = 0;
	FILE* fd = fopen(path, "r");
	while (!feof(fd)) {
		size_t len = 0;
		const char* line = fgetln(fd, &len);
		if (line == nullptr) {
			break;
		}
		items.clear();
		ProcessLine(items, line, len);
		++nrows;
	}
	fclose(fd);
	return nrows;
}
Пример #27
0
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
SCTokenBlock CPreprocessor::ProcessHashElif(CPreprocessorTokenParser* pcParser, CPPConditional* pcCond, SCTokenBlock iLine)
{
	BOOL			bEvaluated;
	CPPTokenHolder	cTokenHolder;
	CChars			sz;

	cTokenHolder.Init(32);
	ProcessLine(&cTokenHolder, pcParser, TRUE, 0);
	sz.Init(128);
	cTokenHolder.Append(&sz);
	bEvaluated = Evaluate(sz.Text());;
	mcConditionalStack.SwapForElseIf(bEvaluated);
	sz.Kill();
	cTokenHolder.Kill();

	return Condition(pcCond, iLine);
}
Пример #28
0
    int Done(int unused_) {
        // Process remaining line, if any.
        ProcessLine(line_);

        // Warn about invalid lines, if any.
        if (!invalid_lines_.empty()) {
            fprintf(stderr,
                    "WARNING: bugreportz generated %zu line(s) with unknown commands, "
                    "device might not support zipped bugreports:\n",
                    invalid_lines_.size());
            for (const auto& line : invalid_lines_) {
                fprintf(stderr, "\t%s\n", line.c_str());
            }
            fprintf(stderr,
                    "If the zipped bugreport was not generated, try 'adb bugreport' instead.\n");
        }

        // Pull the generated bug report.
        if (status_ == 0) {
            if (src_file_.empty()) {
                fprintf(stderr, "bugreportz did not return a '%s' or '%s' line\n", BUGZ_OK_PREFIX,
                        BUGZ_FAIL_PREFIX);
                return -1;
            }
            std::string destination;
            if (dest_dir_.empty()) {
                destination = dest_file_;
            } else {
                destination = android::base::StringPrintf("%s%c%s", dest_dir_.c_str(),
                                                          OS_PATH_SEPARATOR, dest_file_.c_str());
            }
            std::vector<const char*> srcs{src_file_.c_str()};
            SetLineMessage("pulling");
            status_ =
                br_->DoSyncPull(srcs, destination.c_str(), true, line_message_.c_str()) ? 0 : 1;
            if (status_ != 0) {
                fprintf(stderr,
                        "Bug report finished but could not be copied to '%s'.\n"
                        "Try to run 'adb pull %s <directory>'\n"
                        "to copy it to a directory that can be written.\n",
                        destination.c_str(), src_file_.c_str());
            }
        }
        return status_;
    }
Пример #29
0
void GetPosition(int fd, struct TGPS *GPS)
{
    int Count, GotGGA, GotRMC;
    char Buffer[200]; 
    char Character;

    printf("NMEA...\r\n");

	GotGGA = 0;
	GotRMC = 0;
    Count = -1;

    while (!GotGGA || !GotRMC)
    {
        read(fd, &Character, 1);
		// printf ("%c", Character);

        if (Character == '$')
        {
            Count = 0;
        }
        else if (Count > 180)
        {
            Count = -1;
        }
        
        if ((Count >= 0) && (Count <= 180))
        {
            if (Character != '\r')
            {
                Buffer[Count++] = Character;
            }

            if (Character == '\n')
            {
				Buffer[Count] = '\0';
				if (GPSChecksumOK(Buffer, Count))
                {
					ProcessLine(GPS, Buffer, &GotGGA, &GotRMC);
				}
                Count = -1;
            }
        }
    }
}
Пример #30
0
        void Process(const Utils::StringList &data, int level, const QString &location)
        {
            if (m_debug) Out(QString("List (level %1)").arg(level));

            if (level > CMaxIncludeDepth) 
            {
                IncludeErr(QString("Include depth more than %1.").arg(CMaxIncludeDepth), 
                           ""/*fileName*/);
            }

            Location fileLine(location);
            bool inComment = false;  // state var for multiline comments 
            for (int i = 0; i < data.size(); ++i)
            {
                fileLine.Line = i + 1; // starts from 1
                ProcessLine(data.at(i), level, fileLine, inComment);
            }
        }