Fixes for real this time for new telnet client
[reactos.git] / rosapps / net / 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 // Mingw32 doesn't use winsock.h (Paul Brannan 9/4/98)
10 #ifdef __MINGW32__
11 #ifdef __CYGWIN__
12 #include <winsock.h>
13 #else
14 // #include <Windows32/sockets.h> Removed for ReactOS
15 #endif
16 #else
17 #include <winsock.h>
18 #endif
19
20 // ReactOS uses winsock2.h (Steven Edwards 12-31-01)
21 #ifdef __REACTOS__
22 #include <winsock2.h>
23 #endif
24
25 enum NetworkType {TN_NETSOCKET, TN_NETPIPE};
26
27 typedef int(*Naws_func_t)(char *, int, int);
28
29 class TNetwork {
30 private:
31 SOCKET socket;
32 BOOL local_echo; // Paul Brannan 8/25/98
33 BOOL line_mode; // Paul Brannan 12/31/98
34 NetworkType net_type; // Paul Brannan 3/18/99
35 HANDLE pipeIn, pipeOut; // Paul Brannan 3/18/99
36 Naws_func_t naws_func;
37 char *local_address;
38
39 public:
40 TNetwork(SOCKET s = 0): socket(s), local_echo(1), line_mode(1),
41 net_type(TN_NETSOCKET), naws_func((Naws_func_t)NULL),
42 local_address((char *)NULL) {}
43 ~TNetwork() {if(local_address) delete local_address;}
44
45 void SetSocket(SOCKET s);
46 SOCKET GetSocket() {return socket;}
47 void SetPipe(HANDLE pIn, HANDLE pOut);
48 void SetNawsFunc(Naws_func_t func) {naws_func = func;}
49 void SetLocalAddress(char *buf);
50 const char* GetLocalAddress() {return local_address;}
51
52 NetworkType get_net_type() {return net_type;}
53
54 int WriteString(const char *str, const int length);
55 int ReadString (char *str, const int length);
56
57 BOOL get_local_echo() {return local_echo;}
58 void set_local_echo(BOOL b) {local_echo = b;}
59
60 BOOL get_line_mode() {return line_mode;}
61 void set_line_mode(BOOL b) {line_mode = b;}
62
63 void do_naws(int width, int height);
64 };
65
66 #endif