Commit bcf39f34e0ba76d4132448046d7948debb0a5761

Authored by Perry Werneck
1 parent 7f34eb75
Exists in master and in 1 other branch develop

Fixing charset conversions.

client/src/core/abstract.cc
... ... @@ -79,6 +79,8 @@
79 79 /// @brief Setup charsets
80 80 void Abstract::Session::setCharSet(const char *remote, const char *local) {
81 81  
  82 + debug("Charsets: remote=",remote," local=",local);
  83 +
82 84 if(!local) {
83 85  
84 86 // TODO: Detect the current value (maybee something like g_charset)
... ... @@ -117,8 +119,8 @@
117 119 converter = lib3270_iconv_new(remote,local);
118 120  
119 121 debug("lib3270_iconv_new(",remote,",",local,"=",(void *) converter);
120   -#endif
121 122  
  123 +#endif
122 124  
123 125 }
124 126  
... ... @@ -168,11 +170,17 @@
168 170 #else
169 171 if(converter) {
170 172  
171   - lib3270_auto_cleanup<char> converted = lib3270_iconv_from_host(converter,str.c_str(),str.size());
  173 + char * converted = lib3270_iconv_from_host(converter,str.c_str(),str.size());
172 174 if(converted) {
173   - return std::string(converted);
  175 + std::string rc(converted);
  176 + lib3270_free(converted);
  177 + return rc;
174 178 }
175 179  
  180 + } else {
  181 +
  182 + throw std::runtime_error("Unable to convert charsets");
  183 +
176 184 }
177 185  
178 186 return str;
... ... @@ -185,22 +193,32 @@
185 193  
186 194 #ifdef HAVE_ICONV
187 195  
  196 + debug("Using ICONV");
188 197 return convertCharset(const_cast<Abstract::Session *>(this)->converter.host,text,length);
189 198  
190 199 #else
191 200  
192 201 if(converter) {
193 202  
194   - lib3270_auto_cleanup<char> converted = lib3270_iconv_to_host(converter,text,length);
  203 + debug("Converting \"",text,"\" with lib3270 converter ",((void *) converter));
  204 +
  205 + char * converted = lib3270_iconv_to_host(converter,text,length);
  206 +
195 207 if(converted) {
196   - return std::string(converted);
  208 + std::string rc(converted);
  209 + debug("Converted=\"",rc,"\"");
  210 + lib3270_free(converted);
  211 + return rc;
197 212 }
198 213  
199 214 }
200 215  
201 216 #endif // HAVE_ICONV
202 217  
203   - return std::string(text,length);
  218 + if(length > 0)
  219 + return std::string(text,length);
  220 +
  221 + return std::string(text);
204 222  
205 223 }
206 224  
... ...
client/src/core/windows/tools.cc
... ... @@ -90,7 +90,7 @@
90 90  
91 91 for(ix = 0; installLocation.empty() && ix < (sizeof(keys)/sizeof(keys[0])); ix++) {
92 92  
93   - debug(ix,"=",keys[ix]);
  93 +// debug(ix,"=",keys[ix]);
94 94  
95 95 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keys[ix],0,KEY_QUERY_VALUE,&hKey);
96 96 if(rc == ERROR_SUCCESS) {
... ... @@ -103,11 +103,8 @@
103 103  
104 104 rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen);
105 105 if(rc == ERROR_SUCCESS) {
106   -
107   - debug("Found: ",datadir);
108   -
  106 +// debug("Found: ",datadir);
109 107 installLocation.assign(datadir);
110   -
111 108 }
112 109  
113 110 RegCloseKey(hKey);
... ...
client/src/session/remote/wait.cc
... ... @@ -58,6 +58,7 @@
58 58 rc = worker();
59 59  
60 60 debug("rc=",rc," (",strerror(rc),")");
  61 + printf("rc=%d\n",rc);
61 62  
62 63 if(rc == 0)
63 64 return;
... ... @@ -205,9 +206,9 @@
205 206  
206 207 void IPC::Session::wait(unsigned short row, unsigned short col, const char *text, int seconds) {
207 208  
208   - string key = convertToHost(text,-1);
  209 + debug((const char *) __FUNCTION__, "(", row, ",", col, ",\"",text,"\")");
209 210  
210   - debug((const char *) __FUNCTION__, "(", (int) row, ",", (int) col, ", \"", text, "\", length=", key.size());
  211 + string key = convertToHost(text,-1);
211 212  
212 213 wait(seconds, [this, key, row, col]() {
213 214  
... ...
client/src/testprogram/testprogram.cc
... ... @@ -274,13 +274,15 @@
274 274  
275 275 #else
276 276  
  277 + printf("\nRunning IPC Client tests\n");
277 278  
278 279 TN3270::Host host{session};
279 280 host.setTimeout(10);
280 281 host.connect();
281   - printf("\n\n\n");
  282 + printf("\n\nWaiting...\n");
282 283 host.wait(14,22,"SISTEMA");
283 284  
  285 + host.disconnect();
284 286  
285 287 #endif // !_MSC_VER
286 288  
... ...
ipc3270.exp
No preview for this file type