0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SshOutputCollector.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2014 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
27 
28 #include <Common/Compat.h>
29 
30 #include "SshOutputCollector.h"
31 
32 using namespace Hypertable;
33 using namespace std;
34 
35 
37  m_index = m_next_index;
38  m_offset = m_next_offset;
39  m_line.clear();
40  while (m_next_index < m_buffers.size()) {
41  const char *base = m_buffers[m_next_index].base + m_next_offset;
42  const char *end = m_buffers[m_next_index].ptr;
43  const char *ptr = base;
44  while (ptr < end && *ptr != '\n')
45  ptr++;
46  if (ptr > base)
47  m_line.append(base, ptr-base);
48  if (ptr < end) {
49  ptr++; // skip newline
50  if (ptr == end) {
51  m_next_index++;
52  m_next_offset = 0;
53  }
54  else
55  m_next_offset = ptr - m_buffers[m_next_index].base;
56  return;
57  }
58  m_next_index++;
59  m_next_offset = 0;
60  }
61 }
void increment()
Increment to next output line.
STL namespace.
Compatibility Macros for C/C++.
Declarations for SshOutputCollector.
Hypertable definitions