Exemplo n.º 1
0
void Work(struct DTDesc *TheDTDesc)
{

    if(!TheDTDesc)
    {
        return;
    }

    memset(TheDTDesc->ReadBuffer, '\0', READBUFFERSIZE);

    while(fgets(TheDTDesc->ReadBuffer, READBUFFERSIZE, TheDTDesc->Input))
    {
        RemoveNewLine(TheDTDesc);

        if(!HandleLine(TheDTDesc))
        {
            break;
        }

        memset(TheDTDesc->ReadBuffer, '\0', READBUFFERSIZE);
    }

    WriteOutDTD(TheDTDesc);

}
Exemplo n.º 2
0
// If there's still some data (non CRLF terminated) flush it out
PRInt32 nsMsgLineBuffer::FlushLastLine()
{
  char *buf = m_buffer + m_bufferPos;
  PRInt32 length = m_bufferPos - 1;
  if (length > 0)
    return (m_handler) ? m_handler->HandleLine(buf, length) : HandleLine(buf, length);
  else
    return 0;
}
Exemplo n.º 3
0
PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
{
    /* Convert the line terminator to the native form.
     */

    char *buf = m_buffer;
    PRInt32 length = m_bufferPos;

    char* newline;
    
    PR_ASSERT(buf && length > 0);
    if (!buf || length <= 0) 
        return -1;
    newline = buf + length;
    
    PR_ASSERT(newline[-1] == '\r' || newline[-1] == '\n');
    if (newline[-1] != '\r' && newline[-1] != '\n')
        return -1;
    
    if (m_convertNewlinesP)
    {
#if (MSG_LINEBREAK_LEN == 1)
      if ((newline - buf) >= 2 &&
           newline[-2] == '\r' &&
           newline[-1] == '\n')
      {
        /* CRLF -> CR or LF */
        buf [length - 2] = MSG_LINEBREAK[0];
        length--;
      }
      else if (newline > buf + 1 &&
             newline[-1] != MSG_LINEBREAK[0])
      {
        /* CR -> LF or LF -> CR */
        buf [length - 1] = MSG_LINEBREAK[0];
      }
#else
      if (((newline - buf) >= 2 && newline[-2] != '\r') ||
               ((newline - buf) >= 1 && newline[-1] != '\n'))
      {
        /* LF -> CRLF or CR -> CRLF */
        length++;
        buf[length - 2] = MSG_LINEBREAK[0];
        buf[length - 1] = MSG_LINEBREAK[1];
      }
#endif
    }    
    return (m_handler) ? m_handler->HandleLine(buf, length) : HandleLine(buf, length);
}
Exemplo n.º 4
0
	void ConfManager::ReadConf(const string& confFile)
	{
		try{
			if(!fs::exists(confFile)){
				return;
			}
			ifstream inFile;
			inFile.open(confFile.c_str());
			while(!inFile.eof()){
				string line = "";
				getline(inFile, line);
				if(!HandleLine(line)){
					CfgError("Failed to handle corrupted file " << line);
				}
			}
			inFile.close();
		}catch(...){
			CfgError("Failed to parser conf file " << confFile);
		}
	}
Exemplo n.º 5
0
 void LineReader::OnLine(const char *d, const size_t l)
 {
   std::string line(d, l);
   HandleLine(line);
 }
Exemplo n.º 6
0
// Handles GET & POST Line B requests
void HandleLineB()
{
	return HandleLine(LINE_B);
}
Exemplo n.º 7
0
// Handles GET & POST Line A requests
void HandleLineA()
{
	return HandleLine(LINE_A);
}