File: fireflierIO.h

package info (click to toggle)
fireflier 1.1.6-3etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 3,348 kB
  • ctags: 1,167
  • sloc: sh: 9,023; cpp: 8,370; makefile: 437; ansic: 300
file content (87 lines) | stat: -rw-r--r-- 1,323 bytes parent folder | download | duplicates (3)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef _FIREFLIERIO_H_
#define _FIREFLIERIO_H_

#include <openssl/ssl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
//#include <map>
#include <glibmm/ustring.h>
#include "CRefPtr.h"

using Glib::ustring;


class CffIO
{
	static SSL* m_ssl;
	static SSL_CTX* m_ctx;
	static SSL_METHOD* m_meth;
	static in_addr_t m_nHostIP;
	static guint16 m_nPort;

public:
	enum CommErr
	{
		// ssl-errors are 0 and below, so use value above 0
		COMMERR_CONN_NOTVALID = 1, 
		COMMERR_NO_MEMORY, 
	};
	
	class CffIOError
	{
	private:
		int m_nError;
		//static std::map <int, ustring> m_mapErr2Str;
	
	public:
		CffIOError(int nError)
			: m_nError(nError)
		{
		}
		
		int getErrorNum() const
		{
			return m_nError;
		}
		
		
	};

	
	typedef CRefPtr <CffIO::CffIOError> pCffIOError;

	class CNetworkThread;

public:
	static CNetworkThread networkThread;
	
public:
	static void setSocket(const char* szIP, guint16 nPort)
	{
		in_addr addr;
		inet_aton(szIP, &addr);
		m_nHostIP = addr.s_addr;
		m_nPort = nPort;
	}
	
	static bool connect();
	
	static void end();

	operator SSL&()
	{
		return *m_ssl;
	}
};
	

#include "CNetworkThread.h"
#include "CCO_All.h"
extern CffIO ffIO;

SSL& operator <<(SSL& ssl, const CCO_SendBase& co);
SSL& operator >>(SSL& ssl, CCO_RetrieveBase& co);

#endif