Commit bcf39f34e0ba76d4132448046d7948debb0a5761
1 parent
7f34eb75
Exists in
master
and in
1 other branch
Fixing charset conversions.
Showing
5 changed files
with
32 additions
and
14 deletions
Show diff stats
client/src/core/abstract.cc
@@ -79,6 +79,8 @@ | @@ -79,6 +79,8 @@ | ||
79 | /// @brief Setup charsets | 79 | /// @brief Setup charsets |
80 | void Abstract::Session::setCharSet(const char *remote, const char *local) { | 80 | void Abstract::Session::setCharSet(const char *remote, const char *local) { |
81 | 81 | ||
82 | + debug("Charsets: remote=",remote," local=",local); | ||
83 | + | ||
82 | if(!local) { | 84 | if(!local) { |
83 | 85 | ||
84 | // TODO: Detect the current value (maybee something like g_charset) | 86 | // TODO: Detect the current value (maybee something like g_charset) |
@@ -117,8 +119,8 @@ | @@ -117,8 +119,8 @@ | ||
117 | converter = lib3270_iconv_new(remote,local); | 119 | converter = lib3270_iconv_new(remote,local); |
118 | 120 | ||
119 | debug("lib3270_iconv_new(",remote,",",local,"=",(void *) converter); | 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,11 +170,17 @@ | ||
168 | #else | 170 | #else |
169 | if(converter) { | 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 | if(converted) { | 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 | return str; | 186 | return str; |
@@ -185,22 +193,32 @@ | @@ -185,22 +193,32 @@ | ||
185 | 193 | ||
186 | #ifdef HAVE_ICONV | 194 | #ifdef HAVE_ICONV |
187 | 195 | ||
196 | + debug("Using ICONV"); | ||
188 | return convertCharset(const_cast<Abstract::Session *>(this)->converter.host,text,length); | 197 | return convertCharset(const_cast<Abstract::Session *>(this)->converter.host,text,length); |
189 | 198 | ||
190 | #else | 199 | #else |
191 | 200 | ||
192 | if(converter) { | 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 | if(converted) { | 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 | #endif // HAVE_ICONV | 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,7 +90,7 @@ | ||
90 | 90 | ||
91 | for(ix = 0; installLocation.empty() && ix < (sizeof(keys)/sizeof(keys[0])); ix++) { | 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 | rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keys[ix],0,KEY_QUERY_VALUE,&hKey); | 95 | rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keys[ix],0,KEY_QUERY_VALUE,&hKey); |
96 | if(rc == ERROR_SUCCESS) { | 96 | if(rc == ERROR_SUCCESS) { |
@@ -103,11 +103,8 @@ | @@ -103,11 +103,8 @@ | ||
103 | 103 | ||
104 | rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen); | 104 | rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen); |
105 | if(rc == ERROR_SUCCESS) { | 105 | if(rc == ERROR_SUCCESS) { |
106 | - | ||
107 | - debug("Found: ",datadir); | ||
108 | - | 106 | +// debug("Found: ",datadir); |
109 | installLocation.assign(datadir); | 107 | installLocation.assign(datadir); |
110 | - | ||
111 | } | 108 | } |
112 | 109 | ||
113 | RegCloseKey(hKey); | 110 | RegCloseKey(hKey); |
client/src/session/remote/wait.cc
@@ -58,6 +58,7 @@ | @@ -58,6 +58,7 @@ | ||
58 | rc = worker(); | 58 | rc = worker(); |
59 | 59 | ||
60 | debug("rc=",rc," (",strerror(rc),")"); | 60 | debug("rc=",rc," (",strerror(rc),")"); |
61 | + printf("rc=%d\n",rc); | ||
61 | 62 | ||
62 | if(rc == 0) | 63 | if(rc == 0) |
63 | return; | 64 | return; |
@@ -205,9 +206,9 @@ | @@ -205,9 +206,9 @@ | ||
205 | 206 | ||
206 | void IPC::Session::wait(unsigned short row, unsigned short col, const char *text, int seconds) { | 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 | wait(seconds, [this, key, row, col]() { | 213 | wait(seconds, [this, key, row, col]() { |
213 | 214 |
client/src/testprogram/testprogram.cc
@@ -274,13 +274,15 @@ | @@ -274,13 +274,15 @@ | ||
274 | 274 | ||
275 | #else | 275 | #else |
276 | 276 | ||
277 | + printf("\nRunning IPC Client tests\n"); | ||
277 | 278 | ||
278 | TN3270::Host host{session}; | 279 | TN3270::Host host{session}; |
279 | host.setTimeout(10); | 280 | host.setTimeout(10); |
280 | host.connect(); | 281 | host.connect(); |
281 | - printf("\n\n\n"); | 282 | + printf("\n\nWaiting...\n"); |
282 | host.wait(14,22,"SISTEMA"); | 283 | host.wait(14,22,"SISTEMA"); |
283 | 284 | ||
285 | + host.disconnect(); | ||
284 | 286 | ||
285 | #endif // !_MSC_VER | 287 | #endif // !_MSC_VER |
286 | 288 |
ipc3270.exp
No preview for this file type