switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / Termlib / Telnet.cci
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief Telnet inline non-template implementation */
30
31 //#include "Telnet.ih"
32
33 // Custom includes
34
35 #define prefix_ inline
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::term::BaseTelnetProtocol::OptInfo
40
41 prefix_ senf::term::BaseTelnetProtocol::OptInfo::OptInfo()
42     : local (false), option (0u), wantState (DISABLED), optionState (NONE), enabled (false)
43 {}
44
45 prefix_ senf::term::BaseTelnetProtocol::OptInfo::OptInfo(bool l, option_type o)
46     : local (l), option (o), wantState (DISABLED), optionState (NONE), enabled (false)
47 {}
48
49 //-/////////////////////////////////////////////////////////////////////////////////////////////////
50 // senf::term::BaseTelnetProtocol::TelnetHandler
51
52 prefix_ senf::term::BaseTelnetProtocol::TelnetHandler::~TelnetHandler()
53 {}
54
55 prefix_ std::string const & senf::term::telnethandler::TerminalType::terminalType()
56     const
57 {
58     return type_;
59 }
60
61 //-/////////////////////////////////////////////////////////////////////////////////////////////////
62 // senf::term::telnethandler::NAWS
63
64 prefix_ unsigned senf::term::telnethandler::NAWS::width()
65     const
66 {
67     return width_;
68 }
69
70 prefix_ unsigned senf::term::telnethandler::NAWS::height()
71     const
72 {
73     return height_;
74 }
75
76 //-/////////////////////////////////////////////////////////////////////////////////////////////////
77 // senf::term::BaseTelnetProtocol
78
79 prefix_ senf::term::BaseTelnetProtocol::~BaseTelnetProtocol()
80 {}
81
82 prefix_ senf::term::BaseTelnetProtocol::Handle senf::term::BaseTelnetProtocol::handle()
83 {
84     return handle_;
85 }
86
87 prefix_ void senf::term::BaseTelnetProtocol::incrementRequestCounter()
88 {
89     ++ pendingRequests_;
90     timeout_.timeout(scheduler::eventTime() + requestTimeout_);
91 }
92
93 prefix_ bool senf::term::BaseTelnetProtocol::requestsPending()
94 {
95     return pendingRequests_ > 0u;
96 }
97
98 prefix_ void senf::term::BaseTelnetProtocol::sendNOP()
99 {
100     transmit(CMD_IAC);
101     transmit(CMD_NOP);
102 }
103
104 prefix_ void senf::term::BaseTelnetProtocol::sendBRK()
105 {
106     transmit(CMD_IAC);
107     transmit(CMD_BRK);
108 }
109
110 prefix_ void senf::term::BaseTelnetProtocol::sendIP()
111 {
112     transmit(CMD_IAC);
113     transmit(CMD_IP);
114 }
115
116 prefix_ void senf::term::BaseTelnetProtocol::sendAO()
117 {
118     transmit(CMD_IAC);
119     transmit(CMD_AO);
120 }
121
122 prefix_ void senf::term::BaseTelnetProtocol::sendAYT()
123 {
124     transmit(CMD_IAC);
125     transmit(CMD_AYT);
126 }
127
128 prefix_ void senf::term::BaseTelnetProtocol::sendEC()
129 {
130     transmit(CMD_IAC);
131     transmit(CMD_EC);
132 }
133
134 prefix_ void senf::term::BaseTelnetProtocol::sendEL()
135 {
136     transmit(CMD_IAC);
137     transmit(CMD_EL);
138 }
139
140 prefix_ void senf::term::BaseTelnetProtocol::sendGA()
141 {
142     transmit(CMD_IAC);
143     transmit(CMD_GA);
144 }
145
146 prefix_ void senf::term::BaseTelnetProtocol::requestLocalOption(option_type option,
147                                                                            bool enabled)
148 {
149     request(getOption(true, option), enabled);
150 }
151
152 prefix_ void senf::term::BaseTelnetProtocol::acceptLocalOption(option_type option,
153                                                                           bool enabled)
154 {
155     getOption(true, option).wantState = OptInfo::ACCEPTED;
156 }
157
158 prefix_ void senf::term::BaseTelnetProtocol::requestPeerOption(option_type option,
159                                                                           bool enabled)
160 {
161     request(getOption(false, option), enabled);
162 }
163
164 prefix_ void senf::term::BaseTelnetProtocol::acceptPeerOption(option_type option,
165                                                                          bool enabled)
166 {
167     getOption(false, option).wantState = OptInfo::ACCEPTED;
168 }
169
170 prefix_ bool senf::term::BaseTelnetProtocol::localOption(option_type option)
171 {
172     return getOption(true, option).enabled;
173 }
174
175 prefix_ bool senf::term::BaseTelnetProtocol::peerOption(option_type option)
176 {
177     return getOption(false, option).enabled;
178 }
179
180 prefix_ void senf::term::BaseTelnetProtocol::emit(char c)
181 {
182     v_charReceived(c);
183 }
184
185 //-/////////////////////////////////////////////////////////////////////////////////////////////////
186 #undef prefix_
187
188 \f
189 // Local Variables:
190 // mode: c++
191 // fill-column: 100
192 // comment-column: 40
193 // c-file-style: "senf"
194 // indent-tabs-mode: nil
195 // ispell-local-dictionary: "american"
196 // compile-command: "scons -u test"
197 // End: