-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsole.h
72 lines (66 loc) · 1.3 KB
/
Console.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#define PATH_MAX 255
#include <string>
#include <sys/socket.h> //oh god, vxworks, why
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <vxWorks.h>
#include <stdioLib.h>
#include <sockLib.h>
#include <inetLib.h>
#include <strLib.h>
#include <hostLib.h>
#include <ioLib.h>
#include <sstream>
namespace Spyder
{
class Packet
{
private:
std::string strData;
public:
Packet() : strData()
{
}
void AddData(const char* t)
{
unsigned int len = strlen(t);
strData += std::string((char*)(&len), sizeof(unsigned int));
strData += t;
}
void AddData(char *t)
{
AddData((const char*)t);
}
template<class T>
void AddData(T t)
{
strData += std::string((char*)(&t), sizeof(T));
}
void AddData(char *t, unsigned int length)
{
strData += std::string(t, length);
}
const std::string& GetData()
{
return strData;
}
};
class Console
{
public:
Console();
~Console();
static Console* GetSingleton();
bool Connect(const std::string &strIP, unsigned short usPort);
bool SendPacket(const std::string &strSubsystem, Packet &packet);
private:
int m_socket;
struct sockaddr_in m_serverAddr;
};
};