ReactOS 0.4.16-dev-251-ga17b6e9
tnetwork.cpp
Go to the documentation of this file.
1
2//Telnet Win32 : an ANSI telnet client.
3//Copyright (C) 1998-2000 Paul Brannan
4//Copyright (C) 1998 I.Ioannou
5//Copyright (C) 1997 Brad Johnson
6//
7//This program is free software; you can redistribute it and/or
8//modify it under the terms of the GNU General Public License
9//as published by the Free Software Foundation; either version 2
10//of the License, or (at your option) any later version.
11//
12//This program is distributed in the hope that it will be useful,
13//but WITHOUT ANY WARRANTY; without even the implied warranty of
14//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15//GNU General Public License for more details.
16//
17//You should have received a copy of the GNU General Public License
18//along with this program; if not, write to the Free Software
19//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20//
21//I.Ioannou
22//roryt@hol.gr
23//
25
27//
28// Module: tnetwork.cpp
29//
30// Contents: telnet network module
31//
32// Product: telnet
33//
34// Revisions: March 18, 1999 Paul Brannan (pbranna@clemson.edu)
35//
37
38#include "precomp.h"
39
41 socket = s;
44}
45
47 pipeIn = pIn;
48 pipeOut = pOut;
51}
52
53int TNetwork::WriteString(const char *str, const int length) {
54 switch(net_type) {
55 case TN_NETSOCKET:
56 return send(socket, str, length, 0);
57 case TN_NETPIPE:
58 {
59 DWORD dwWritten;
60 if(!WriteFile(pipeOut, str, length, &dwWritten, (LPOVERLAPPED)NULL)) return -1;
61 return dwWritten;
62 }
63 }
64 return 0;
65}
66
67int TNetwork::ReadString (char *str, const int length) {
68 switch(net_type) {
69 case TN_NETSOCKET:
70 return recv(socket, str, length, 0);
71 case TN_NETPIPE:
72 {
73 DWORD dwRead;
74 if(!ReadFile(pipeIn, str, length, &dwRead, (LPOVERLAPPED)NULL)) return -1;
75 return dwRead;
76 }
77 }
78 return 0;
79}
80
82 if(!naws_func) return;
83 char buf[100];
84 int len = (*naws_func)(buf, width, height);
86}
87
89 local_address = new char[strlen(buf) + 1];
91}
92
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int ReadString(char *str, const int length)
Definition: tnetwork.cpp:67
void SetSocket(SOCKET s)
Definition: tnetwork.cpp:40
void SetLocalAddress(char *buf)
Definition: tnetwork.cpp:88
NetworkType net_type
Definition: tnetwork.h:17
HANDLE pipeIn
Definition: tnetwork.h:18
HANDLE pipeOut
Definition: tnetwork.h:18
BOOL local_echo
Definition: tnetwork.h:15
Naws_func_t naws_func
Definition: tnetwork.h:19
int WriteString(const char *str, const int length)
Definition: tnetwork.cpp:53
SOCKET socket
Definition: tnetwork.h:14
void SetPipe(HANDLE pIn, HANDLE pOut)
Definition: tnetwork.cpp:46
void do_naws(int width, int height)
Definition: tnetwork.cpp:81
BOOL line_mode
Definition: tnetwork.h:16
char * local_address
Definition: tnetwork.h:20
#define NULL
Definition: types.h:112
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum GLsizei len
Definition: glext.h:6722
const WCHAR * str
@ TN_NETSOCKET
Definition: tnetwork.h:8
@ TN_NETPIPE
Definition: tnetwork.h:8
UINT_PTR SOCKET
Definition: winsock.h:47