From 262966b29b7287f1ffbbcee9ce8affdd1e66bd3a Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 13 Aug 2019 17:11:18 -0300 Subject: [PATCH] Refactoring .NET api native module. --- src/native/actions.cc | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- src/native/get.cc | 81 +++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------- src/native/init.cc | 43 +++++++++++++------------------------------ src/native/native.cbp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/native/network.cc | 62 +++++++++++++++++++++++++++++++++++++++++++------------------- src/native/private.h | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- src/native/screen.cc | 49 +++++++++++++++++++++++++++++-------------------- src/native/set.cc | 48 ++++++++++++++++++++++++++---------------------- 8 files changed, 340 insertions(+), 212 deletions(-) create mode 100644 src/native/native.cbp diff --git a/src/native/actions.cc b/src/native/actions.cc index 7b7952b..c1e8caf 100644 --- a/src/native/actions.cc +++ b/src/native/actions.cc @@ -27,79 +27,105 @@ * */ + /** + * @file actions.cc + * + * @brief Actions wrapper. + * + * @author Perry Werneck + * + */ + #include "private.h" /*---[ Implement ]----------------------------------------------------------------------------------*/ -int tn3270_enter(h3270::session *ses) { - try { - return ses->enter(); - } catch(std::exception &e) { - tn3270_lasterror = e.what(); - return -1; +static int do_action(TN3270::Session *ses, TN3270::Action action) { + + if(ses) { + + try { + + ses->push(action); + return 0; + + } catch(const exception &e) { + + tn3270_lasterror = e.what(); + return -1; + + } + } + + return -1; + } -int tn3270_pfkey(h3270::session *ses, int key) { - try { - return ses->pfkey(key); - } catch(std::exception &e) { - tn3270_lasterror = e.what(); - return -1; - } +int tn3270_enter(TN3270::Session *ses) { + return do_action(ses,TN3270::ENTER); } -int tn3270_pakey(h3270::session *ses, int key) { +int tn3270_pfkey(TN3270::Session *ses, int key) { + try { - return ses->pakey(key); - } catch(std::exception &e) { + + ses->pfkey(key); + return 0; + + } catch(const exception &e) { + tn3270_lasterror = e.what(); - return -1; + } + return -1; + } -int tn3270_action(h3270::session *ses, const char *name) { +int tn3270_pakey(TN3270::Session *ses, int key) { + try { - return ses->action(name); - } catch(std::exception &e) { + + ses->pakey(key); + return 0; + + } catch(const exception &e) { + tn3270_lasterror = e.what(); - return -1; + } + return -1; } -int tn3270_erase(h3270::session *ses) { +int tn3270_action(TN3270::Session *ses, const char *name) { + try { - return ses->erase(); - } catch(std::exception &e) { + + ses->action(name); + return 0; + + } catch(const exception &e) { + tn3270_lasterror = e.what(); - return -1; + } + return -1; + } -int tn3270_erase_eof(h3270::session *ses) { - try { - return ses->erase_eof(); - } catch(std::exception &e) { - tn3270_lasterror = e.what(); - return -1; - } +int tn3270_erase(TN3270::Session *ses) { + return do_action(ses,TN3270::ERASE); } -int tn3270_erase_eol(h3270::session *ses) { - try { - return ses->erase_eol(); - } catch(std::exception &e) { - tn3270_lasterror = e.what(); - return -1; - } +int tn3270_erase_eof(TN3270::Session *ses) { + return do_action(ses,TN3270::ERASE_EOF); } -int tn3270_erase_input(h3270::session *ses) { - try { - return ses->erase_input(); - } catch(std::exception &e) { - tn3270_lasterror = e.what(); - return -1; - } +int tn3270_erase_eol(TN3270::Session *ses) { + return do_action(ses,TN3270::ERASE_EOL); +} + +int tn3270_erase_input(TN3270::Session *ses) { + return do_action(ses,TN3270::ERASE_INPUT); } diff --git a/src/native/get.cc b/src/native/get.cc index f967095..e070de5 100644 --- a/src/native/get.cc +++ b/src/native/get.cc @@ -36,17 +36,21 @@ * @brief Obtém a versão da biblioteca. * */ - int tn3270_get_version(h3270::session *ses, char* str, int strlen) { + int tn3270_get_version(TN3270::Session *ses, char* str, int strlen) { if(!ses) { return -1; } try { - strncpy(str,ses->get_version().c_str(),strlen); - } catch(std::exception &e) { + + strncpy(str,ses->getVersion().c_str(),strlen); + + } catch(const exception &e) { + tn3270_lasterror = e.what(); return -1; + } return 0; } @@ -55,120 +59,133 @@ * @brief Obtém a revisão da biblioteca. * */ - int tn3270_get_revision(h3270::session *ses, char* str, int strlen) { + int tn3270_get_revision(TN3270::Session *ses, char* str, int strlen) { if(!ses) { return -1; } try { - strncpy(str,ses->get_revision().c_str(),strlen); - } catch(std::exception &e) { + + strncpy(str,ses->getRevision().c_str(),strlen); + + } catch(const exception &e) { + tn3270_lasterror = e.what(); return -1; + } return 0; } - int tn3270_get_cstate(h3270::session *ses) { + int tn3270_get_cstate(TN3270::Session *ses) { if(!ses) { return -1; } - trace_to_file("%s: %d",__FUNCTION__,(int) ses->get_cstate()); - try { - return (int) ses->get_cstate(); - } catch(std::exception &e) { + + return (int) ses->getConnectionState(); + + } catch(const exception &e) { + tn3270_lasterror = e.what(); + } return -1; } - int tn3270_get_program_message(h3270::session *ses) { + int tn3270_get_program_message(TN3270::Session *ses) { if(!ses) { return -1; } try { - return (int) ses->get_program_message(); - } catch(std::exception &e) { + + return (int) ses->getProgramMessage(); + + } catch(const exception &e) { tn3270_lasterror = e.what(); } return -1; } - int tn3270_get_secure(h3270::session *ses) { + int tn3270_get_secure(TN3270::Session *ses) { + /* if(!ses) { return -1; } try { + return (int) ses->get_secure(); - } catch(std::exception &e) { + + } catch(const exception &e) { tn3270_lasterror = e.what(); } + */ + return -1; } - int tn3270_get_width(h3270::session *ses) { + int tn3270_get_width(TN3270::Session *ses) { if(!ses) { return 0; } try { - return (int) ses->get_width(); - } catch(std::exception &e) { + return (int) ses->getScreenWidth(); + } catch(const exception &e) { tn3270_lasterror = e.what(); } return -1; } - int tn3270_get_height(h3270::session *ses) { + int tn3270_get_height(TN3270::Session *ses) { if(!ses) { return 0; } try { - return (int) ses->get_height(); - } catch(std::exception &e) { + return (int) ses->getScreenHeight(); + } catch(const exception &e) { tn3270_lasterror = e.what(); } return -1; } - int tn3270_get_length(h3270::session *ses) { + int tn3270_get_length(TN3270::Session *ses) { if(!ses) { return 0; } try { - return (int) ses->get_length(); - } catch(std::exception &e) { + return (int) ses->getScreenLength(); + } catch(const exception &e) { tn3270_lasterror = e.what(); } return -1; } - int tn3270_get_cursor_addr(h3270::session *ses) { + int tn3270_get_cursor_addr(TN3270::Session *ses) { if(ses) { try { - return (int) ses->get_cursor_addr(); - } catch(std::exception &e) { + return (int) ses->getCursorAddress(); + } catch(const exception &e) { tn3270_lasterror = e.what(); } @@ -177,16 +194,16 @@ } - int tn3270_get_url(h3270::session *ses, char* str, int strlen) { + int tn3270_get_url(TN3270::Session *ses, char* str, int strlen) { if(ses) { try { - strncpy(str,ses->get_url().c_str(),strlen); + strncpy(str,ses->getHostURL().c_str(),strlen); return 0; - } catch(std::exception &e) { + } catch(const exception &e) { tn3270_lasterror = e.what(); } @@ -195,7 +212,7 @@ } - int tn3270_get_error_message(h3270::session *ses, char* str, int strlen) { + int tn3270_get_error_message(TN3270::Session *ses, char* str, int strlen) { strncpy(str,tn3270_lasterror.c_str(),strlen); return 0; diff --git a/src/native/init.cc b/src/native/init.cc index ca79ef2..301e146 100644 --- a/src/native/init.cc +++ b/src/native/init.cc @@ -41,16 +41,17 @@ * @return Identificador da sessão criada. * */ - h3270::session * tn3270_create_session(const char *name) { - - trace_to_file("%s(%s)",__FUNCTION__,name ? name : ""); + TN3270::Session * tn3270_create_session(const char *name) { try { - return h3270::session::create(name); - } catch(std::exception &e) { + + return TN3270::Session::create(name); + + } catch(const exception &e) { + tn3270_lasterror = e.what(); - trace_to_file("%s(%s)",__FUNCTION__,e.what()); } + return nullptr; } @@ -58,36 +59,18 @@ * @brief Destrói uma sessão. * */ - int tn3270_destroy_session(h3270::session *ses) { - - trace_to_file("%s",__FUNCTION__); + int tn3270_destroy_session(TN3270::Session *ses) { try { + delete ses; - } catch(std::exception &e) { + + } catch(const exception &e) { + tn3270_lasterror = e.what(); return -1; + } return 0; } -#ifdef ENABLE_TRACE_TO_FILE - void write_trace(const char *fmt, ...) { - - FILE *trace = fopen(PACKAGE_NAME ".trace","a"); - if(trace) { - va_list arg_ptr; - va_start(arg_ptr, fmt); - vfprintf(trace, fmt, arg_ptr); - fprintf(trace,"\n"); - va_end(arg_ptr); - fclose(trace); - } -#ifdef DEBUG - else { - perror(PACKAGE_NAME ".trace"); - } -#endif // DEBUG - - } -#endif // ENABLE_TRACE_TO_FILE diff --git a/src/native/native.cbp b/src/native/native.cbp new file mode 100644 index 0000000..652aee3 --- /dev/null +++ b/src/native/native.cbp @@ -0,0 +1,50 @@ + + + + + + diff --git a/src/native/network.cc b/src/native/network.cc index 332a81d..0fe7599 100644 --- a/src/native/network.cc +++ b/src/native/network.cc @@ -31,15 +31,24 @@ /*---[ Implement ]----------------------------------------------------------------------------------*/ -int tn3270_connect(h3270::session *ses, const char *host, time_t wait) { +int tn3270_connect(TN3270::Session *ses, const char *url, time_t timeout) { if(ses) { try { - debug("%s(%s,%d)",__FUNCTION__,host,(int) wait); - return ses->connect(host,wait); - } catch(std::exception &e) { + + ses->connect(url); + + if(timeout) { + ses->waitForReady(timeout); + } + + return 0; + + } catch(const exception &e) { + tn3270_lasterror = e.what(); + } } @@ -47,13 +56,16 @@ int tn3270_connect(h3270::session *ses, const char *host, time_t wait) { return -1; } -int tn3270_disconnect(h3270::session *ses) { +int tn3270_disconnect(TN3270::Session *ses) { if(ses) { try { - return ses->disconnect(); - } catch(std::exception &e) { + + ses->disconnect(); + return 0; + + } catch(const exception &e) { tn3270_lasterror = e.what(); } @@ -62,13 +74,15 @@ int tn3270_disconnect(h3270::session *ses) { return -1; } -int tn3270_is_connected(h3270::session *ses) { +int tn3270_is_connected(TN3270::Session *ses) { if(ses) { try { - return (int) ses->is_connected(); - } catch(std::exception &e) { + + return (int) (ses->getConnectionState() == TN3270::CONNECTED_TN3270E ? 1 : 0); + + } catch(const exception &e) { tn3270_lasterror = e.what(); } @@ -77,14 +91,18 @@ int tn3270_is_connected(h3270::session *ses) { return -1; } -int tn3270_is_ready(h3270::session *ses) { +int tn3270_is_ready(TN3270::Session *ses) { if(ses) { try { - return (int) ses->is_ready(); - } catch(std::exception &e) { + + return (int) (ses->getProgramMessage() == TN3270::MESSAGE_NONE ? 1 : 0); + + } catch(const exception &e) { + tn3270_lasterror = e.what(); + } } @@ -92,13 +110,16 @@ int tn3270_is_ready(h3270::session *ses) { return -1; } -int tn3270_wait_for_ready(h3270::session *ses, int seconds) { +int tn3270_wait_for_ready(TN3270::Session *ses, int seconds) { if(ses) { try { - return (int) ses->wait_for_ready(seconds); - } catch(std::exception &e) { + + ses->waitForReady(seconds); + return 0; + + } catch(const exception &e) { tn3270_lasterror = e.what(); } @@ -107,13 +128,16 @@ int tn3270_wait_for_ready(h3270::session *ses, int seconds) { } -int tn3270_wait(h3270::session *ses, int seconds) { +int tn3270_wait(TN3270::Session *ses, int seconds) { if(ses) { try { - return (int) ses->wait(seconds); - } catch(std::exception &e) { + + ses->wait(seconds); + return 0; + + } catch(const exception &e) { tn3270_lasterror = e.what(); } diff --git a/src/native/private.h b/src/native/private.h index 809218e..3baf462 100644 --- a/src/native/private.h +++ b/src/native/private.h @@ -31,6 +31,16 @@ * http://tirania.org/blog/archive/2011/Dec-19.html * */ + +/** + * @file private.h + * + * @brief Internal definitions for the .NET Native module. + * + * @author Perry Werneck + * + */ + #ifndef PRIVATE_H_INCLUDED #define PRIVATE_H_INCLUDED @@ -65,77 +75,82 @@ #define debug( fmt, ... ) /* */ #endif // DEBUG + /* #ifdef ENABLE_TRACE_TO_FILE DLL_PRIVATE void write_trace(const char *fmt, ...); - #define trace_to_file( ... ) write_trace(__VA_ARGS__) + #define trace( ... ) write_trace(__VA_ARGS__) #else - #define trace_to_file( ... ) /* */ + #define trace( ... ) #endif // ENABLE_TRACE_TO_FILE + */ - #include + #include #include #include - DLL_PRIVATE std::string tn3270_lasterror; + using std::string; + using std::exception; + + DLL_PRIVATE string tn3270_lasterror; extern "C" { - DLL_PUBLIC h3270::session * tn3270_create_session(const char *name); + DLL_PUBLIC TN3270::Session * tn3270_create_session(const char *name); - DLL_PUBLIC int tn3270_destroy_session(h3270::session *ses); + DLL_PUBLIC int tn3270_destroy_session(TN3270::Session *ses); - DLL_PUBLIC int tn3270_get_version(h3270::session *ses, char* str, int strlen); - DLL_PUBLIC int tn3270_get_revision(h3270::session *ses, char* str, int strlen); + DLL_PUBLIC int tn3270_get_version(TN3270::Session *ses, char* str, int strlen); + DLL_PUBLIC int tn3270_get_revision(TN3270::Session *ses, char* str, int strlen); - DLL_PUBLIC int tn3270_connect(h3270::session *ses, const char *host, time_t wait); - DLL_PUBLIC int tn3270_disconnect(h3270::session *ses); - DLL_PUBLIC int tn3270_is_connected(h3270::session *ses); - DLL_PUBLIC int tn3270_is_ready(h3270::session *ses); + DLL_PUBLIC int tn3270_connect(TN3270::Session *ses, const char *host, time_t wait); + DLL_PUBLIC int tn3270_disconnect(TN3270::Session *ses); + DLL_PUBLIC int tn3270_is_connected(TN3270::Session *ses); + DLL_PUBLIC int tn3270_is_ready(TN3270::Session *ses); - DLL_PUBLIC int tn3270_set_url(h3270::session *ses, const char *url); - DLL_PUBLIC int tn3270_get_url(h3270::session *ses, char* str, int strlen); + DLL_PUBLIC int tn3270_set_url(TN3270::Session *ses, const char *url); + DLL_PUBLIC int tn3270_get_url(TN3270::Session *ses, char* str, int strlen); - DLL_PUBLIC int tn3270_set_error_message(h3270::session *ses, const char *url); - DLL_PUBLIC int tn3270_get_error_message(h3270::session *ses, char* str, int strlen); + DLL_PUBLIC int tn3270_set_error_message(TN3270::Session *ses, const char *url); + DLL_PUBLIC int tn3270_get_error_message(TN3270::Session *ses, char* str, int strlen); - DLL_PUBLIC int tn3270_set_cursor_addr(h3270::session *ses, int addr); - DLL_PUBLIC int tn3270_get_cursor_addr(h3270::session *ses); + DLL_PUBLIC int tn3270_set_cursor_addr(TN3270::Session *ses, int addr); + DLL_PUBLIC int tn3270_get_cursor_addr(TN3270::Session *ses); - DLL_PUBLIC int tn3270_action(h3270::session *ses, const char *name); + DLL_PUBLIC int tn3270_action(TN3270::Session *ses, const char *name); - DLL_PUBLIC int tn3270_erase(h3270::session *ses); - DLL_PUBLIC int tn3270_erase_eof(h3270::session *ses); - DLL_PUBLIC int tn3270_erase_eol(h3270::session *ses); - DLL_PUBLIC int tn3270_erase_input(h3270::session *ses); + DLL_PUBLIC int tn3270_erase(TN3270::Session *ses); + DLL_PUBLIC int tn3270_erase_eof(TN3270::Session *ses); + DLL_PUBLIC int tn3270_erase_eol(TN3270::Session *ses); + DLL_PUBLIC int tn3270_erase_input(TN3270::Session *ses); - DLL_PUBLIC int tn3270_wait_for_ready(h3270::session *ses, int seconds); - DLL_PUBLIC int tn3270_wait(h3270::session *ses, int seconds); + DLL_PUBLIC int tn3270_wait_for_ready(TN3270::Session *ses, int seconds); + DLL_PUBLIC int tn3270_wait(TN3270::Session *ses, int seconds); - DLL_PUBLIC int tn3270_get_cstate(h3270::session *ses); - DLL_PUBLIC int tn3270_get_program_message(h3270::session *ses); - DLL_PUBLIC int tn3270_get_secure(h3270::session *ses); + DLL_PUBLIC int tn3270_get_cstate(TN3270::Session *ses); + DLL_PUBLIC int tn3270_get_program_message(TN3270::Session *ses); + DLL_PUBLIC int tn3270_get_secure(TN3270::Session *ses); - DLL_PUBLIC int tn3270_get_contents(h3270::session *ses, char* str, int strlen); - DLL_PUBLIC int tn3270_get_string(h3270::session *ses, int addr, char* str, int strlen); - DLL_PUBLIC int tn3270_get_string_at(h3270::session *ses, int row, int col, char* str, int strlen); + DLL_PUBLIC int tn3270_get_contents(TN3270::Session *ses, char* str, int strlen); + DLL_PUBLIC int tn3270_get_string(TN3270::Session *ses, int addr, char* str, int strlen); + DLL_PUBLIC int tn3270_get_string_at(TN3270::Session *ses, int row, int col, char* str, int strlen); - DLL_PUBLIC int tn3270_set_string_at(h3270::session *ses, int row, int col, const char* str); + DLL_PUBLIC int tn3270_set_string_at(TN3270::Session *ses, int row, int col, const char* str); - DLL_PUBLIC int tn3270_wait_for_string_at(h3270::session *ses, int row, int col, const char *key, int timeout); - DLL_PUBLIC int tn3270_cmp_string_at(h3270::session *ses, int row, int col, const char* str); + DLL_PUBLIC int tn3270_wait_for_string_at(TN3270::Session *ses, int row, int col, const char *key, int timeout); + DLL_PUBLIC int tn3270_cmp_string_at(TN3270::Session *ses, int row, int col, const char* str); - DLL_PUBLIC int tn3270_set_unlock_delay(h3270::session *ses, int ms); - DLL_PUBLIC int tn3270_set_cursor_position(h3270::session *ses, int row, int col); + DLL_PUBLIC int tn3270_set_unlock_delay(TN3270::Session *ses, int ms); + DLL_PUBLIC int tn3270_set_cursor_position(TN3270::Session *ses, int row, int col); - DLL_PUBLIC int tn3270_enter(h3270::session *ses); - DLL_PUBLIC int tn3270_pfkey(h3270::session *ses, int key); - DLL_PUBLIC int tn3270_pakey(h3270::session *ses, int key); + DLL_PUBLIC int tn3270_enter(TN3270::Session *ses); + DLL_PUBLIC int tn3270_pfkey(TN3270::Session *ses, int key); + DLL_PUBLIC int tn3270_pakey(TN3270::Session *ses, int key); - DLL_PUBLIC int tn3270_get_width(h3270::session *ses); - DLL_PUBLIC int tn3270_get_height(h3270::session *ses); - DLL_PUBLIC int tn3270_get_length(h3270::session *ses); + DLL_PUBLIC int tn3270_get_width(TN3270::Session *ses); + DLL_PUBLIC int tn3270_get_height(TN3270::Session *ses); + DLL_PUBLIC int tn3270_get_length(TN3270::Session *ses); - DLL_PUBLIC int tn3270_set_charset(h3270::session *ses, const char* str); + DLL_PUBLIC int tn3270_set_charset(TN3270::Session *ses, const char* str); } diff --git a/src/native/screen.cc b/src/native/screen.cc index 0897ae3..2d1c464 100644 --- a/src/native/screen.cc +++ b/src/native/screen.cc @@ -31,7 +31,7 @@ /*---[ Implement ]----------------------------------------------------------------------------------*/ -int tn3270_get_contents(h3270::session *ses, char* str, int sz) { +int tn3270_get_contents(TN3270::Session *ses, char* str, int sz) { if(!ses) { return -1; @@ -39,7 +39,7 @@ int tn3270_get_contents(h3270::session *ses, char* str, int sz) { try { - std::string contents = ses->get_contents(); + std::string contents = ses->toString(0,sz); memset(str,0,sz); strncpy(str,contents.c_str(),sz); @@ -48,7 +48,7 @@ int tn3270_get_contents(h3270::session *ses, char* str, int sz) { return contents.size(); } - } catch(std::exception &e) { + } catch(const exception &e) { tn3270_lasterror = e.what(); return -1; } @@ -57,7 +57,7 @@ int tn3270_get_contents(h3270::session *ses, char* str, int sz) { } -int tn3270_get_string(h3270::session *ses, int addr, char* str, int strlen) { +int tn3270_get_string(TN3270::Session *ses, int addr, char* str, int strlen) { if(!ses) { return -1; @@ -65,8 +65,8 @@ int tn3270_get_string(h3270::session *ses, int addr, char* str, int strlen) { try { memset(str,0,strlen); - strncpy(str,ses->get_string(addr,strlen).c_str(),strlen); - } catch(std::exception &e) { + strncpy(str,ses->toString(addr,strlen).c_str(),strlen); + } catch(const exception &e) { tn3270_lasterror = e.what(); return -1; } @@ -74,67 +74,76 @@ int tn3270_get_string(h3270::session *ses, int addr, char* str, int strlen) { return 0; } -int tn3270_get_string_at(h3270::session *ses, int row, int col, char* str, int sz) { +int tn3270_get_string_at(TN3270::Session *ses, int row, int col, char* str, int sz) { if(!ses) { return -1; } try { + memset(str,0,sz+1); - strncpy(str,ses->get_string_at(row,col,sz).c_str(),sz); - trace_to_file("%s(%d,%d,%d):\n%s\n",__FUNCTION__,row,col,sz,str); - } catch(std::exception &e) { + strncpy(str,ses->toString(row,col,(size_t) sz).c_str(),sz); + + } catch(const exception &e) { tn3270_lasterror = e.what(); return -1; } return (int) strlen(str); } -int tn3270_set_string_at(h3270::session *ses, int row, int col, const char* str) { +int tn3270_set_string_at(TN3270::Session *ses, int row, int col, const char* str) { if(!ses) { return -1; } try { - trace_to_file("%s(%d,%d):\n%s\n",__FUNCTION__,row,col,str); - debug("%s(%d,%d,\"%s\")",__FUNCTION__,row,col,str); - ses->set_string_at(row,col,str); - } catch(std::exception &e) { + + ses->push(row,col,str); + + } catch(const exception &e) { tn3270_lasterror = e.what(); return -1; } return 0; } -int tn3270_wait_for_string_at(h3270::session *ses, int row, int col, const char *key, int timeout) { +int tn3270_wait_for_string_at(TN3270::Session *ses, int row, int col, const char *key, int timeout) { + /* if(ses) { try { - return ses->wait_for_string_at(row,col,key,timeout); - } catch(std::exception &e) { + + return ses->wait(row,col,key,timeout); + + } catch(const exception &e) { + tn3270_lasterror = e.what(); + } } + */ return -1; } -int tn3270_cmp_string_at(h3270::session *ses, int row, int col, const char* str) { +int tn3270_cmp_string_at(TN3270::Session *ses, int row, int col, const char* str) { + /* if(ses) { try { return ses->cmp_string_at(row,col,str); - } catch(std::exception &e) { + } catch(const exception &e) { tn3270_lasterror = e.what(); } } + */ return -1; } diff --git a/src/native/set.cc b/src/native/set.cc index 1d60e93..95938c1 100644 --- a/src/native/set.cc +++ b/src/native/set.cc @@ -31,64 +31,68 @@ /*---[ Implement ]----------------------------------------------------------------------------------*/ -int tn3270_set_unlock_delay(h3270::session *ses, int ms) { +int tn3270_set_unlock_delay(TN3270::Session *ses, int ms) { try { - ses->set_unlock_delay((unsigned short) ms); - } catch(std::exception &e) { + ses->setUnlockDelay((unsigned short) ms); + } catch(const exception &e) { tn3270_lasterror = e.what(); return -1; } return 0; } -int tn3270_set_cursor_position(h3270::session *ses, int row, int col) { +int tn3270_set_cursor_position(TN3270::Session *ses, int row, int col) { try { - ses->set_cursor_position(row,col); - } catch(std::exception &e) { + ses->setCursor((unsigned short) row, (unsigned short) col); + } catch(const exception &e) { tn3270_lasterror = e.what(); return -1; } return 0; } -int tn3270_set_cursor_addr(h3270::session *ses, int addr) { +int tn3270_set_cursor_addr(TN3270::Session *ses, int addr) { try { - ses->set_cursor_addr(addr); - } catch(std::exception &e) { + ses->setCursor((unsigned short) addr); + } catch(const exception &e) { tn3270_lasterror = e.what(); return -1; } return 0; } -int tn3270_set_charset(h3270::session *ses, const char* str) { - - if(!ses) { - return EINVAL; - } +int tn3270_set_charset(TN3270::Session *ses, const char* str) { try { - trace_to_file("%s: \"%s\" -> \"%s\"",__FUNCTION__,ses->get_display_charset().c_str(),str); - ses->set_display_charset(NULL, str); - } catch(std::exception &e) { + + ses->setCharSet(str); + + } catch(const exception &e) { + tn3270_lasterror = e.what(); return -1; + } + return 0; + } -int tn3270_set_url(h3270::session *ses, const char *url) { +int tn3270_set_url(TN3270::Session *ses, const char *url) { + try { - debug("%s(%s)",__FUNCTION__,url); - ses->set_url(url); - } catch(std::exception &e) { + + ses->setHostURL(url); + + } catch(const exception &e) { tn3270_lasterror = e.what(); return -1; } + return 0; } -int tn3270_set_error_message(h3270::session *ses, const char *str) { +int tn3270_set_error_message(TN3270::Session *ses, const char *str) { tn3270_lasterror = str; return 0; } -- libgit2 0.21.2