67ad169137df4fcac0fd0e66dff2ce54fdd55440
[senf.git] / senf / Utils / Termlib / Telnet.cci
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Telnet inline non-template implementation */
25
26 //#include "Telnet.ih"
27
28 // Custom includes
29
30 #define prefix_ inline
31 ///////////////////////////////cci.p///////////////////////////////////////
32
33 ///////////////////////////////////////////////////////////////////////////
34 // senf::term::BaseTelnetProtocol::OptInfo
35
36 prefix_ senf::term::BaseTelnetProtocol::OptInfo::OptInfo()
37     : local (false), option (0u), wantState (DISABLED), optionState (NONE), enabled (false)
38 {}
39
40 prefix_ senf::term::BaseTelnetProtocol::OptInfo::OptInfo(bool l, option_type o)
41     : local (l), option (o), wantState (DISABLED), optionState (NONE), enabled (false)
42 {}
43
44 ///////////////////////////////////////////////////////////////////////////
45 // senf::term::BaseTelnetProtocol::TelnetHandler
46
47 prefix_ senf::term::BaseTelnetProtocol::TelnetHandler::~TelnetHandler()
48 {}
49
50 prefix_ std::string const & senf::term::telnethandler::TerminalType::terminalType()
51     const
52 {
53     return type_;
54 }
55
56 ///////////////////////////////////////////////////////////////////////////
57 // senf::term::telnethandler::NAWS
58
59 prefix_ unsigned senf::term::telnethandler::NAWS::width()
60     const
61 {
62     return width_;
63 }
64
65 prefix_ unsigned senf::term::telnethandler::NAWS::height()
66     const
67 {
68     return height_;
69 }
70
71 ///////////////////////////////////////////////////////////////////////////
72 // senf::term::BaseTelnetProtocol
73
74 prefix_ senf::term::BaseTelnetProtocol::~BaseTelnetProtocol()
75 {}
76
77 prefix_ senf::term::BaseTelnetProtocol::Handle senf::term::BaseTelnetProtocol::handle()
78 {
79     return handle_;
80 }
81
82 prefix_ void senf::term::BaseTelnetProtocol::incrementRequestCounter()
83 {
84     ++ pendingRequests_;
85     timeout_.timeout(senf::scheduler::eventTime() + requestTimeout_);
86 }
87
88 prefix_ bool senf::term::BaseTelnetProtocol::requestsPending()
89 {
90     return pendingRequests_ > 0u;
91 }
92
93 prefix_ void senf::term::BaseTelnetProtocol::sendNOP()
94 {
95     transmit(CMD_IAC);
96     transmit(CMD_NOP);
97 }
98
99 prefix_ void senf::term::BaseTelnetProtocol::sendBRK()
100 {
101     transmit(CMD_IAC);
102     transmit(CMD_BRK);
103 }
104
105 prefix_ void senf::term::BaseTelnetProtocol::sendIP()
106 {
107     transmit(CMD_IAC);
108     transmit(CMD_IP);
109 }
110
111 prefix_ void senf::term::BaseTelnetProtocol::sendAO()
112 {
113     transmit(CMD_IAC);
114     transmit(CMD_AO);
115 }
116
117 prefix_ void senf::term::BaseTelnetProtocol::sendAYT()
118 {
119     transmit(CMD_IAC);
120     transmit(CMD_AYT);
121 }
122
123 prefix_ void senf::term::BaseTelnetProtocol::sendEC()
124 {
125     transmit(CMD_IAC);
126     transmit(CMD_EC);
127 }
128
129 prefix_ void senf::term::BaseTelnetProtocol::sendEL()
130 {
131     transmit(CMD_IAC);
132     transmit(CMD_EL);
133 }
134
135 prefix_ void senf::term::BaseTelnetProtocol::sendGA()
136 {
137     transmit(CMD_IAC);
138     transmit(CMD_GA);
139 }
140
141 prefix_ void senf::term::BaseTelnetProtocol::requestLocalOption(option_type option,
142                                                                            bool enabled)
143 {
144     request(getOption(true, option), enabled);
145 }
146
147 prefix_ void senf::term::BaseTelnetProtocol::acceptLocalOption(option_type option,
148                                                                           bool enabled)
149 {
150     getOption(true, option).wantState = OptInfo::ACCEPTED;
151 }
152
153 prefix_ void senf::term::BaseTelnetProtocol::requestPeerOption(option_type option,
154                                                                           bool enabled)
155 {
156     request(getOption(false, option), enabled);
157 }
158
159 prefix_ void senf::term::BaseTelnetProtocol::acceptPeerOption(option_type option,
160                                                                          bool enabled)
161 {
162     getOption(false, option).wantState = OptInfo::ACCEPTED;
163 }
164
165 prefix_ bool senf::term::BaseTelnetProtocol::localOption(option_type option)
166 {
167     return getOption(true, option).enabled;
168 }
169
170 prefix_ bool senf::term::BaseTelnetProtocol::peerOption(option_type option)
171 {
172     return getOption(false, option).enabled;
173 }
174
175 prefix_ void senf::term::BaseTelnetProtocol::emit(char c)
176 {
177     v_charReceived(c);
178 }
179
180 ///////////////////////////////cci.e///////////////////////////////////////
181 #undef prefix_
182
183 \f
184 // Local Variables:
185 // mode: c++
186 // fill-column: 100
187 // comment-column: 40
188 // c-file-style: "senf"
189 // indent-tabs-mode: nil
190 // ispell-local-dictionary: "american"
191 // compile-command: "scons -u test"
192 // End: