Commit 6c93bad80b1ce3c991fc721f0e4f2f0c95cf1643
1 parent
d401cc11
Exists in
master
and in
5 other branches
Incluindo conversão ebcdic<->asc no módulo rexx
Showing
13 changed files
with
182 additions
and
4 deletions
Show diff stats
po/pt_BR.po
@@ -5,7 +5,7 @@ msgid "" | @@ -5,7 +5,7 @@ msgid "" | ||
5 | msgstr "" | 5 | msgstr "" |
6 | "Project-Id-Version: pw3270 5.0\n" | 6 | "Project-Id-Version: pw3270 5.0\n" |
7 | "Report-Msgid-Bugs-To: \n" | 7 | "Report-Msgid-Bugs-To: \n" |
8 | -"POT-Creation-Date: 2013-11-27 14:51-0200\n" | 8 | +"POT-Creation-Date: 2013-11-28 10:23-0200\n" |
9 | "PO-Revision-Date: 2013-11-12 08:07-0200\n" | 9 | "PO-Revision-Date: 2013-11-12 08:07-0200\n" |
10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" | 10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" |
11 | "Language-Team: Português <perry.werneck@gmail.com>\n" | 11 | "Language-Team: Português <perry.werneck@gmail.com>\n" |
@@ -664,12 +664,12 @@ msgstr "Erro \"%s\" gravando arquivo local (rc=%d)" | @@ -664,12 +664,12 @@ msgstr "Erro \"%s\" gravando arquivo local (rc=%d)" | ||
664 | msgid "Error %d resolving %s" | 664 | msgid "Error %d resolving %s" |
665 | msgstr "Erro %d resolvendo %s" | 665 | msgstr "Erro %d resolvendo %s" |
666 | 666 | ||
667 | -#: telnet.c:3145 telnet.c:3156 | 667 | +#: telnet.c:3146 telnet.c:3157 |
668 | #, c-format | 668 | #, c-format |
669 | msgid "Error in fcntl(%s) when setting non blocking mode" | 669 | msgid "Error in fcntl(%s) when setting non blocking mode" |
670 | msgstr "Erro em fcntl(%s) ao ativar o modo não blocante" | 670 | msgstr "Erro em fcntl(%s) ao ativar o modo não blocante" |
671 | 671 | ||
672 | -#: telnet.c:3135 | 672 | +#: telnet.c:3136 |
673 | #, c-format | 673 | #, c-format |
674 | msgid "Error in ioctl(%s) when setting no blocking mode" | 674 | msgid "Error in ioctl(%s) when setting no blocking mode" |
675 | msgstr "Erro em ioctl(%s) ao ativar o modo não blocante" | 675 | msgstr "Erro em ioctl(%s) ao ativar o modo não blocante" |
@@ -1692,7 +1692,7 @@ msgstr "Tipo de servidor:" | @@ -1692,7 +1692,7 @@ msgstr "Tipo de servidor:" | ||
1692 | msgid "TELNET Proxy: send error" | 1692 | msgid "TELNET Proxy: send error" |
1693 | msgstr "TELNET Proxy: Erro ao enviar" | 1693 | msgstr "TELNET Proxy: Erro ao enviar" |
1694 | 1694 | ||
1695 | -#: telnet.c:3342 | 1695 | +#: telnet.c:3343 |
1696 | msgid "TLS negotiation failure" | 1696 | msgid "TLS negotiation failure" |
1697 | msgstr "Negociação TLS falhou" | 1697 | msgstr "Negociação TLS falhou" |
1698 | 1698 |
src/classlib/local.cc
@@ -307,6 +307,8 @@ | @@ -307,6 +307,8 @@ | ||
307 | const char * (*_get_host_charset)(H3270 *hSession); | 307 | const char * (*_get_host_charset)(H3270 *hSession); |
308 | int (*_print)(H3270 *hSession); | 308 | int (*_print)(H3270 *hSession); |
309 | int (*_erase_eof)(H3270 *hSession); | 309 | int (*_erase_eof)(H3270 *hSession); |
310 | + const char * (*_ebc2asc)(H3270 *hSession, unsigned char *buffer, size_t sz); | ||
311 | + const char * (*_asc2ebc)(H3270 *hSession, unsigned char *buffer, size_t sz); | ||
310 | 312 | ||
311 | public: | 313 | public: |
312 | 314 | ||
@@ -358,6 +360,8 @@ | @@ -358,6 +360,8 @@ | ||
358 | { (void **) & _get_host_charset, "lib3270_get_host_charset" }, | 360 | { (void **) & _get_host_charset, "lib3270_get_host_charset" }, |
359 | { (void **) & _erase_eof, "lib3270_eraseeof" }, | 361 | { (void **) & _erase_eof, "lib3270_eraseeof" }, |
360 | { (void **) & _print, "lib3270_print" }, | 362 | { (void **) & _print, "lib3270_print" }, |
363 | + { (void **) & _ebc2asc, "lib3270_ebc2asc" }, | ||
364 | + { (void **) & _asc2ebc, "lib3270_asc2ebc" }, | ||
361 | 365 | ||
362 | }; | 366 | }; |
363 | 367 | ||
@@ -576,6 +580,16 @@ | @@ -576,6 +580,16 @@ | ||
576 | } | 580 | } |
577 | 581 | ||
578 | 582 | ||
583 | + const char * asc2ebc(unsigned char *str, size_t sz) | ||
584 | + { | ||
585 | + return _asc2ebc(hSession,str,sz); | ||
586 | + } | ||
587 | + | ||
588 | + const char * ebc2asc(unsigned char *str, size_t sz) | ||
589 | + { | ||
590 | + return _ebc2asc(hSession,str,sz); | ||
591 | + } | ||
592 | + | ||
579 | }; | 593 | }; |
580 | 594 | ||
581 | session * session::create_local(void) | 595 | session * session::create_local(void) |
src/classlib/remote.cc
@@ -1188,6 +1188,19 @@ | @@ -1188,6 +1188,19 @@ | ||
1188 | return query_intval(HLLAPI_PACKET_PRINT); | 1188 | return query_intval(HLLAPI_PACKET_PRINT); |
1189 | } | 1189 | } |
1190 | 1190 | ||
1191 | + const char * asc2ebc(unsigned char *str, size_t sz) | ||
1192 | + { | ||
1193 | + #warning Incomplete | ||
1194 | + return (const char *) str; | ||
1195 | + } | ||
1196 | + | ||
1197 | + const char * ebc2asc(unsigned char *str, size_t sz) | ||
1198 | + { | ||
1199 | + #warning Incomplete | ||
1200 | + return (const char *) str; | ||
1201 | + } | ||
1202 | + | ||
1203 | + | ||
1191 | }; | 1204 | }; |
1192 | 1205 | ||
1193 | session * session::create_remote(const char *session) | 1206 | session * session::create_remote(const char *session) |
src/classlib/session.cc
@@ -446,6 +446,23 @@ | @@ -446,6 +446,23 @@ | ||
446 | return get_local_text(get_text(baddr,len)); | 446 | return get_local_text(get_text(baddr,len)); |
447 | } | 447 | } |
448 | 448 | ||
449 | + string session::asc2ebc(string &str) | ||
450 | + { | ||
451 | + size_t sz = str.size(); | ||
452 | + unsigned char buffer[sz+1]; | ||
453 | + | ||
454 | + memcpy(buffer,str.c_str(),sz); | ||
455 | + return string(asc2ebc(buffer,sz)); | ||
456 | + } | ||
457 | + | ||
458 | + string session::ebc2asc(string &str) | ||
459 | + { | ||
460 | + size_t sz = str.size(); | ||
461 | + unsigned char buffer[sz+1]; | ||
462 | + memcpy(buffer,str.c_str(),sz); | ||
463 | + return string(ebc2asc(buffer,sz)); | ||
464 | + } | ||
465 | + | ||
449 | } | 466 | } |
450 | 467 | ||
451 | 468 |
src/include/lib3270/charset.h
@@ -64,6 +64,9 @@ | @@ -64,6 +64,9 @@ | ||
64 | LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name); | 64 | LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name); |
65 | LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession); | 65 | LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession); |
66 | LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way); | 66 | LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way); |
67 | + LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buffer, size_t sz); | ||
68 | + LIB3270_EXPORT const char * lib3270_asc2ebc(H3270 *hSession, unsigned char *buffer, size_t sz); | ||
69 | + | ||
67 | 70 | ||
68 | #ifdef __cplusplus | 71 | #ifdef __cplusplus |
69 | } | 72 | } |
src/include/pw3270/class.h
@@ -140,6 +140,12 @@ | @@ -140,6 +140,12 @@ | ||
140 | virtual int wait_for_text_at(int row, int col, const char *key, int timeout); | 140 | virtual int wait_for_text_at(int row, int col, const char *key, int timeout); |
141 | virtual int emulate_input(const char *str) = 0; | 141 | virtual int emulate_input(const char *str) = 0; |
142 | 142 | ||
143 | + // Ascii<->EBCDIC translation | ||
144 | + virtual const char * asc2ebc(unsigned char *str, size_t sz = -1) = 0; | ||
145 | + virtual const char * ebc2asc(unsigned char *str, size_t sz = -1) = 0; | ||
146 | + string asc2ebc(string &str); | ||
147 | + string ebc2asc(string &str); | ||
148 | + | ||
143 | // Get/Set/Test with charset translation | 149 | // Get/Set/Test with charset translation |
144 | string * get_string(int baddr, size_t len); | 150 | string * get_string(int baddr, size_t len); |
145 | string * get_string_at(int row, int col, size_t sz); | 151 | string * get_string_at(int row, int col, size_t sz); |
src/lib3270/charset.c
@@ -402,6 +402,37 @@ LIB3270_ACTION( charsettable ) | @@ -402,6 +402,37 @@ LIB3270_ACTION( charsettable ) | ||
402 | return 0; | 402 | return 0; |
403 | } | 403 | } |
404 | 404 | ||
405 | +LIB3270_EXPORT const char * lib3270_asc2ebc(H3270 *hSession, unsigned char *buffer, size_t sz) | ||
406 | +{ | ||
407 | + int f; | ||
408 | + if(sz < 0) | ||
409 | + sz = strlen((const char *) buffer); | ||
410 | + | ||
411 | + if(sz > 0) | ||
412 | + { | ||
413 | + for(f=0;f<sz;f++) | ||
414 | + buffer[f] = hSession->charset.asc2ebc[buffer[f]]; | ||
415 | + } | ||
416 | + | ||
417 | + return (const char *) buffer; | ||
418 | +} | ||
419 | + | ||
420 | +LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buffer, size_t sz) | ||
421 | +{ | ||
422 | + int f; | ||
423 | + if(sz < 0) | ||
424 | + sz = strlen((const char *) buffer); | ||
425 | + | ||
426 | + if(sz > 0) | ||
427 | + { | ||
428 | + for(f=0;f<sz;f++) | ||
429 | + buffer[f] = hSession->charset.ebc2asc[buffer[f]]; | ||
430 | + } | ||
431 | + | ||
432 | + return (const char *) buffer; | ||
433 | +} | ||
434 | + | ||
435 | + | ||
405 | // Process a single character definition. | 436 | // Process a single character definition. |
406 | LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way) | 437 | LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way) |
407 | { | 438 | { |
src/plugins/rx3270/pluginmain.cc
@@ -52,6 +52,7 @@ | @@ -52,6 +52,7 @@ | ||
52 | #include <lib3270/charset.h> | 52 | #include <lib3270/charset.h> |
53 | #include <pw3270/class.h> | 53 | #include <pw3270/class.h> |
54 | 54 | ||
55 | + | ||
55 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 56 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
56 | 57 | ||
57 | #if GTK_CHECK_VERSION(2,32,0) | 58 | #if GTK_CHECK_VERSION(2,32,0) |
@@ -134,6 +135,9 @@ | @@ -134,6 +135,9 @@ | ||
134 | string * get_host_charset(void); | 135 | string * get_host_charset(void); |
135 | string * get_display_charset(void); | 136 | string * get_display_charset(void); |
136 | 137 | ||
138 | + const char * asc2ebc(unsigned char *str, size_t sz = -1); | ||
139 | + const char * ebc2asc(unsigned char *str, size_t sz = -1); | ||
140 | + | ||
137 | int quit(void); | 141 | int quit(void); |
138 | 142 | ||
139 | protected: | 143 | protected: |
@@ -756,3 +760,14 @@ int plugin::print(void) | @@ -756,3 +760,14 @@ int plugin::print(void) | ||
756 | { | 760 | { |
757 | return lib3270_print(hSession); | 761 | return lib3270_print(hSession); |
758 | } | 762 | } |
763 | + | ||
764 | +const char * plugin::asc2ebc(unsigned char *str, size_t sz) | ||
765 | +{ | ||
766 | + return lib3270_asc2ebc(hSession,str,sz); | ||
767 | +} | ||
768 | + | ||
769 | +const char * plugin::ebc2asc(unsigned char *str, size_t sz) | ||
770 | +{ | ||
771 | + return lib3270_ebc2asc(hSession,str,sz); | ||
772 | +} | ||
773 | + |
src/plugins/rx3270/rx3270.h
@@ -85,6 +85,8 @@ | @@ -85,6 +85,8 @@ | ||
85 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt); | 85 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt); |
86 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt); | 86 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt); |
87 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270CloseApplication); | 87 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270CloseApplication); |
88 | + REXX_TYPED_ROUTINE_PROTOTYPE(ebc2asc); | ||
89 | + REXX_TYPED_ROUTINE_PROTOTYPE(asc2ebc); | ||
88 | 90 | ||
89 | REXX_METHOD_PROTOTYPE(rx3270_method_version); | 91 | REXX_METHOD_PROTOTYPE(rx3270_method_version); |
90 | REXX_METHOD_PROTOTYPE(rx3270_method_revision); | 92 | REXX_METHOD_PROTOTYPE(rx3270_method_revision); |
src/plugins/rx3270/rxapimain.cc
@@ -113,6 +113,8 @@ RexxRoutineEntry rx3270_functions[] = | @@ -113,6 +113,8 @@ RexxRoutineEntry rx3270_functions[] = | ||
113 | REXX_TYPED_ROUTINE(rx3270queryStringAt, rx3270queryStringAt), | 113 | REXX_TYPED_ROUTINE(rx3270queryStringAt, rx3270queryStringAt), |
114 | REXX_TYPED_ROUTINE(rx3270SetStringAt, rx3270SetStringAt), | 114 | REXX_TYPED_ROUTINE(rx3270SetStringAt, rx3270SetStringAt), |
115 | REXX_TYPED_ROUTINE(rx3270CloseApplication, rx3270CloseApplication), | 115 | REXX_TYPED_ROUTINE(rx3270CloseApplication, rx3270CloseApplication), |
116 | + REXX_TYPED_ROUTINE(ebc2asc, ebc2asc), | ||
117 | + REXX_TYPED_ROUTINE(asc2ebc, asc2ebc), | ||
116 | 118 | ||
117 | 119 | ||
118 | // rx3270Popup | 120 | // rx3270Popup |
src/plugins/rx3270/typed_routines.cc
@@ -217,3 +217,51 @@ RexxRoutine0(int, rx3270CloseApplication) | @@ -217,3 +217,51 @@ RexxRoutine0(int, rx3270CloseApplication) | ||
217 | { | 217 | { |
218 | return session::get_default()->quit(); | 218 | return session::get_default()->quit(); |
219 | } | 219 | } |
220 | + | ||
221 | + | ||
222 | +RexxRoutine2(RexxStringObject, asc2ebc, CSTRING, str, OPTIONAL_int, sz) | ||
223 | +{ | ||
224 | + try | ||
225 | + { | ||
226 | + if(sz < 1) | ||
227 | + sz = strlen(str); | ||
228 | + | ||
229 | + if(sz) | ||
230 | + { | ||
231 | + char buffer[sz+1]; | ||
232 | + memcpy(buffer,str,sz); | ||
233 | + buffer[sz] = 0; | ||
234 | + return context->String((CSTRING) session::get_default()->asc2ebc((unsigned char *)buffer,sz)); | ||
235 | + } | ||
236 | + } | ||
237 | + catch(std::exception &e) | ||
238 | + { | ||
239 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
240 | + } | ||
241 | + | ||
242 | + return context->String(""); | ||
243 | +} | ||
244 | + | ||
245 | +RexxRoutine2(RexxStringObject, ebc2asc, CSTRING, str, OPTIONAL_int, sz) | ||
246 | +{ | ||
247 | + try | ||
248 | + { | ||
249 | + if(sz < 1) | ||
250 | + sz = strlen(str); | ||
251 | + | ||
252 | + if(sz) | ||
253 | + { | ||
254 | + char buffer[sz+1]; | ||
255 | + memcpy(buffer,str,sz); | ||
256 | + buffer[sz] = 0; | ||
257 | + return context->String((CSTRING) session::get_default()->ebc2asc((unsigned char *)buffer,sz)); | ||
258 | + } | ||
259 | + } | ||
260 | + catch(std::exception &e) | ||
261 | + { | ||
262 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
263 | + } | ||
264 | + | ||
265 | + return context->String(""); | ||
266 | +} | ||
267 | + |