Commit 251cf4807e8694036baf009cd980ff616bb31127
1 parent
2c5467eb
Exists in
master
and in
3 other branches
Working in new lib3270 API.
Showing
5 changed files
with
92 additions
and
4 deletions
Show diff stats
src/include/lib3270++.h
... | ... | @@ -24,8 +24,6 @@ |
24 | 24 | * |
25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | - * licinio@bb.com.br (Licínio Luis Branco) | |
28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | 27 | * |
30 | 28 | */ |
31 | 29 | |
... | ... | @@ -34,6 +32,7 @@ |
34 | 32 | #define LIB3270_HPP_INCLUDED 1 |
35 | 33 | |
36 | 34 | #include <iostream> |
35 | + #include <cstdarg> | |
37 | 36 | #include <lib3270.h> |
38 | 37 | |
39 | 38 | #if defined(_WIN32) |
... | ... | @@ -136,6 +135,15 @@ |
136 | 135 | protected: |
137 | 136 | Session(); |
138 | 137 | |
138 | + /// @brief Write information to log file. | |
139 | + void info(const char *fmt, ...) const; | |
140 | + | |
141 | + /// @brief Write warning to log file. | |
142 | + void warning(const char *fmt, ...) const; | |
143 | + | |
144 | + /// @brief Write error to log file. | |
145 | + void error(const char *fmt, ...) const; | |
146 | + | |
139 | 147 | public: |
140 | 148 | |
141 | 149 | /// @brief Create a tn3270 session. |
... | ... | @@ -145,7 +153,7 @@ |
145 | 153 | |
146 | 154 | // Connect/disconnect |
147 | 155 | virtual void connect(const char *url) = 0; |
148 | - virtual void disconnect(); | |
156 | + virtual void disconnect() = 0; | |
149 | 157 | |
150 | 158 | // Wait for session state. |
151 | 159 | virtual void waitForReady(time_t timeout = 5) throw() = 0; |
... | ... | @@ -205,6 +213,15 @@ |
205 | 213 | /// @brief Writes characters to the associated output sequence from the put area. |
206 | 214 | int overflow(int c) override; |
207 | 215 | |
216 | + /// @brief Write information to log file. | |
217 | + void info(const char *fmt, ...) const; | |
218 | + | |
219 | + /// @brief Write warning to log file. | |
220 | + void warning(const char *fmt, ...) const; | |
221 | + | |
222 | + /// @brief Write error to log file. | |
223 | + void error(const char *fmt, ...) const; | |
224 | + | |
208 | 225 | public: |
209 | 226 | Host(const char *id = nullptr, const char *url = nullptr); |
210 | 227 | ~Host(); | ... | ... |
src/lib3270++/lib3270++.cbp
... | ... | @@ -41,11 +41,13 @@ |
41 | 41 | </Linker> |
42 | 42 | <Unit filename="../include/lib3270++.h" /> |
43 | 43 | <Unit filename="../include/lib3270.h" /> |
44 | + <Unit filename="../include/lib3270/session.h" /> | |
44 | 45 | <Unit filename="abstract.cc" /> |
45 | 46 | <Unit filename="host.cc" /> |
46 | 47 | <Unit filename="local.cc" /> |
47 | 48 | <Unit filename="private.h" /> |
48 | 49 | <Unit filename="session.cc" /> |
50 | + <Unit filename="testprogram/testprogram.cc" /> | |
49 | 51 | <Extensions> |
50 | 52 | <code_completion /> |
51 | 53 | <envvars /> | ... | ... |
src/lib3270++/local.cc
... | ... | @@ -64,7 +64,12 @@ |
64 | 64 | |
65 | 65 | void LocalSession::connect(const char *url) { |
66 | 66 | std::lock_guard<std::mutex> lock(sync); |
67 | - lib3270_connect_url(hSession,url,0); | |
67 | + int rc = lib3270_connect_url(hSession,url,0); | |
68 | + | |
69 | + if(!rc) { | |
70 | + throw std::system_error(rc, std::system_category()); | |
71 | + } | |
72 | + | |
68 | 73 | } |
69 | 74 | |
70 | 75 | void LocalSession::disconnect() { | ... | ... |
src/lib3270++/session.cc
... | ... | @@ -43,6 +43,18 @@ |
43 | 43 | |
44 | 44 | namespace TN3270 { |
45 | 45 | |
46 | + /// @brief Create a tn3270 session. | |
47 | + Session * Session::create(const char *id) { | |
48 | + | |
49 | + if(!id) { | |
50 | + return new LocalSession(); | |
51 | + } | |
52 | + | |
53 | + throw std::system_error(EINVAL, std::system_category()); | |
54 | + | |
55 | + } | |
56 | + | |
57 | + | |
46 | 58 | Session::Session() { |
47 | 59 | |
48 | 60 | } | ... | ... |
... | ... | @@ -0,0 +1,52 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como lib3270++.h e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +/** | |
31 | + * @file src/lib3270++/testprogram/testprogram.cc | |
32 | + * | |
33 | + * @brief | |
34 | + * | |
35 | + * @author perry.werneck@gmail.com | |
36 | + * | |
37 | + */ | |
38 | + | |
39 | + #include <lib3270++.h> | |
40 | + | |
41 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
42 | + | |
43 | + int main(int argc, const char *argv[]) { | |
44 | + | |
45 | + TN3270::Host host; | |
46 | + | |
47 | + host.connect(nullptr); | |
48 | + | |
49 | + return 0; | |
50 | + } | |
51 | + | |
52 | + | ... | ... |