00001 #ifndef _STR_TelnetChunker_H_ // -*-c++-*- 00002 00003 /* 00004 * Copyright 1991-2002 Eric M. Hopper <hopper@omnifarious.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published 00008 * by the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #ifdef __GNUG__ 00022 # pragma interface 00023 #endif 00024 00025 /* $Header: /home/hopper/src/cvs/C++/StrMod/StrMod/TelnetChunker.h,v 1.7 2002/08/29 00:58:05 hopper Exp $ */ 00026 00027 // For a log, see ../ChangeLog 00028 00029 #include <StrMod/STR_ClassIdent.h> 00030 #include <StrMod/StreamProcessor.h> 00031 00032 #define _STR_TelnetChunker_H_ 00033 00034 namespace strmod { 00035 namespace strmod { 00036 00037 /** \class TelnetChunker TelnetChunker.h StrMod/TelnetChunker.h 00038 * This class parses out a stream of data into seperate telnet protocol 00039 * elements. 00040 * 00041 * The protocol elements are either raw data, or a StrChunk derived from 00042 * TelnetParser::TelnetData. For more information on what the protocol 00043 * elements mean, search for the relevant IETF RFCs, or visit 00044 * http://www.omnifarious.org/~hopper/technical/telnet-rfc.html 00045 */ 00046 class TelnetChunker : public StreamProcessor 00047 { 00048 public: 00049 class TelnetData; 00050 class SingleChar; 00051 class Suboption; 00052 class OptionNegotiation; 00053 00054 static const STR_ClassIdent identifier; 00055 //! The maximum size an unfinished suboption can reach before it's aborted. 00056 static const unsigned int MAX_SUBOPTSIZE = (64U * 1024U); 00057 00058 /** Construct a TelnetChunker. 00059 * Not much to tell one when you make it. The state diagram has a quite 00060 * well defined starting point. 00061 */ 00062 TelnetChunker(); 00063 /** Destruct a TelnetChunker. 00064 * No pointers mean no explicit memory management here. 00065 */ 00066 virtual ~TelnetChunker(); 00067 00068 inline virtual int AreYouA(const lcore::ClassIdent &cid) const; 00069 00070 protected: 00071 class Builder; 00072 00073 virtual const lcore::ClassIdent *i_GetIdent() const { return(&identifier); } 00074 00075 virtual void processIncoming(); 00076 00077 private: 00078 class DataFunctor; 00079 class Internals; 00080 friend class Internals; 00081 Internals &data_; 00082 }; 00083 00084 //-----------------------------inline functions-------------------------------- 00085 00086 inline int TelnetChunker::AreYouA(const lcore::ClassIdent &cid) const 00087 { 00088 return((identifier == cid) || StreamProcessor::AreYouA(cid)); 00089 } 00090 00091 }; // namespace strmod 00092 }; // namespace strmod 00093 00094 #endif
1.3-rc1