Martin Ettl <ettl DOT martin AT gmx DOT de>: Fix various resource and memory leaks
[reactos.git] / reactos / base / applications / network / telnet / src / tnetwork.h
1 // This is a simple class to handle socket connections
2 // (Paul Brannan 6/15/98)
3
4 #ifndef __TNETWORK_H
5 #define __TNETWORK_H
6
7 #include <windows.h>
8
9 enum NetworkType {TN_NETSOCKET, TN_NETPIPE};
10
11 typedef int(*Naws_func_t)(char *, int, int);
12
13 class TNetwork {
14 private:
15 SOCKET socket;
16 BOOL local_echo; // Paul Brannan 8/25/98
17 BOOL line_mode; // Paul Brannan 12/31/98
18 NetworkType net_type; // Paul Brannan 3/18/99
19 HANDLE pipeIn, pipeOut; // Paul Brannan 3/18/99
20 Naws_func_t naws_func;
21 char *local_address;
22
23 public:
24 TNetwork(SOCKET s = 0): socket(s), local_echo(1), line_mode(1),
25 net_type(TN_NETSOCKET), naws_func((Naws_func_t)NULL),
26 local_address((char *)NULL) {}
27 ~TNetwork() {if(local_address) delete[] local_address;}
28
29 void SetSocket(SOCKET s);
30 SOCKET GetSocket() {return socket;}
31 void SetPipe(HANDLE pIn, HANDLE pOut);
32 void SetNawsFunc(Naws_func_t func) {naws_func = func;}
33 void SetLocalAddress(char *buf);
34 const char* GetLocalAddress() {return local_address;}
35
36 NetworkType get_net_type() {return net_type;}
37
38 int WriteString(const char *str, const int length);
39 int ReadString (char *str, const int length);
40
41 BOOL get_local_echo() {return local_echo;}
42 void set_local_echo(BOOL b) {local_echo = b;}
43
44 BOOL get_line_mode() {return line_mode;}
45 void set_line_mode(BOOL b) {line_mode = b;}
46
47 void do_naws(int width, int height);
48 };
49
50 #endif