]> git.mxchange.org Git - simgear.git/blob - simgear/io/sg_netChat.hxx
Add optional attribute condition to "copyProperties".
[simgear.git] / simgear / io / sg_netChat.hxx
1 /*
2     Copied from PLIB into SimGear
3
4      PLIB - A Suite of Portable Game Libraries
5      Copyright (C) 1998,2002  Steve Baker
6  
7      This library is free software; you can redistribute it and/or
8      modify it under the terms of the GNU Library General Public
9      License as published by the Free Software Foundation; either
10      version 2 of the License, or (at your option) any later version.
11  
12      This library 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 GNU
15      Library General Public License for more details.
16  
17      You should have received a copy of the GNU Library General Public
18      License along with this library; if not, write to the Free Software
19      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20  
21      For further information visit http://plib.sourceforge.net
22
23      $Id: netChat.h 1568 2002-09-02 06:05:49Z sjbaker $
24 */
25
26 /****
27 * NAME
28 *   netChat - network chat class
29 *
30 * DESCRIPTION
31 *   This class adds support for 'chat' style protocols -
32 *   where one side sends a 'command', and the other sends
33 *   a response (examples would be the common internet
34 *   protocols - smtp, nntp, ftp, etc..).
35 *
36 *   The handle_buffer_read() method looks at the input
37 *   stream for the current 'terminator' (usually '\r\n'
38 *   for single-line responses, '\r\n.\r\n' for multi-line
39 *   output), calling found_terminator() on its receipt.
40 *
41 * EXAMPLE
42 *   Say you build an nntp client using this class.
43 *   At the start of the connection, you'll have
44 *   terminator set to '\r\n', in order to process
45 *   the single-line greeting.  Just before issuing a
46 *   'LIST' command you'll set it to '\r\n.\r\n'.
47 *   The output of the LIST command will be accumulated
48 *   (using your own 'collect_incoming_data' method)
49 *   up to the terminator, and then control will be
50 *   returned to you - by calling your found_terminator()
51 *
52 * AUTHORS
53 *   Sam Rushing <rushing@nightmare.com> - original version for Medusa
54 *   Dave McClurg <dpm@efn.org> - modified for use in PLIB
55 *
56 * CREATION DATE
57 *   Dec-2000
58 *
59 ****/
60
61 #ifndef SG_NET_CHAT_H
62 #define SG_NET_CHAT_H
63
64 #include <simgear/io/sg_netBuffer.hxx>
65
66 namespace simgear
67 {
68
69 class NetChat : public NetBufferChannel
70 {
71   char* terminator;
72   
73   virtual void handleBufferRead (NetBuffer& buffer) ;
74
75 public:
76
77   NetChat () : terminator (0) {}
78
79   void setTerminator (const char* t);
80   const char* getTerminator (void);
81
82   bool push (const char* s);
83   
84   virtual void collectIncomingData      (const char* s, int n) {}
85   virtual void foundTerminator (void) {}
86 };
87
88 } // of namespace simgear
89
90 #endif // SG_NET_CHAT_H