diff --git a/src/include/lib3270++.h b/src/include/lib3270++.h index 4abe974..f3d483e 100644 --- a/src/include/lib3270++.h +++ b/src/include/lib3270++.h @@ -24,8 +24,6 @@ * * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) * */ @@ -34,6 +32,7 @@ #define LIB3270_HPP_INCLUDED 1 #include + #include #include #if defined(_WIN32) @@ -136,6 +135,15 @@ protected: Session(); + /// @brief Write information to log file. + void info(const char *fmt, ...) const; + + /// @brief Write warning to log file. + void warning(const char *fmt, ...) const; + + /// @brief Write error to log file. + void error(const char *fmt, ...) const; + public: /// @brief Create a tn3270 session. @@ -145,7 +153,7 @@ // Connect/disconnect virtual void connect(const char *url) = 0; - virtual void disconnect(); + virtual void disconnect() = 0; // Wait for session state. virtual void waitForReady(time_t timeout = 5) throw() = 0; @@ -205,6 +213,15 @@ /// @brief Writes characters to the associated output sequence from the put area. int overflow(int c) override; + /// @brief Write information to log file. + void info(const char *fmt, ...) const; + + /// @brief Write warning to log file. + void warning(const char *fmt, ...) const; + + /// @brief Write error to log file. + void error(const char *fmt, ...) const; + public: Host(const char *id = nullptr, const char *url = nullptr); ~Host(); diff --git a/src/lib3270++/lib3270++.cbp b/src/lib3270++/lib3270++.cbp index 5cde9f1..bdb02fa 100644 --- a/src/lib3270++/lib3270++.cbp +++ b/src/lib3270++/lib3270++.cbp @@ -41,11 +41,13 @@ + + diff --git a/src/lib3270++/local.cc b/src/lib3270++/local.cc index 1e99f9e..0865644 100644 --- a/src/lib3270++/local.cc +++ b/src/lib3270++/local.cc @@ -64,7 +64,12 @@ void LocalSession::connect(const char *url) { std::lock_guard lock(sync); - lib3270_connect_url(hSession,url,0); + int rc = lib3270_connect_url(hSession,url,0); + + if(!rc) { + throw std::system_error(rc, std::system_category()); + } + } void LocalSession::disconnect() { diff --git a/src/lib3270++/session.cc b/src/lib3270++/session.cc index 2ed957c..61f84b5 100644 --- a/src/lib3270++/session.cc +++ b/src/lib3270++/session.cc @@ -43,6 +43,18 @@ namespace TN3270 { + /// @brief Create a tn3270 session. + Session * Session::create(const char *id) { + + if(!id) { + return new LocalSession(); + } + + throw std::system_error(EINVAL, std::system_category()); + + } + + Session::Session() { } diff --git a/src/lib3270++/testprogram/testprogram.cc b/src/lib3270++/testprogram/testprogram.cc new file mode 100644 index 0000000..cf2e559 --- /dev/null +++ b/src/lib3270++/testprogram/testprogram.cc @@ -0,0 +1,52 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como lib3270++.h e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +/** + * @file src/lib3270++/testprogram/testprogram.cc + * + * @brief + * + * @author perry.werneck@gmail.com + * + */ + + #include + +/*---[ Implement ]----------------------------------------------------------------------------------*/ + + int main(int argc, const char *argv[]) { + + TN3270::Host host; + + host.connect(nullptr); + + return 0; + } + + -- libgit2 0.21.2