Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentnetwork.cpp
Go to the documentation of this file.
00001 00002 //Telnet Win32 : an ANSI telnet client. 00003 //Copyright (C) 1998-2000 Paul Brannan 00004 //Copyright (C) 1998 I.Ioannou 00005 //Copyright (C) 1997 Brad Johnson 00006 // 00007 //This program is free software; you can redistribute it and/or 00008 //modify it under the terms of the GNU General Public License 00009 //as published by the Free Software Foundation; either version 2 00010 //of the License, or (at your option) any later version. 00011 // 00012 //This program is distributed in the hope that it will be useful, 00013 //but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 //GNU General Public License for more details. 00016 // 00017 //You should have received a copy of the GNU General Public License 00018 //along with this program; if not, write to the Free Software 00019 //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 // 00021 //I.Ioannou 00022 //roryt@hol.gr 00023 // 00025 00027 // 00028 // Module: tnetwork.cpp 00029 // 00030 // Contents: telnet network module 00031 // 00032 // Product: telnet 00033 // 00034 // Revisions: March 18, 1999 Paul Brannan (pbranna@clemson.edu) 00035 // 00037 00038 #include "precomp.h" 00039 00040 void TNetwork::SetSocket(SOCKET s) { 00041 socket = s; 00042 net_type = TN_NETSOCKET; 00043 local_echo = line_mode = 1; 00044 } 00045 00046 void TNetwork::SetPipe(HANDLE pIn, HANDLE pOut) { 00047 pipeIn = pIn; 00048 pipeOut = pOut; 00049 net_type = TN_NETPIPE; 00050 local_echo = line_mode = 0; 00051 } 00052 00053 int TNetwork::WriteString(const char *str, const int length) { 00054 switch(net_type) { 00055 case TN_NETSOCKET: 00056 return send(socket, str, length, 0); 00057 case TN_NETPIPE: 00058 { 00059 DWORD dwWritten; 00060 if(!WriteFile(pipeOut, str, length, &dwWritten, (LPOVERLAPPED)NULL)) return -1; 00061 return dwWritten; 00062 } 00063 } 00064 return 0; 00065 } 00066 00067 int TNetwork::ReadString (char *str, const int length) { 00068 switch(net_type) { 00069 case TN_NETSOCKET: 00070 return recv(socket, str, length, 0); 00071 case TN_NETPIPE: 00072 { 00073 DWORD dwRead; 00074 if(!ReadFile(pipeIn, str, length, &dwRead, (LPOVERLAPPED)NULL)) return -1; 00075 return dwRead; 00076 } 00077 } 00078 return 0; 00079 } 00080 00081 void TNetwork::do_naws(int width, int height) { 00082 if(!naws_func) return; 00083 char buf[100]; 00084 int len = (*naws_func)(buf, width, height); 00085 WriteString(buf, len); 00086 } 00087 00088 void TNetwork::SetLocalAddress(char *buf) { 00089 local_address = new char[strlen(buf) + 1]; 00090 strcpy(local_address, buf); 00091 } 00092 Generated on Fri May 25 2012 04:15:34 for ReactOS by
1.7.6.1
|