src/cLogBuffer.cpp
// write a character to the current buffer
write a character to the current buffer
write a character to the current buffer
size_t cLogBuffer::write(uint8_t c) {
  char *buf = &_buffer[_n_buffer][0];
  if( c=='\"' ){
    if( _buffer_len<LOGBUFFER_MAX_LEN-4 ){
      buf[_buffer_len++] = '\\';
      buf[_buffer_len++] = '\"';
      return 1;
    }
    else
      return 0;
  }
  else{
    if( c=='\r' ){
      if( _buffer_len>LOGBUFFER_MAX_LEN-3 )
        _buffer_len = LOGBUFFER_MAX_LEN-3;
      strcpy( buf + _buffer_len, "\\n" );   
      next();
      return 1;
    }
    else if( c=='\n' ){
      return 0;
    }
    else{
      if( _buffer_len<LOGBUFFER_MAX_LEN-3 ){
        buf[_buffer_len++] = c;
        return 1;
      }
      else
        return 0;
    }
  }
}
size_t cLogBuffer :: write ( uint8_t c ) { char * buf = & _buffer [ _n_buffer ] [ 0 ] ; if ( c == ' \" ' ) { if ( _buffer_len < LOGBUFFER_MAX_LEN - 4 ) { buf [ _buffer_len ++ ] = ' \\ ' ; buf [ _buffer_len ++ ] = ' \" ' ; return 1 ; } else return 0 ; } else { if ( c == ' \r ' ) { if ( _buffer_len > LOGBUFFER_MAX_LEN - 3 ) _buffer_len = LOGBUFFER_MAX_LEN - 3 ; strcpy ( buf + _buffer_len , " \\ " ) ; next ( ) ; return 1 ; } else if ( c == ' \n ' ) { return 0 ; } else { if ( _buffer_len < LOGBUFFER_MAX_LEN - 3 ) { buf [ _buffer_len ++ ] = c ; return 1 ; } else return 0 ; } } }
write a character to the current buffer
write a character to the current buffer
// escape quotes // end message and go next if '\r' // end message with newline // do nothing if '\n'