fgms 0.11.8
The
FlightGear MultiPlayer Server
project
cli_client.hxx
Go to the documentation of this file.
1 //
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License as
4 // published by the Free Software Foundation; either version 2 of the
5 // License, or (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful, but
8 // WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // General Public License for more details.
11 //
12 // You should have received a copy of the GNU General Public License
13 // along with this program; if not, write to the Free Software
14 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U$
15 //
16 // Copyright (C) 2011 Oliver Schroeder
17 //
18 
19 #ifndef CLI_CLIENT_H
20 #define CLI_CLIENT_H
21 
22 #include <string>
23 #include <sstream>
24 #include <iomanip>
25 #include <plib/netSocket.h>
26 #ifndef _MSC_VER
27  #include <termios.h>
28 #endif
29 #include "common.hxx"
30 #include "filter.hxx"
31 
32 namespace LIBCLI
33 {
34 
35 class CLI;
36 
38 {
39 public:
40  int flags;
41  char* str;
42 };
43 
45 {
46 public:
47  int matched;
48  char* from;
49  char* to;
50 };
51 
52 class Client
53 {
54 public:
55  friend class CLI;
56  Client ( int fd );
57  ~Client ();
58  int wait_for_input ( int seconds ); // select()
59  int read_char ( unsigned char& c );
60  void put_char ( const char& c );
61 
62  template <class T> Client& operator << ( T v );
63  Client& operator << ( Client& (*f) (Client&) );
64 
65  friend Client& commit ( Client& );
66  friend Client& CRLF ( Client& );
67  friend Client& UNFILTERED ( Client& );
68  size_t lines_out;
71 protected:
72  char* join_words ( int argc, char** argv );
73  int match_filter_init ( int argc, char** argv, filter_t* filt );
74  int range_filter_init ( int argc, char** argv, filter_t* filt );
75  int count_filter_init ( int argc, char** argv, filter_t* filt );
76  int match_filter ( char* cmd, void* data );
77  int range_filter ( char* cmd, void* data );
78  int count_filter ( char* cmd, void* data );
81  std::ostringstream m_output;
82  #ifndef _MSC_VER
83  struct termios OldModes;
84  #endif
85 };
86 
87 //////////////////////////////////////////////////////////////////////
88 //
89 //////////////////////////////////////////////////////////////////////
90 template <class T>
92 {
93  m_output << v;
94  return *this;
95 } // operator << ( class T );
96 //////////////////////////////////////////////////////////////////////
97 
98 Client& commit ( Client& );
99 Client& CRLF ( Client& out );
100 Client& UNFILTERED ( Client& out );
101 
102 }; // namespace LIBCLI
103 
104 #endif
Socket type.
Definition: netSocket.h:125
friend Client & commit(Client &)
Definition: cli_client.cxx:430
Client & operator<<(T v)
Definition: cli_client.hxx:91
static char f[32]
Definition: crypt-win.c:225
PRINT_MODE m_print_mode
Definition: cli_client.hxx:79
Client & commit(Client &out)
Definition: cli_client.cxx:430
int read_char(unsigned char &c)
Definition: cli_client.cxx:160
int range_filter(char *cmd, void *data)
Definition: cli_client.cxx:369
netSocket * m_socket
Definition: cli_client.hxx:80
struct termios OldModes
Definition: cli_client.hxx:83
friend Client & UNFILTERED(Client &)
Definition: cli_client.cxx:485
int wait_for_input(int seconds)
Definition: cli_client.cxx:125
char * join_words(int argc, char **argv)
Definition: cli_client.cxx:210
int match_filter(char *cmd, void *data)
Definition: cli_client.cxx:335
filter_t * filters
Definition: cli_client.hxx:70
size_t max_screen_lines
Definition: cli_client.hxx:69
Client(int fd)
Definition: cli_client.cxx:54
size_t lines_out
Definition: cli_client.hxx:68
int range_filter_init(int argc, char **argv, filter_t *filt)
Definition: cli_client.cxx:269
Client & CRLF(Client &out)
Definition: cli_client.cxx:471
std::ostringstream m_output
Definition: cli_client.hxx:81
PRINT_MODE
Definition: common.hxx:62
Client & UNFILTERED(Client &out)
Definition: cli_client.cxx:485
void put_char(const char &c)
Definition: cli_client.cxx:178
int count_filter(char *cmd, void *data)
Definition: cli_client.cxx:401
netSocket is a thin C++ wrapper over bsd sockets to facilitate porting to other platforms. Part of PLIB - A Suite of Portable Game Libraries
int match_filter_init(int argc, char **argv, filter_t *filt)
Definition: cli_client.cxx:242
friend Client & CRLF(Client &)
Definition: cli_client.cxx:471
int count_filter_init(int argc, char **argv, filter_t *filt)
Definition: cli_client.cxx:312