Commit 394595afdf0a74327fba1c6ed7dd72952782d918

Authored by Perry Werneck
1 parent a9bf66c0

Iniciando implementação do "remap" de caracteres.

src/include/lib3270/charset.h
... ... @@ -60,7 +60,8 @@
60 60  
61 61 LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name);
62 62 LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession);
63   - LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way);
  63 + LIB3270_EXPORT void lib3270_remap(H3270 *hSession,const char *host, const char *display, unsigned long cgcsgid, const unsigned short *chr);
  64 + LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way);
64 65 LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buffer, int sz);
65 66 LIB3270_EXPORT const char * lib3270_asc2ebc(H3270 *hSession, unsigned char *buffer, int sz);
66 67  
... ...
src/lib3270/charset.c
... ... @@ -255,6 +255,21 @@ static void copy_charset(const unsigned short *from, unsigned short *to)
255 255 to[f+UT_OFFSET] = from[f];
256 256 }
257 257  
  258 +LIB3270_EXPORT void lib3270_remap(H3270 *hSession,const char *host, const char *display, unsigned long cgcsgid, const unsigned short *chr)
  259 +{
  260 + int c;
  261 +
  262 + hSession->charset.host = host;
  263 + hSession->charset.display = display;
  264 + hSession->charset.cgcsgid = cgcsgid;
  265 +
  266 + for(c=0;chr[c];c+=2)
  267 + {
  268 + lib3270_remap_char(hSession,chr[c],chr[c+1], BOTH, 0);
  269 + }
  270 +
  271 +}
  272 +
258 273 LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name)
259 274 {
260 275 int f;
... ... @@ -271,6 +286,7 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name)
271 286  
272 287 for(f=0;f<UT_OFFSET;f++)
273 288 hSession->charset.asc2uc[f] = f;
  289 +
274 290 copy_charset(asc2uc,hSession->charset.asc2uc);
275 291  
276 292 /*
... ... @@ -288,13 +304,16 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name)
288 304 if(!strcasecmp(name,charset[f].name))
289 305 {
290 306 // Found required charset
  307 + lib3270_remap(hSession,charset[f].name,"ISO-8859-1",charset[f].cgcsgid,charset[f].chr);
  308 + /*
291 309 int c;
292 310  
293 311 hSession->charset.host = charset[f].name;
294 312 hSession->charset.cgcsgid = charset[f].cgcsgid;
295 313  
296 314 for(c=0;charset[f].chr[c];c+=2)
297   - lib3270_remap(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0);
  315 + lib3270_remap_char(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0);
  316 + */
298 317 return 0;
299 318 }
300 319 }
... ... @@ -438,7 +457,7 @@ LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buff
438 457  
439 458  
440 459 // Process a single character definition.
441   -LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way)
  460 +LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way)
442 461 {
443 462 // unsigned char cg;
444 463 CHECK_SESSION_HANDLE(hSession);
... ...