-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTelnet.cpp
More file actions
35 lines (31 loc) · 701 Bytes
/
Telnet.cpp
File metadata and controls
35 lines (31 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "Telnet.h"
namespace SocketLib
{
using std::string;
void Telnet::Translate(Connection<Telnet>& p_conn, char* p_buffer, int p_size)
{
for (int i = 0; i < p_size; ++i)
{
char c = p_buffer[i];
if (c >= 32 && c != 127 && m_buffersize < BUFFERSIZE)
{
m_buffer[m_buffersize] = c;
m_buffersize++;
}
else if(c == 8 && m_buffersize > 0)
{
m_buffersize--;
}
else if (c == '\n' || c == '\r')
{
if (m_buffersize > 0)
p_conn.Handler()->Handle(string(m_buffer, m_buffersize));
m_buffersize = 0;
}
}
}
void Telnet::SendString(Connection<Telnet>& p_conn, std::string p_string)
{
p_conn.BufferData(p_string.data(), p_string.size());
}
}