diff --git a/client/src/core/abstract.cc b/client/src/core/abstract.cc index 8219db0..8924f04 100644 --- a/client/src/core/abstract.cc +++ b/client/src/core/abstract.cc @@ -79,6 +79,8 @@ /// @brief Setup charsets void Abstract::Session::setCharSet(const char *remote, const char *local) { + debug("Charsets: remote=",remote," local=",local); + if(!local) { // TODO: Detect the current value (maybee something like g_charset) @@ -117,8 +119,8 @@ converter = lib3270_iconv_new(remote,local); debug("lib3270_iconv_new(",remote,",",local,"=",(void *) converter); -#endif +#endif } @@ -168,11 +170,17 @@ #else if(converter) { - lib3270_auto_cleanup converted = lib3270_iconv_from_host(converter,str.c_str(),str.size()); + char * converted = lib3270_iconv_from_host(converter,str.c_str(),str.size()); if(converted) { - return std::string(converted); + std::string rc(converted); + lib3270_free(converted); + return rc; } + } else { + + throw std::runtime_error("Unable to convert charsets"); + } return str; @@ -185,22 +193,32 @@ #ifdef HAVE_ICONV + debug("Using ICONV"); return convertCharset(const_cast(this)->converter.host,text,length); #else if(converter) { - lib3270_auto_cleanup converted = lib3270_iconv_to_host(converter,text,length); + debug("Converting \"",text,"\" with lib3270 converter ",((void *) converter)); + + char * converted = lib3270_iconv_to_host(converter,text,length); + if(converted) { - return std::string(converted); + std::string rc(converted); + debug("Converted=\"",rc,"\""); + lib3270_free(converted); + return rc; } } #endif // HAVE_ICONV - return std::string(text,length); + if(length > 0) + return std::string(text,length); + + return std::string(text); } diff --git a/client/src/core/windows/tools.cc b/client/src/core/windows/tools.cc index 92bb814..1de936c 100644 --- a/client/src/core/windows/tools.cc +++ b/client/src/core/windows/tools.cc @@ -90,7 +90,7 @@ for(ix = 0; installLocation.empty() && ix < (sizeof(keys)/sizeof(keys[0])); ix++) { - debug(ix,"=",keys[ix]); +// debug(ix,"=",keys[ix]); rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keys[ix],0,KEY_QUERY_VALUE,&hKey); if(rc == ERROR_SUCCESS) { @@ -103,11 +103,8 @@ rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen); if(rc == ERROR_SUCCESS) { - - debug("Found: ",datadir); - +// debug("Found: ",datadir); installLocation.assign(datadir); - } RegCloseKey(hKey); diff --git a/client/src/session/remote/wait.cc b/client/src/session/remote/wait.cc index 013c46c..9d1d393 100644 --- a/client/src/session/remote/wait.cc +++ b/client/src/session/remote/wait.cc @@ -58,6 +58,7 @@ rc = worker(); debug("rc=",rc," (",strerror(rc),")"); + printf("rc=%d\n",rc); if(rc == 0) return; @@ -205,9 +206,9 @@ void IPC::Session::wait(unsigned short row, unsigned short col, const char *text, int seconds) { - string key = convertToHost(text,-1); + debug((const char *) __FUNCTION__, "(", row, ",", col, ",\"",text,"\")"); - debug((const char *) __FUNCTION__, "(", (int) row, ",", (int) col, ", \"", text, "\", length=", key.size()); + string key = convertToHost(text,-1); wait(seconds, [this, key, row, col]() { diff --git a/client/src/testprogram/testprogram.cc b/client/src/testprogram/testprogram.cc index 280ad34..22c86ff 100644 --- a/client/src/testprogram/testprogram.cc +++ b/client/src/testprogram/testprogram.cc @@ -274,13 +274,15 @@ #else + printf("\nRunning IPC Client tests\n"); TN3270::Host host{session}; host.setTimeout(10); host.connect(); - printf("\n\n\n"); + printf("\n\nWaiting...\n"); host.wait(14,22,"SISTEMA"); + host.disconnect(); #endif // !_MSC_VER diff --git a/ipc3270.exp b/ipc3270.exp index 8d9182f..2de3cb8 100644 Binary files a/ipc3270.exp and b/ipc3270.exp differ -- libgit2 0.21.2