Commit 8de44186c475cfc1aef31d4b68600048c68d4ce7
1 parent
e815434f
Exists in
master
and in
3 other branches
Updating return codes.
Showing
8 changed files
with
28 additions
and
969 deletions
Show diff stats
src/lib3270/actions.c
@@ -68,6 +68,10 @@ | @@ -68,6 +68,10 @@ | ||
68 | /** | 68 | /** |
69 | * @brief Launch an action by name. | 69 | * @brief Launch an action by name. |
70 | * | 70 | * |
71 | + * @param name Name of the action to launch. | ||
72 | + * | ||
73 | + * @return 0 if ok, error code if not (sets errno). | ||
74 | + * | ||
71 | */ | 75 | */ |
72 | LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | 76 | LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) |
73 | { | 77 | { |
@@ -87,7 +91,6 @@ LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | @@ -87,7 +91,6 @@ LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | ||
87 | } | 91 | } |
88 | 92 | ||
89 | lib3270_trace_event(hSession,"Unknown action %s\n",name); | 93 | lib3270_trace_event(hSession,"Unknown action %s\n",name); |
90 | - errno = ENOENT; | ||
91 | - return -1; | 94 | + return errno = ENOENT; |
92 | 95 | ||
93 | } | 96 | } |
src/lib3270/bounds.c
@@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
42 | * @param start return location for start of selection, as a character offset. | 42 | * @param start return location for start of selection, as a character offset. |
43 | * @param end return location for end of selection, as a character offset. | 43 | * @param end return location for end of selection, as a character offset. |
44 | * | 44 | * |
45 | - * @return -1 if invalid or not connected (sets errno). | 45 | + * @return Non zero if invalid or not connected (sets errno). |
46 | * | 46 | * |
47 | */ | 47 | */ |
48 | LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *hSession, int baddr, int *start, int *end) | 48 | LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *hSession, int baddr, int *start, int *end) |
@@ -52,7 +52,7 @@ LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *hSession, int baddr, int *sta | @@ -52,7 +52,7 @@ LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *hSession, int baddr, int *sta | ||
52 | first = lib3270_field_addr(hSession,baddr); | 52 | first = lib3270_field_addr(hSession,baddr); |
53 | 53 | ||
54 | if(first < 0) | 54 | if(first < 0) |
55 | - return -1; | 55 | + return errno = (errno == 0 ? EINVAL : errno); |
56 | 56 | ||
57 | first++; | 57 | first++; |
58 | 58 |
src/lib3270/charset.c
@@ -132,48 +132,6 @@ static const unsigned short asc2ebc0[256] = | @@ -132,48 +132,6 @@ static const unsigned short asc2ebc0[256] = | ||
132 | /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf | 132 | /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf |
133 | }; | 133 | }; |
134 | 134 | ||
135 | -/* | ||
136 | -static const unsigned short ft2asc[256] = | ||
137 | -{ | ||
138 | - 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, | ||
139 | - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, | ||
140 | - 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, | ||
141 | - 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, | ||
142 | - 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, | ||
143 | - 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0xa2,0x5c,0x7c,0xac,0x5f, | ||
144 | - 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, | ||
145 | - 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0xa6,0x7d,0x7e,0x7f, | ||
146 | - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, | ||
147 | - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0xf7, | ||
148 | - 0xa0,0xe2,0xe4,0xe0,0xe1,0xe3,0xe5,0xe7,0xf1,0xe9,0xea,0xeb,0xe8,0xed,0xee,0xef, | ||
149 | - 0xec,0xdf,0xc2,0xc4,0xc0,0xc1,0xc3,0xc5,0xc7,0xd1,0xf8,0xc9,0xca,0xcb,0xc8,0xcd, | ||
150 | - 0xce,0xcf,0xcc,0xd8,0xab,0xbb,0xf0,0xfd,0xfe,0xb1,0xb0,0xaa,0xba,0xe6,0xb8,0xc6, | ||
151 | - 0xa4,0xb5,0xa1,0xbf,0xd0,0xdd,0xde,0xae,0x5e,0xa3,0xa5,0xb7,0xa9,0xa7,0xb6,0xbc, | ||
152 | - 0xbd,0xbe,0x5b,0x5d,0xaf,0xa8,0xb4,0xd7,0xad,0xf4,0xf6,0xf2,0xf3,0xf5,0xb9,0xfb, | ||
153 | - 0xfc,0xf9,0xfa,0xff,0xb2,0xd4,0xd6,0xd2,0xd3,0xd5,0xb3,0xdb,0xdc,0xd9,0xda,0xff | ||
154 | -}; | ||
155 | - | ||
156 | -const unsigned short asc2ft[256] = | ||
157 | -{ | ||
158 | - 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, | ||
159 | - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, | ||
160 | - 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, | ||
161 | - 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, | ||
162 | - 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, | ||
163 | - 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0xe2,0x5c,0xe3,0xd8,0x5f, | ||
164 | - 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, | ||
165 | - 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x5d,0x7d,0x7e,0x7f, | ||
166 | - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, | ||
167 | - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x00, | ||
168 | - 0xa0,0xd2,0x5b,0xd9,0xd0,0xda,0x7c,0xdd,0xe5,0xdc,0xcb,0xc4,0x5e,0xe8,0xd7,0xe4, | ||
169 | - 0xca,0xc9,0xf4,0xfa,0xe6,0xd1,0xde,0xdb,0xce,0xee,0xcc,0xc5,0xdf,0xe0,0xe1,0xd3, | ||
170 | - 0xb4,0xb5,0xb2,0xb6,0xb3,0xb7,0xcf,0xb8,0xbe,0xbb,0xbc,0xbd,0xc2,0xbf,0xc0,0xc1, | ||
171 | - 0xd4,0xb9,0xf7,0xf8,0xf5,0xf9,0xf6,0xe7,0xc3,0xfd,0xfe,0xfb,0xfc,0xd5,0xd6,0xb1, | ||
172 | - 0xa3,0xa4,0xa1,0xa5,0xa2,0xa6,0xcd,0xa7,0xac,0xa9,0xaa,0xab,0xb0,0xad,0xae,0xaf, | ||
173 | - 0xc6,0xa8,0xeb,0xec,0xe9,0xed,0xea,0x9f,0xba,0xf1,0xf2,0xef,0xf0,0xc7,0xc8,0xf3 | ||
174 | -}; | ||
175 | -*/ | ||
176 | - | ||
177 | static const unsigned short asc2uc[UT_SIZE] = | 135 | static const unsigned short asc2uc[UT_SIZE] = |
178 | { | 136 | { |
179 | /*40*/ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, | 137 | /*40*/ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, |
@@ -283,13 +241,6 @@ LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, co | @@ -283,13 +241,6 @@ LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, co | ||
283 | 241 | ||
284 | copy_charset(asc2uc,hSession->charset.asc2uc); | 242 | copy_charset(asc2uc,hSession->charset.asc2uc); |
285 | 243 | ||
286 | -/* | ||
287 | -#if defined(X3270_FT) | ||
288 | - memcpy(hSession->charset.ft2asc, ft2asc, sizeof(hSession->charset.ft2asc)); | ||
289 | - memcpy(hSession->charset.asc2ft, asc2ft, sizeof(hSession->charset.asc2ft)); | ||
290 | -#endif | ||
291 | -*/ | ||
292 | - | ||
293 | } | 244 | } |
294 | 245 | ||
295 | LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) | 246 | LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) |
@@ -479,434 +430,8 @@ LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsi | @@ -479,434 +430,8 @@ LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsi | ||
479 | 430 | ||
480 | if (iso <= 0xff) | 431 | if (iso <= 0xff) |
481 | { | 432 | { |
482 | -//#if defined(X3270_FT) | ||
483 | -// unsigned char aa; | ||
484 | -//#endif | ||
485 | - | ||
486 | if (scope == BOTH || scope == CS_ONLY) | 433 | if (scope == BOTH || scope == CS_ONLY) |
487 | { | 434 | { |
488 | - /* | ||
489 | - if (iso <= 0xff) | ||
490 | - { | ||
491 | - cg = hSession->charset.asc2cg[iso]; | ||
492 | - | ||
493 | - if (hSession->charset.cg2asc[cg] == iso || iso == 0) | ||
494 | - { | ||
495 | - // well-defined | ||
496 | - hSession->charset.ebc2cg[ebc] = cg; | ||
497 | - if (!one_way) | ||
498 | - hSession->charset.cg2ebc[cg] = ebc; | ||
499 | - } | ||
500 | - else | ||
501 | - { | ||
502 | - // into a hole | ||
503 | - hSession->charset.ebc2cg[ebc] = CG_boxsolid; | ||
504 | - } | ||
505 | - } | ||
506 | - */ | ||
507 | - | ||
508 | - if (ebc > 0x40) | ||
509 | - { | ||
510 | - hSession->charset.ebc2asc[ebc] = iso; | ||
511 | - if (!one_way) | ||
512 | - hSession->charset.asc2ebc[iso] = ebc; | ||
513 | - } | ||
514 | - } | ||
515 | - | ||
516 | -/* | ||
517 | -#if defined(X3270_FT) | ||
518 | - if (iso <= 0xff && ebc > 0x40) | ||
519 | - { | ||
520 | - // Change the file transfer translation table. | ||
521 | - if (scope == BOTH) | ||
522 | - { | ||
523 | - // | ||
524 | - // We have an alternate mapping of an EBCDIC | ||
525 | - // code to an ASCII code. Modify the existing | ||
526 | - // ASCII(ft)-to-ASCII(desired) maps. | ||
527 | - // | ||
528 | - // This is done by figuring out which ASCII | ||
529 | - // code the host usually translates the given | ||
530 | - // EBCDIC code to (asc2ft0[ebc2asc0[ebc]]). | ||
531 | - // Now we want to translate that code to the | ||
532 | - // given ISO code, and vice-versa. | ||
533 | - // | ||
534 | - aa = asc2ft[ebc2asc0[ebc]]; | ||
535 | - if (aa != ' ') | ||
536 | - { | ||
537 | - hSession->charset.ft2asc[aa] = iso; | ||
538 | - hSession->charset.asc2ft[iso] = aa; | ||
539 | - } | ||
540 | - } | ||
541 | - else if (scope == FT_ONLY) | ||
542 | - { | ||
543 | - // | ||
544 | - // We have a map of how the host translates | ||
545 | - // the given EBCDIC code to an ASCII code. | ||
546 | - // Generate the translation between that code | ||
547 | - // and the ISO code that we would normally | ||
548 | - // use to display that EBCDIC code. | ||
549 | - // | ||
550 | - hSession->charset.ft2asc[iso] = hSession->charset.ebc2asc[ebc]; | ||
551 | - hSession->charset.asc2ft[hSession->charset.ebc2asc[ebc]] = iso; | ||
552 | - } | ||
553 | - } | ||
554 | -#endif | ||
555 | -*/ | ||
556 | - } | ||
557 | -} | ||
558 | - | ||
559 | - | ||
560 | -/*ISO-8859-1 | ||
561 | - | ||
562 | -#include "resources.h" | ||
563 | -// #include "appres.h" | ||
564 | -#include "cg.h" | ||
565 | - | ||
566 | -#include "charsetc.h" | ||
567 | -#include "kybdc.h" | ||
568 | -#include "popupsc.h" | ||
569 | - | ||
570 | -#ifndef ANDROID | ||
571 | - #include <stdlib.h> | ||
572 | -#endif // !ANDROID | ||
573 | - | ||
574 | -#include "tablesc.h" | ||
575 | -#include "utf8c.h" | ||
576 | -#include "utilc.h" | ||
577 | -#include "widec.h" | ||
578 | -#include "X11keysym.h" | ||
579 | - | ||
580 | -#include <errno.h> | ||
581 | - | ||
582 | -#define EURO_SUFFIX "-euro" | ||
583 | -#define ES_SIZE (sizeof(EURO_SUFFIX) - 1) | ||
584 | - | ||
585 | -// Globals. | ||
586 | -const char *default_display_charset = "3270cg-1a,3270cg-1,iso8859-1"; | ||
587 | - | ||
588 | -// Statics. | ||
589 | -static enum cs_result resource_charset(H3270 *hSession, const char *csname, char *cs, char *ftcs); | ||
590 | - | ||
591 | -typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; | ||
592 | - | ||
593 | -static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spec, remap_scope scope, int *ne); | ||
594 | -static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scope scope,Boolean one_way); | ||
595 | - | ||
596 | -#if defined(DEBUG_CHARSET) | ||
597 | -static enum cs_result check_charset(void); | ||
598 | -static char *char_if_ascii7(unsigned long l); | ||
599 | -#endif | ||
600 | - | ||
601 | -static void set_cgcsgids(H3270 *hSession, const char *spec); | ||
602 | -static int set_cgcsgid(char *spec, unsigned long *idp); | ||
603 | - | ||
604 | -static KeySym StringToKeysym(char *s); | ||
605 | - | ||
606 | -struct charset_buffer | ||
607 | -{ | ||
608 | - unsigned char ebc2cg[256]; | ||
609 | - unsigned char cg2ebc[256]; | ||
610 | - unsigned char ebc2asc[256]; | ||
611 | - unsigned char asc2ebc[256]; | ||
612 | - | ||
613 | - #if defined(X3270_FT) | ||
614 | - unsigned char ft2asc[256]; | ||
615 | - unsigned char asc2ft[256]; | ||
616 | - #endif | ||
617 | -}; | ||
618 | - | ||
619 | - | ||
620 | -static void save_charset(H3270 *hSession, struct charset_buffer *save) | ||
621 | -{ | ||
622 | - (void) memcpy((char *)save->ebc2cg, (char *) hSession->charset.ebc2cg, 256); | ||
623 | - (void) memcpy((char *)save->cg2ebc, (char *) hSession->charset.cg2ebc, 256); | ||
624 | - (void) memcpy((char *)save->ebc2asc, (char *) hSession->charset.ebc2asc, 256); | ||
625 | - (void) memcpy((char *)save->asc2ebc, (char *) hSession->charset.asc2ebc, 256); | ||
626 | -#if defined(X3270_FT) | ||
627 | - (void) memcpy((char *)save->ft2asc, (char *) hSession->charset.ft2asc, 256); | ||
628 | - (void) memcpy((char *)save->asc2ft, (char *) hSession->charset.asc2ft, 256); | ||
629 | -#endif | ||
630 | -} | ||
631 | - | ||
632 | -static void restore_charset(H3270 *hSession, struct charset_buffer *save) | ||
633 | -{ | ||
634 | - (void) memcpy((char *)hSession->charset.ebc2cg, (char *)save->ebc2cg, 256); | ||
635 | - (void) memcpy((char *)hSession->charset.cg2ebc, (char *)save->cg2ebc, 256); | ||
636 | - (void) memcpy((char *)hSession->charset.ebc2asc, (char *)save->ebc2asc, 256); | ||
637 | - (void) memcpy((char *)hSession->charset.asc2ebc, (char *)save->asc2ebc, 256); | ||
638 | -#if defined(X3270_FT) | ||
639 | - (void) memcpy((char *)hSession->charset.ft2asc, (char *)save->ft2asc, 256); | ||
640 | - (void) memcpy((char *)hSession->charset.asc2ft, (char *)save->asc2ft, 256); | ||
641 | -#endif | ||
642 | -} | ||
643 | - | ||
644 | -// | ||
645 | -// Change character sets. | ||
646 | -// | ||
647 | -enum cs_result charset_init(H3270 *hSession, const char *csname) | ||
648 | -{ | ||
649 | - enum cs_result rc; | ||
650 | - char *ccs, *cftcs; | ||
651 | - const char *ak; | ||
652 | - struct charset_buffer save; | ||
653 | - | ||
654 | - // Do nothing, successfully. | ||
655 | - if (csname == CN || !strcasecmp(csname, "us")) | ||
656 | - { | ||
657 | - charset_defaults(hSession); | ||
658 | - set_cgcsgids(hSession,CN); | ||
659 | - set_display_charset(hSession, "ISO-8859-1"); | ||
660 | - return CS_OKAY; | ||
661 | - } | ||
662 | - | ||
663 | - // Figure out if it's already in a resource or in a file. | ||
664 | -#ifdef ANDROID | ||
665 | - ccs = strdup("0xad: [ \n 0xba: Yacute \n0xbd: ] \n 0xbb: diaeresis \n"); | ||
666 | -#else | ||
667 | - ccs = lib3270_get_resource_string(hSession,"charset", csname, NULL); | ||
668 | -#endif | ||
669 | - if (!ccs) | ||
670 | - return CS_NOTFOUND; | ||
671 | - | ||
672 | - // Grab the File Transfer character set. | ||
673 | - cftcs = lib3270_get_resource_string(hSession,"ftCharset",csname,NULL); | ||
674 | - | ||
675 | - // Save the current definitions, and start over with the defaults. | ||
676 | - save_charset(hSession,&save); | ||
677 | - charset_defaults(hSession); | ||
678 | - | ||
679 | - // Check for auto-keymap. | ||
680 | - ak = lib3270_get_resource_string(hSession,"autoKeymap", csname, NULL); | ||
681 | - if (ak != NULL) | ||
682 | - hSession->auto_keymap = strcasecmp(ak, "true") ? 0 : 1; | ||
683 | - else | ||
684 | - hSession->auto_keymap = 0; | ||
685 | - | ||
686 | - // Interpret them. | ||
687 | - rc = resource_charset(hSession,csname, ccs, cftcs); | ||
688 | - | ||
689 | - // Free them. | ||
690 | - lib3270_free(ccs); | ||
691 | - lib3270_free(cftcs); | ||
692 | - | ||
693 | -#if defined(DEBUG_CHARSET) | ||
694 | - if (rc == CS_OKAY) | ||
695 | - rc = check_charset(); | ||
696 | -#endif | ||
697 | - | ||
698 | - if (rc != CS_OKAY) | ||
699 | - restore_charset(hSession,&save); | ||
700 | - | ||
701 | - return rc; | ||
702 | -} | ||
703 | - | ||
704 | -// | ||
705 | -// Set a CGCSGID. Return 0 for success, -1 for failure. | ||
706 | -// | ||
707 | -static int set_cgcsgid(char *spec, unsigned long *r) | ||
708 | -{ | ||
709 | - unsigned long cp; | ||
710 | - char *ptr; | ||
711 | - | ||
712 | - if (spec != CN && | ||
713 | - (cp = strtoul(spec, &ptr, 0)) && | ||
714 | - ptr != spec && | ||
715 | - *ptr == '\0') { | ||
716 | - if (!(cp & ~0xffffL)) | ||
717 | - *r = LIB3270_DEFAULT_CGEN | cp; | ||
718 | - else | ||
719 | - *r = cp; | ||
720 | - return 0; | ||
721 | - } else | ||
722 | - return -1; | ||
723 | -} | ||
724 | - | ||
725 | -// Set the CGCSGIDs. | ||
726 | -static void set_cgcsgids(H3270 *hSession, const char *spec) | ||
727 | -{ | ||
728 | - int n_ids = 0; | ||
729 | - char *spec_copy; | ||
730 | - char *buf; | ||
731 | - char *token; | ||
732 | - | ||
733 | - if (spec != CN) { | ||
734 | - buf = spec_copy = NewString(spec); | ||
735 | - while (n_ids >= 0 && (token = strtok(buf, "+")) != CN) { | ||
736 | - unsigned long *idp = NULL; | ||
737 | - | ||
738 | - buf = CN; | ||
739 | - switch (n_ids) { | ||
740 | - case 0: | ||
741 | - idp = &hSession->cgcsgid; | ||
742 | - break; | ||
743 | -#if defined(X3270_DBCS) | ||
744 | - case 1: | ||
745 | - idp = &hSession->cgcsgid_dbcs; | ||
746 | - break; | ||
747 | -#endif | ||
748 | - default: | ||
749 | - popup_an_error(hSession,_( "Extra CGCSGID(s), ignoring" )); | ||
750 | - break; | ||
751 | - } | ||
752 | - if (idp == NULL) | ||
753 | - break; | ||
754 | - if (set_cgcsgid(token, idp) < 0) { | ||
755 | - popup_an_error(hSession,_( "Invalid CGCSGID '%s', ignoring" ),token); | ||
756 | - n_ids = -1; | ||
757 | - break; | ||
758 | - } | ||
759 | - n_ids++; | ||
760 | - } | ||
761 | - lib3270_free(spec_copy); | ||
762 | - if (n_ids > 0) | ||
763 | - return; | ||
764 | - } | ||
765 | - | ||
766 | - hSession->cgcsgid = LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET; | ||
767 | -#if defined(X3270_DBCS) | ||
768 | - hSession->cgcsgid_dbcs = 0L; | ||
769 | -#endif | ||
770 | -} | ||
771 | - | ||
772 | -// Define a charset from resources. | ||
773 | -static enum cs_result resource_charset(H3270 *hSession, const char *csname, char *cs, char *ftcs) | ||
774 | -{ | ||
775 | - enum cs_result rc; | ||
776 | - int ne = 0; | ||
777 | - char * rcs = CN; | ||
778 | - int n_rcs = 0; | ||
779 | - char * dcs; | ||
780 | - | ||
781 | - // Interpret the spec. | ||
782 | - rc = remap_chars(hSession, csname, cs, (ftcs == NULL)? BOTH: CS_ONLY, &ne); | ||
783 | - if (rc != CS_OKAY) | ||
784 | - return rc; | ||
785 | - if (ftcs != NULL) { | ||
786 | - rc = remap_chars(hSession, csname, ftcs, FT_ONLY, &ne); | ||
787 | - if (rc != CS_OKAY) | ||
788 | - return rc; | ||
789 | - } | ||
790 | - | ||
791 | - rcs = lib3270_get_resource_string(hSession,"displayCharset", csname, NULL); | ||
792 | - | ||
793 | - // Isolate the pieces. | ||
794 | - if (rcs != CN) | ||
795 | - { | ||
796 | - char *buf, *token; | ||
797 | - | ||
798 | - buf = rcs; | ||
799 | - while ((token = strtok(buf, "+")) != CN) | ||
800 | - { | ||
801 | - buf = CN; | ||
802 | - switch (n_rcs) | ||
803 | - { | ||
804 | - case 0: | ||
805 | -#if defined(X3270_DBCS) | ||
806 | - case 1: | ||
807 | -#endif | ||
808 | - break; | ||
809 | - default: | ||
810 | - popup_an_error(NULL,"Extra value(s) in displayCharset.%s, ignoring", csname); | ||
811 | - break; | ||
812 | - } | ||
813 | - n_rcs++; | ||
814 | - } | ||
815 | - } | ||
816 | - | ||
817 | - lib3270_free(rcs); | ||
818 | - | ||
819 | - // Set up the cgcsgid. | ||
820 | -// set_cgcsgids(get_fresource("%s.%s", "codepage", csname)); | ||
821 | - { | ||
822 | - char *ptr = lib3270_get_resource_string(hSession,"codepage", csname, NULL); | ||
823 | - set_cgcsgids(hSession,ptr); | ||
824 | - lib3270_free(ptr); | ||
825 | - } | ||
826 | - | ||
827 | -// dcs = get_fresource("%s.%s", "displayCharset", csname); | ||
828 | - dcs = lib3270_get_resource_string(hSession,"displayCharset", csname, NULL); | ||
829 | - | ||
830 | - if (dcs != NULL) | ||
831 | - set_display_charset(hSession,dcs); | ||
832 | - else | ||
833 | - set_display_charset(hSession,"ISO-8859-1"); | ||
834 | - | ||
835 | - lib3270_free(dcs); | ||
836 | - | ||
837 | - // Set up the character set name. | ||
838 | -// set_charset_name(csname); | ||
839 | - | ||
840 | - return CS_OKAY; | ||
841 | -} | ||
842 | - | ||
843 | -// | ||
844 | -// Map a keysym name or literal string into a character. | ||
845 | -//Returns NoSymbol if there is a problem. | ||
846 | -// | ||
847 | -static KeySym | ||
848 | -parse_keysym(char *s, Boolean extended) | ||
849 | -{ | ||
850 | - KeySym k; | ||
851 | - | ||
852 | - k = StringToKeysym(s); | ||
853 | - if (k == NoSymbol) { | ||
854 | - if (strlen(s) == 1) | ||
855 | - k = *s & 0xff; | ||
856 | - else if (s[0] == '0' && s[1] == 'x') { | ||
857 | - unsigned long l; | ||
858 | - char *ptr; | ||
859 | - | ||
860 | - l = strtoul(s, &ptr, 16); | ||
861 | - if (*ptr != '\0' || (l & ~0xffff)) | ||
862 | - return NoSymbol; | ||
863 | - return (KeySym)l; | ||
864 | - } else | ||
865 | - return NoSymbol; | ||
866 | - } | ||
867 | - if (k < ' ' || (!extended && k > 0xff)) | ||
868 | - return NoSymbol; | ||
869 | - else | ||
870 | - return k; | ||
871 | -} | ||
872 | - | ||
873 | -// Process a single character definition. | ||
874 | -static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) | ||
875 | -{ | ||
876 | - unsigned char cg; | ||
877 | - | ||
878 | - // Ignore mappings of EBCDIC control codes and the space character. | ||
879 | - if (ebc <= 0x40) | ||
880 | - return; | ||
881 | - | ||
882 | - // If they want to map to a NULL or a blank, make it a one-way blank. | ||
883 | - if (iso == 0x0) | ||
884 | - iso = 0x20; | ||
885 | - if (iso == 0x20) | ||
886 | - one_way = True; | ||
887 | - | ||
888 | - if (!hSession->auto_keymap || iso <= 0xff) { | ||
889 | -#if defined(X3270_FT) | ||
890 | - unsigned char aa; | ||
891 | -#endif | ||
892 | - | ||
893 | - if (scope == BOTH || scope == CS_ONLY) { | ||
894 | - if (iso <= 0xff) { | ||
895 | - cg = hSession->charset.asc2cg[iso]; | ||
896 | - | ||
897 | - if (hSession->charset.cg2asc[cg] == iso || iso == 0) | ||
898 | - { | ||
899 | - // well-defined | ||
900 | - hSession->charset.ebc2cg[ebc] = cg; | ||
901 | - if (!one_way) | ||
902 | - hSession->charset.cg2ebc[cg] = ebc; | ||
903 | - } | ||
904 | - else | ||
905 | - { | ||
906 | - // into a hole | ||
907 | - hSession->charset.ebc2cg[ebc] = CG_boxsolid; | ||
908 | - } | ||
909 | - } | ||
910 | if (ebc > 0x40) | 435 | if (ebc > 0x40) |
911 | { | 436 | { |
912 | hSession->charset.ebc2asc[ebc] = iso; | 437 | hSession->charset.ebc2asc[ebc] = iso; |
@@ -914,441 +439,9 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop | @@ -914,441 +439,9 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop | ||
914 | hSession->charset.asc2ebc[iso] = ebc; | 439 | hSession->charset.asc2ebc[iso] = ebc; |
915 | } | 440 | } |
916 | } | 441 | } |
917 | -#if defined(X3270_FT) | ||
918 | - if (iso <= 0xff && ebc > 0x40) { | ||
919 | - // Change the file transfer translation table. | ||
920 | - if (scope == BOTH) { | ||
921 | - // | ||
922 | - // We have an alternate mapping of an EBCDIC | ||
923 | - // code to an ASCII code. Modify the existing | ||
924 | - // ASCII(ft)-to-ASCII(desired) maps. | ||
925 | - // | ||
926 | - // This is done by figuring out which ASCII | ||
927 | - // code the host usually translates the given | ||
928 | - // EBCDIC code to (asc2ft0[ebc2asc0[ebc]]). | ||
929 | - // Now we want to translate that code to the | ||
930 | - // given ISO code, and vice-versa. | ||
931 | - // | ||
932 | - aa = asc2ft0[ebc2asc0[ebc]]; | ||
933 | - if (aa != ' ') { | ||
934 | - hSession->charset.ft2asc[aa] = iso; | ||
935 | - hSession->charset.asc2ft[iso] = aa; | ||
936 | - } | ||
937 | - } else if (scope == FT_ONLY) { | ||
938 | - // | ||
939 | - // We have a map of how the host translates | ||
940 | - // the given EBCDIC code to an ASCII code. | ||
941 | - // Generate the translation between that code | ||
942 | - // and the ISO code that we would normally | ||
943 | - // use to display that EBCDIC code. | ||
944 | - // | ||
945 | - hSession->charset.ft2asc[iso] = hSession->charset.ebc2asc[ebc]; | ||
946 | - hSession->charset.asc2ft[hSession->charset.ebc2asc[ebc]] = iso; | ||
947 | - } | ||
948 | - } | ||
949 | -#endif | ||
950 | - } else { | ||
951 | - // Auto-keymap. | ||
952 | - add_xk(iso, (KeySym)hSession->charset.ebc2asc[ebc]); | ||
953 | - } | ||
954 | -} | ||
955 | - | ||
956 | -// | ||
957 | -// Parse an EBCDIC character set map, a series of pairs of numeric EBCDIC codes and keysyms. | ||
958 | -// | ||
959 | -// If the keysym is in the range 1..255, it is a remapping of the EBCDIC code | ||
960 | -// for a standard Latin-1 graphic, and the CG-to-EBCDIC map will be modified | ||
961 | -// to match. | ||
962 | -// | ||
963 | -// Otherwise (keysym > 255), it is a definition for the EBCDIC code to use for | ||
964 | -// a multibyte keysym. This is intended for 8-bit fonts that with special | ||
965 | -// characters that replace certain standard Latin-1 graphics. The keysym | ||
966 | -// will be entered into the extended keysym translation table. | ||
967 | -// | ||
968 | -static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spec, remap_scope scope, int *ne) | ||
969 | -{ | ||
970 | - char *s; | ||
971 | - char *ebcs, *isos; | ||
972 | - unsigned char ebc; | ||
973 | - KeySym iso; | ||
974 | - int ns; | ||
975 | - enum cs_result rc = CS_OKAY; | ||
976 | - Boolean is_table = False; | ||
977 | - Boolean one_way = False; | ||
978 | - | ||
979 | - // Pick apart a copy of the spec. | ||
980 | - s = spec = NewString(spec); | ||
981 | - while (isspace(*s)) { | ||
982 | - s++; | ||
983 | - } | ||
984 | - if (!strncmp(s, "#table", 6)) { | ||
985 | - is_table = True; | ||
986 | - s += 6; | ||
987 | - } | ||
988 | - | ||
989 | - if (is_table) { | ||
990 | - int ebc = 0; | ||
991 | - char *tok; | ||
992 | - char *ptr; | ||
993 | - | ||
994 | - while ((tok = strtok(s, " \t\n")) != CN) { | ||
995 | - if (ebc >= 256) { | ||
996 | - popup_an_error(hSession,_( "Charset has more than 256 entries" )); | ||
997 | - rc = CS_BAD; | ||
998 | - break; | ||
999 | - } | ||
1000 | - if (tok[0] == '*') { | ||
1001 | - one_way = True; | ||
1002 | - tok++; | ||
1003 | - } else | ||
1004 | - one_way = False; | ||
1005 | - iso = strtoul(tok, &ptr, 0); | ||
1006 | - if (ptr == tok || *ptr != '\0' || iso > 256L) { | ||
1007 | - if (strlen(tok) == 1) | ||
1008 | - iso = tok[0] & 0xff; | ||
1009 | - else { | ||
1010 | - popup_an_error(hSession,_( "Invalid charset entry '%s' (#%d)" ),tok, ebc); | ||
1011 | - rc = CS_BAD; | ||
1012 | - break; | ||
1013 | - } | ||
1014 | - } | ||
1015 | - remap_one(hSession, ebc, iso, scope, one_way); | ||
1016 | - | ||
1017 | - ebc++; | ||
1018 | - s = CN; | ||
1019 | - } | ||
1020 | - if (ebc != 256) { | ||
1021 | - popup_an_error(NULL,_( "Charset has %d entries, need 256" ), ebc); | ||
1022 | - rc = CS_BAD; | ||
1023 | - } else { | ||
1024 | - // | ||
1025 | - // The entire EBCDIC-to-ASCII mapping has been defined. | ||
1026 | - // Make sure that any printable ASCII character that | ||
1027 | - // doesn't now map back onto itself is mapped onto an | ||
1028 | - // EBCDIC NUL. | ||
1029 | - // | ||
1030 | - int i; | ||
1031 | - | ||
1032 | - for (i = 0; i < 256; i++) { | ||
1033 | - if ((i & 0x7f) > 0x20 && i != 0x7f && | ||
1034 | - hSession->charset.asc2ebc[i] != 0 && | ||
1035 | - hSession->charset.ebc2asc[hSession->charset.asc2ebc[i]] != i) { | ||
1036 | - hSession->charset.asc2ebc[i] = 0; | ||
1037 | - } | ||
1038 | - } | ||
1039 | - } | ||
1040 | - } else { | ||
1041 | - while ((ns = split_dresource(&s, &ebcs, &isos))) { | ||
1042 | - char *ptr; | ||
1043 | - | ||
1044 | - (*ne)++; | ||
1045 | - if (ebcs[0] == '*') { | ||
1046 | - one_way = True; | ||
1047 | - ebcs++; | ||
1048 | - } else | ||
1049 | - one_way = False; | ||
1050 | - if (ns < 0 || | ||
1051 | - ((ebc = strtoul(ebcs, &ptr, 0)), | ||
1052 | - ptr == ebcs || *ptr != '\0') || | ||
1053 | - (iso = parse_keysym(isos, True)) == NoSymbol) { | ||
1054 | - popup_an_error(hSession,_( "Cannot parse %s \"%s\", entry %d" ), "charset", csname, *ne); | ||
1055 | - rc = CS_BAD; | ||
1056 | - break; | ||
1057 | - } | ||
1058 | - remap_one(hSession, ebc, iso, scope, one_way); | ||
1059 | - } | ||
1060 | - } | ||
1061 | - lib3270_free(spec); | ||
1062 | - return rc; | ||
1063 | -} | ||
1064 | - | ||
1065 | -#if defined(DEBUG_CHARSET) | ||
1066 | -static char * | ||
1067 | -char_if_ascii7(unsigned long l) | ||
1068 | -{ | ||
1069 | - static char buf[6]; | ||
1070 | 442 | ||
1071 | - if (((l & 0x7f) > ' ' && (l & 0x7f) < 0x7f) || l == 0xff) { | ||
1072 | - (void) sprintf(buf, " ('%c')", (char)l); | ||
1073 | - return buf; | ||
1074 | - } else | ||
1075 | - return ""; | ||
1076 | -} | ||
1077 | -#endif | ||
1078 | - | ||
1079 | - | ||
1080 | -#if defined(DEBUG_CHARSET) | ||
1081 | -// | ||
1082 | -// Verify that a character set is not ambiguous. | ||
1083 | -// (All this checks is that multiple EBCDIC codes map onto the same ISO code. | ||
1084 | -// Hmm. God, I find the CG stuff confusing.) | ||
1085 | -// | ||
1086 | -static enum cs_result | ||
1087 | -check_charset(void) | ||
1088 | -{ | ||
1089 | - unsigned long iso; | ||
1090 | - unsigned char ebc; | ||
1091 | - enum cs_result rc = CS_OKAY; | ||
1092 | - | ||
1093 | - for (iso = 1; iso <= 255; iso++) { | ||
1094 | - unsigned char multi[256]; | ||
1095 | - int n_multi = 0; | ||
1096 | - | ||
1097 | - if (iso == ' ') | ||
1098 | - continue; | ||
1099 | - | ||
1100 | - for (ebc = 0x41; ebc < 0xff; ebc++) { | ||
1101 | - if (cg2asc[ebc2cg[ebc]] == iso) { | ||
1102 | - multi[n_multi] = ebc; | ||
1103 | - n_multi++; | ||
1104 | - } | ||
1105 | - } | ||
1106 | - if (n_multi > 1) { | ||
1107 | - xs_warning("Display character 0x%02x%s has multiple " | ||
1108 | - "EBCDIC definitions: X'%02X', X'%02X'%s", | ||
1109 | - iso, char_if_ascii7(iso), | ||
1110 | - multi[0], multi[1], (n_multi > 2)? ", ...": ""); | ||
1111 | - rc = CS_BAD; | ||
1112 | - } | ||
1113 | } | 443 | } |
1114 | - return rc; | ||
1115 | } | 444 | } |
1116 | -#endif | ||
1117 | 445 | ||
1118 | -void set_display_charset(H3270 *session, const char *dcs) | ||
1119 | -{ | ||
1120 | - session->charset.display = strdup(dcs); | ||
1121 | -} | ||
1122 | - | ||
1123 | -static KeySym StringToKeysym(char *s) | ||
1124 | -{ | ||
1125 | - static struct | ||
1126 | - { | ||
1127 | - const char *name; | ||
1128 | - KeySym keysym; | ||
1129 | - } latin1[] = | ||
1130 | - { | ||
1131 | - { "space", XK_space }, | ||
1132 | - { "exclam", XK_exclam }, | ||
1133 | - { "quotedbl", XK_quotedbl }, | ||
1134 | - { "numbersign", XK_numbersign }, | ||
1135 | - { "dollar", XK_dollar }, | ||
1136 | - { "percent", XK_percent }, | ||
1137 | - { "ampersand", XK_ampersand }, | ||
1138 | - { "apostrophe", XK_apostrophe }, | ||
1139 | - { "quoteright", XK_quoteright }, | ||
1140 | - { "parenleft", XK_parenleft }, | ||
1141 | - { "parenright", XK_parenright }, | ||
1142 | - { "asterisk", XK_asterisk }, | ||
1143 | - { "plus", XK_plus }, | ||
1144 | - { "comma", XK_comma }, | ||
1145 | - { "minus", XK_minus }, | ||
1146 | - { "period", XK_period }, | ||
1147 | - { "slash", XK_slash }, | ||
1148 | - { "0", XK_0 }, | ||
1149 | - { "1", XK_1 }, | ||
1150 | - { "2", XK_2 }, | ||
1151 | - { "3", XK_3 }, | ||
1152 | - { "4", XK_4 }, | ||
1153 | - { "5", XK_5 }, | ||
1154 | - { "6", XK_6 }, | ||
1155 | - { "7", XK_7 }, | ||
1156 | - { "8", XK_8 }, | ||
1157 | - { "9", XK_9 }, | ||
1158 | - { "colon", XK_colon }, | ||
1159 | - { "semicolon", XK_semicolon }, | ||
1160 | - { "less", XK_less }, | ||
1161 | - { "equal", XK_equal }, | ||
1162 | - { "greater", XK_greater }, | ||
1163 | - { "question", XK_question }, | ||
1164 | - { "at", XK_at }, | ||
1165 | - { "A", XK_A }, | ||
1166 | - { "B", XK_B }, | ||
1167 | - { "C", XK_C }, | ||
1168 | - { "D", XK_D }, | ||
1169 | - { "E", XK_E }, | ||
1170 | - { "F", XK_F }, | ||
1171 | - { "G", XK_G }, | ||
1172 | - { "H", XK_H }, | ||
1173 | - { "I", XK_I }, | ||
1174 | - { "J", XK_J }, | ||
1175 | - { "K", XK_K }, | ||
1176 | - { "L", XK_L }, | ||
1177 | - { "M", XK_M }, | ||
1178 | - { "N", XK_N }, | ||
1179 | - { "O", XK_O }, | ||
1180 | - { "P", XK_P }, | ||
1181 | - { "Q", XK_Q }, | ||
1182 | - { "R", XK_R }, | ||
1183 | - { "S", XK_S }, | ||
1184 | - { "T", XK_T }, | ||
1185 | - { "U", XK_U }, | ||
1186 | - { "V", XK_V }, | ||
1187 | - { "W", XK_W }, | ||
1188 | - { "X", XK_X }, | ||
1189 | - { "Y", XK_Y }, | ||
1190 | - { "Z", XK_Z }, | ||
1191 | - { "bracketleft", XK_bracketleft }, | ||
1192 | - { "backslash", XK_backslash }, | ||
1193 | - { "bracketright", XK_bracketright }, | ||
1194 | - { "asciicircum", XK_asciicircum }, | ||
1195 | - { "underscore", XK_underscore }, | ||
1196 | - { "grave", XK_grave }, | ||
1197 | - { "quoteleft", XK_quoteleft }, | ||
1198 | - { "a", XK_a }, | ||
1199 | - { "b", XK_b }, | ||
1200 | - { "c", XK_c }, | ||
1201 | - { "d", XK_d }, | ||
1202 | - { "e", XK_e }, | ||
1203 | - { "f", XK_f }, | ||
1204 | - { "g", XK_g }, | ||
1205 | - { "h", XK_h }, | ||
1206 | - { "i", XK_i }, | ||
1207 | - { "j", XK_j }, | ||
1208 | - { "k", XK_k }, | ||
1209 | - { "l", XK_l }, | ||
1210 | - { "m", XK_m }, | ||
1211 | - { "n", XK_n }, | ||
1212 | - { "o", XK_o }, | ||
1213 | - { "p", XK_p }, | ||
1214 | - { "q", XK_q }, | ||
1215 | - { "r", XK_r }, | ||
1216 | - { "s", XK_s }, | ||
1217 | - { "t", XK_t }, | ||
1218 | - { "u", XK_u }, | ||
1219 | - { "v", XK_v }, | ||
1220 | - { "w", XK_w }, | ||
1221 | - { "x", XK_x }, | ||
1222 | - { "y", XK_y }, | ||
1223 | - { "z", XK_z }, | ||
1224 | - { "braceleft", XK_braceleft }, | ||
1225 | - { "bar", XK_bar }, | ||
1226 | - { "braceright", XK_braceright }, | ||
1227 | - { "asciitilde", XK_asciitilde }, | ||
1228 | - { "nobreakspace", XK_nobreakspace }, | ||
1229 | - { "exclamdown", XK_exclamdown }, | ||
1230 | - { "cent", XK_cent }, | ||
1231 | - { "sterling", XK_sterling }, | ||
1232 | - { "currency", XK_currency }, | ||
1233 | - { "yen", XK_yen }, | ||
1234 | - { "brokenbar", XK_brokenbar }, | ||
1235 | - { "section", XK_section }, | ||
1236 | - { "diaeresis", XK_diaeresis }, | ||
1237 | - { "copyright", XK_copyright }, | ||
1238 | - { "ordfeminine", XK_ordfeminine }, | ||
1239 | - { "guillemotleft", XK_guillemotleft }, | ||
1240 | - { "notsign", XK_notsign }, | ||
1241 | - { "hyphen", XK_hyphen }, | ||
1242 | - { "registered", XK_registered }, | ||
1243 | - { "macron", XK_macron }, | ||
1244 | - { "degree", XK_degree }, | ||
1245 | - { "plusminus", XK_plusminus }, | ||
1246 | - { "twosuperior", XK_twosuperior }, | ||
1247 | - { "threesuperior", XK_threesuperior }, | ||
1248 | - { "acute", XK_acute }, | ||
1249 | - { "mu", XK_mu }, | ||
1250 | - { "paragraph", XK_paragraph }, | ||
1251 | - { "periodcentered", XK_periodcentered }, | ||
1252 | - { "cedilla", XK_cedilla }, | ||
1253 | - { "onesuperior", XK_onesuperior }, | ||
1254 | - { "masculine", XK_masculine }, | ||
1255 | - { "guillemotright", XK_guillemotright }, | ||
1256 | - { "onequarter", XK_onequarter }, | ||
1257 | - { "onehalf", XK_onehalf }, | ||
1258 | - { "threequarters", XK_threequarters }, | ||
1259 | - { "questiondown", XK_questiondown }, | ||
1260 | - { "Agrave", XK_Agrave }, | ||
1261 | - { "Aacute", XK_Aacute }, | ||
1262 | - { "Acircumflex", XK_Acircumflex }, | ||
1263 | - { "Atilde", XK_Atilde }, | ||
1264 | - { "Adiaeresis", XK_Adiaeresis }, | ||
1265 | - { "Aring", XK_Aring }, | ||
1266 | - { "AE", XK_AE }, | ||
1267 | - { "Ccedilla", XK_Ccedilla }, | ||
1268 | - { "Egrave", XK_Egrave }, | ||
1269 | - { "Eacute", XK_Eacute }, | ||
1270 | - { "Ecircumflex", XK_Ecircumflex }, | ||
1271 | - { "Ediaeresis", XK_Ediaeresis }, | ||
1272 | - { "Igrave", XK_Igrave }, | ||
1273 | - { "Iacute", XK_Iacute }, | ||
1274 | - { "Icircumflex", XK_Icircumflex }, | ||
1275 | - { "Idiaeresis", XK_Idiaeresis }, | ||
1276 | - { "ETH", XK_ETH }, | ||
1277 | - { "Eth", XK_Eth }, | ||
1278 | - { "Ntilde", XK_Ntilde }, | ||
1279 | - { "Ograve", XK_Ograve }, | ||
1280 | - { "Oacute", XK_Oacute }, | ||
1281 | - { "Ocircumflex", XK_Ocircumflex }, | ||
1282 | - { "Otilde", XK_Otilde }, | ||
1283 | - { "Odiaeresis", XK_Odiaeresis }, | ||
1284 | - { "multiply", XK_multiply }, | ||
1285 | - { "Ooblique", XK_Ooblique }, | ||
1286 | - { "Ugrave", XK_Ugrave }, | ||
1287 | - { "Uacute", XK_Uacute }, | ||
1288 | - { "Ucircumflex", XK_Ucircumflex }, | ||
1289 | - { "Udiaeresis", XK_Udiaeresis }, | ||
1290 | - { "Yacute", XK_Yacute }, | ||
1291 | - { "THORN", XK_THORN }, | ||
1292 | - { "Thorn", XK_Thorn }, | ||
1293 | - { "ssharp", XK_ssharp }, | ||
1294 | - { "agrave", XK_agrave }, | ||
1295 | - { "aacute", XK_aacute }, | ||
1296 | - { "acircumflex", XK_acircumflex }, | ||
1297 | - { "atilde", XK_atilde }, | ||
1298 | - { "adiaeresis", XK_adiaeresis }, | ||
1299 | - { "aring", XK_aring }, | ||
1300 | - { "ae", XK_ae }, | ||
1301 | - { "ccedilla", XK_ccedilla }, | ||
1302 | - { "egrave", XK_egrave }, | ||
1303 | - { "eacute", XK_eacute }, | ||
1304 | - { "ecircumflex", XK_ecircumflex }, | ||
1305 | - { "ediaeresis", XK_ediaeresis }, | ||
1306 | - { "igrave", XK_igrave }, | ||
1307 | - { "iacute", XK_iacute }, | ||
1308 | - { "icircumflex", XK_icircumflex }, | ||
1309 | - { "idiaeresis", XK_idiaeresis }, | ||
1310 | - { "eth", XK_eth }, | ||
1311 | - { "ntilde", XK_ntilde }, | ||
1312 | - { "ograve", XK_ograve }, | ||
1313 | - { "oacute", XK_oacute }, | ||
1314 | - { "ocircumflex", XK_ocircumflex }, | ||
1315 | - { "otilde", XK_otilde }, | ||
1316 | - { "odiaeresis", XK_odiaeresis }, | ||
1317 | - { "division", XK_division }, | ||
1318 | - { "oslash", XK_oslash }, | ||
1319 | - { "ugrave", XK_ugrave }, | ||
1320 | - { "uacute", XK_uacute }, | ||
1321 | - { "ucircumflex", XK_ucircumflex }, | ||
1322 | - { "udiaeresis", XK_udiaeresis }, | ||
1323 | - { "yacute", XK_yacute }, | ||
1324 | - { "thorn", XK_thorn }, | ||
1325 | - { "ydiaeresis", XK_ydiaeresis }, | ||
1326 | - | ||
1327 | - // The following are, umm, hacks to allow symbolic names for | ||
1328 | - // control codes. | ||
1329 | - #if !defined(_WIN32) | ||
1330 | - { "BackSpace", 0x08 }, | ||
1331 | - { "Tab", 0x09 }, | ||
1332 | - { "Linefeed", 0x0a }, | ||
1333 | - { "Return", 0x0d }, | ||
1334 | - { "Escape", 0x1b }, | ||
1335 | - { "Delete", 0x7f }, | ||
1336 | - #endif | ||
1337 | - | ||
1338 | - { (char *)NULL, NoSymbol } | ||
1339 | - }; | ||
1340 | - | ||
1341 | - int i; | ||
1342 | - | ||
1343 | - if (strlen(s) == 1 && (*(unsigned char *)s & 0x7f) > ' ') | ||
1344 | - return (KeySym)*(unsigned char *)s; | ||
1345 | - for (i = 0; latin1[i].name != (char *)NULL; i++) { | ||
1346 | - if (!strcmp(s, latin1[i].name)) | ||
1347 | - return latin1[i].keysym; | ||
1348 | - } | ||
1349 | - return NoSymbol; | ||
1350 | -} | ||
1351 | - | ||
1352 | -*/ | ||
1353 | 446 | ||
1354 | 447 |
src/lib3270/ctlr.c
@@ -433,7 +433,7 @@ LIB3270_EXPORT int lib3270_get_field_start(H3270 *hSession, int baddr) | @@ -433,7 +433,7 @@ LIB3270_EXPORT int lib3270_get_field_start(H3270 *hSession, int baddr) | ||
433 | CHECK_SESSION_HANDLE(hSession); | 433 | CHECK_SESSION_HANDLE(hSession); |
434 | 434 | ||
435 | if (!hSession->formatted) | 435 | if (!hSession->formatted) |
436 | - return -1; | 436 | + return errno = ENOTCONN; |
437 | 437 | ||
438 | if(baddr < 0) | 438 | if(baddr < 0) |
439 | baddr = hSession->cursor_addr; | 439 | baddr = hSession->cursor_addr; |
@@ -459,7 +459,7 @@ LIB3270_EXPORT int lib3270_get_field_len(H3270 *hSession, int baddr) | @@ -459,7 +459,7 @@ LIB3270_EXPORT int lib3270_get_field_len(H3270 *hSession, int baddr) | ||
459 | CHECK_SESSION_HANDLE(hSession); | 459 | CHECK_SESSION_HANDLE(hSession); |
460 | 460 | ||
461 | if (!hSession->formatted) | 461 | if (!hSession->formatted) |
462 | - return -1; | 462 | + return errno = ENOTCONN; |
463 | 463 | ||
464 | if(baddr < 0) | 464 | if(baddr < 0) |
465 | baddr = hSession->cursor_addr; | 465 | baddr = hSession->cursor_addr; |
@@ -498,10 +498,7 @@ LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) | @@ -498,10 +498,7 @@ LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) | ||
498 | FAIL_IF_NOT_ONLINE(hSession); | 498 | FAIL_IF_NOT_ONLINE(hSession); |
499 | 499 | ||
500 | if(!hSession->formatted) | 500 | if(!hSession->formatted) |
501 | - { | ||
502 | - errno = ENOTCONN; | ||
503 | - return -1; | ||
504 | - } | 501 | + return errno = ENOTCONN; |
505 | 502 | ||
506 | sbaddr = baddr; | 503 | sbaddr = baddr; |
507 | do | 504 | do |
@@ -522,10 +519,7 @@ LIB3270_EXPORT int lib3270_field_attribute(H3270 *hSession, int baddr) | @@ -522,10 +519,7 @@ LIB3270_EXPORT int lib3270_field_attribute(H3270 *hSession, int baddr) | ||
522 | FAIL_IF_NOT_ONLINE(hSession); | 519 | FAIL_IF_NOT_ONLINE(hSession); |
523 | 520 | ||
524 | if(!hSession->formatted) | 521 | if(!hSession->formatted) |
525 | - { | ||
526 | - errno = ENOTCONN; | ||
527 | - return -1; | ||
528 | - } | 522 | + return errno = ENOTCONN; |
529 | 523 | ||
530 | sbaddr = baddr; | 524 | sbaddr = baddr; |
531 | do | 525 | do |
@@ -571,8 +565,7 @@ int lib3270_field_length(H3270 *hSession, int baddr) | @@ -571,8 +565,7 @@ int lib3270_field_length(H3270 *hSession, int baddr) | ||
571 | width++; | 565 | width++; |
572 | } while (addr != saddr); | 566 | } while (addr != saddr); |
573 | 567 | ||
574 | - errno = EINVAL; | ||
575 | - return -1; | 568 | + return errno = EINVAL; |
576 | 569 | ||
577 | } | 570 | } |
578 | 571 | ||
@@ -601,10 +594,7 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0) | @@ -601,10 +594,7 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0) | ||
601 | FAIL_IF_NOT_ONLINE(hSession); | 594 | FAIL_IF_NOT_ONLINE(hSession); |
602 | 595 | ||
603 | if(!hSession->formatted) | 596 | if(!hSession->formatted) |
604 | - { | ||
605 | - errno = ENOTCONN; | ||
606 | - return -1; | ||
607 | - } | 597 | + return errno = ENOTCONN; |
608 | 598 | ||
609 | if(baddr0 < 0) | 599 | if(baddr0 < 0) |
610 | baddr0 = hSession->cursor_addr; | 600 | baddr0 = hSession->cursor_addr; |
src/lib3270/kybd.c
@@ -1751,8 +1751,7 @@ LIB3270_EXPORT int lib3270_enter(H3270 *hSession) | @@ -1751,8 +1751,7 @@ LIB3270_EXPORT int lib3270_enter(H3270 *hSession) | ||
1751 | 1751 | ||
1752 | if (hSession->kybdlock & KL_OIA_MINUS) | 1752 | if (hSession->kybdlock & KL_OIA_MINUS) |
1753 | { | 1753 | { |
1754 | - errno = EPERM; | ||
1755 | - return -1; | 1754 | + return errno = EPERM; |
1756 | } | 1755 | } |
1757 | else if (hSession->kybdlock) | 1756 | else if (hSession->kybdlock) |
1758 | { | 1757 | { |
@@ -1772,7 +1771,6 @@ LIB3270_EXPORT int lib3270_sysreq(H3270 *hSession) | @@ -1772,7 +1771,6 @@ LIB3270_EXPORT int lib3270_sysreq(H3270 *hSession) | ||
1772 | 1771 | ||
1773 | if (IN_ANSI) | 1772 | if (IN_ANSI) |
1774 | { | 1773 | { |
1775 | - errno = ENOTCONN; | ||
1776 | return 0; | 1774 | return 0; |
1777 | } | 1775 | } |
1778 | 1776 | ||
@@ -1848,7 +1846,7 @@ LIB3270_EXPORT int lib3270_eraseeol(H3270 *hSession) | @@ -1848,7 +1846,7 @@ LIB3270_EXPORT int lib3270_eraseeol(H3270 *hSession) | ||
1848 | if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) | 1846 | if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) |
1849 | { | 1847 | { |
1850 | operator_error(hSession,KL_OERR_PROTECTED); | 1848 | operator_error(hSession,KL_OERR_PROTECTED); |
1851 | - return -1; | 1849 | + return errno = EPERM; |
1852 | } | 1850 | } |
1853 | 1851 | ||
1854 | if (hSession->formatted) | 1852 | if (hSession->formatted) |
@@ -1914,7 +1912,7 @@ LIB3270_EXPORT int lib3270_eraseeof(H3270 *hSession) | @@ -1914,7 +1912,7 @@ LIB3270_EXPORT int lib3270_eraseeof(H3270 *hSession) | ||
1914 | fa = get_field_attribute(hSession,baddr); | 1912 | fa = get_field_attribute(hSession,baddr); |
1915 | if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) { | 1913 | if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) { |
1916 | operator_error(hSession,KL_OERR_PROTECTED); | 1914 | operator_error(hSession,KL_OERR_PROTECTED); |
1917 | - return -1; | 1915 | + return errno = EPERM; |
1918 | } | 1916 | } |
1919 | if (hSession->formatted) | 1917 | if (hSession->formatted) |
1920 | { /* erase to next field attribute */ | 1918 | { /* erase to next field attribute */ |
@@ -2039,7 +2037,7 @@ LIB3270_EXPORT int lib3270_deleteword(H3270 *hSession) | @@ -2039,7 +2037,7 @@ LIB3270_EXPORT int lib3270_deleteword(H3270 *hSession) | ||
2039 | /* Make sure we're on a modifiable field. */ | 2037 | /* Make sure we're on a modifiable field. */ |
2040 | if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) { | 2038 | if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) { |
2041 | operator_error(hSession,KL_OERR_PROTECTED); | 2039 | operator_error(hSession,KL_OERR_PROTECTED); |
2042 | - return -1; | 2040 | + return errno = EPERM; |
2043 | } | 2041 | } |
2044 | 2042 | ||
2045 | /* Backspace over any spaces to the left of the cursor. */ | 2043 | /* Backspace over any spaces to the left of the cursor. */ |
@@ -2105,7 +2103,7 @@ LIB3270_EXPORT int lib3270_deletefield(H3270 *hSession) | @@ -2105,7 +2103,7 @@ LIB3270_EXPORT int lib3270_deletefield(H3270 *hSession) | ||
2105 | fa = get_field_attribute(hSession,baddr); | 2103 | fa = get_field_attribute(hSession,baddr); |
2106 | if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) { | 2104 | if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) { |
2107 | operator_error(hSession,KL_OERR_PROTECTED); | 2105 | operator_error(hSession,KL_OERR_PROTECTED); |
2108 | - return -1; | 2106 | + return errno = EPERM; |
2109 | } | 2107 | } |
2110 | while (!hSession->ea_buf[baddr].fa) | 2108 | while (!hSession->ea_buf[baddr].fa) |
2111 | DEC_BA(baddr); | 2109 | DEC_BA(baddr); |
@@ -2153,16 +2151,18 @@ int lib3270_get_field_end(H3270 *hSession, int baddr) | @@ -2153,16 +2151,18 @@ int lib3270_get_field_end(H3270 *hSession, int baddr) | ||
2153 | 2151 | ||
2154 | #if defined(X3270_ANSI) /*[*/ | 2152 | #if defined(X3270_ANSI) /*[*/ |
2155 | if (IN_ANSI) | 2153 | if (IN_ANSI) |
2156 | - return -1; | 2154 | + { |
2155 | + return errno = EINVAL; | ||
2156 | + } | ||
2157 | #endif /*]*/ | 2157 | #endif /*]*/ |
2158 | 2158 | ||
2159 | if (!hSession->formatted) | 2159 | if (!hSession->formatted) |
2160 | - return -1; | 2160 | + return errno = EINVAL; |
2161 | 2161 | ||
2162 | faddr = find_field_attribute(hSession,baddr); | 2162 | faddr = find_field_attribute(hSession,baddr); |
2163 | fa = hSession->ea_buf[faddr].fa; | 2163 | fa = hSession->ea_buf[faddr].fa; |
2164 | if (faddr == baddr || FA_IS_PROTECTED(fa)) | 2164 | if (faddr == baddr || FA_IS_PROTECTED(fa)) |
2165 | - return -1; | 2165 | + return errno = EPERM; |
2166 | 2166 | ||
2167 | baddr = faddr; | 2167 | baddr = faddr; |
2168 | while (True) | 2168 | while (True) |
@@ -2317,7 +2317,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, const char *s, int len | @@ -2317,7 +2317,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, const char *s, int len | ||
2317 | if (hSession->kybdlock) | 2317 | if (hSession->kybdlock) |
2318 | { | 2318 | { |
2319 | lib3270_trace_event(hSession," keyboard locked, string dropped\n"); | 2319 | lib3270_trace_event(hSession," keyboard locked, string dropped\n"); |
2320 | - return -1; | 2320 | + return errno = EPERM; |
2321 | } | 2321 | } |
2322 | 2322 | ||
2323 | if (pasting && IN_3270) | 2323 | if (pasting && IN_3270) |
src/lib3270/linux/connect.c
@@ -290,8 +290,7 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u | @@ -290,8 +290,7 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u | ||
290 | 290 | ||
291 | default: | 291 | default: |
292 | lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->cstate); | 292 | lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->cstate); |
293 | - errno = EINVAL; | ||
294 | - return -1; | 293 | + return errno = EINVAL; |
295 | } | 294 | } |
296 | 295 | ||
297 | } | 296 | } |
src/lib3270/paste.c
@@ -240,10 +240,7 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, int row, int col, cons | @@ -240,10 +240,7 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, int row, int col, cons | ||
240 | 240 | ||
241 | // Is Keyboard locked ? | 241 | // Is Keyboard locked ? |
242 | if(hSession->kybdlock) | 242 | if(hSession->kybdlock) |
243 | - { | ||
244 | - errno = EPERM; | ||
245 | - return -1; | ||
246 | - } | 243 | + return errno = EPERM; |
247 | 244 | ||
248 | if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) | 245 | if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) |
249 | lib3270_unselect(hSession); | 246 | lib3270_unselect(hSession); |
@@ -273,10 +270,7 @@ LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, con | @@ -273,10 +270,7 @@ LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, con | ||
273 | FAIL_IF_NOT_ONLINE(hSession); | 270 | FAIL_IF_NOT_ONLINE(hSession); |
274 | 271 | ||
275 | if(hSession->kybdlock) | 272 | if(hSession->kybdlock) |
276 | - { | ||
277 | - errno = EPERM; | ||
278 | - return -1; | ||
279 | - } | 273 | + return errno = EPERM; |
280 | 274 | ||
281 | if(lib3270_set_cursor_address(hSession,baddr) < 0) | 275 | if(lib3270_set_cursor_address(hSession,baddr) < 0) |
282 | return -1; | 276 | return -1; |
@@ -307,10 +301,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) | @@ -307,10 +301,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) | ||
307 | FAIL_IF_NOT_ONLINE(hSession); | 301 | FAIL_IF_NOT_ONLINE(hSession); |
308 | 302 | ||
309 | if(hSession->kybdlock) | 303 | if(hSession->kybdlock) |
310 | - { | ||
311 | - errno = EPERM; | ||
312 | - return -1; | ||
313 | - } | 304 | + return errno = EPERM; |
314 | 305 | ||
315 | hSession->cbk.suspend(hSession); | 306 | hSession->cbk.suspend(hSession); |
316 | rc = set_string(hSession, str); | 307 | rc = set_string(hSession, str); |
src/lib3270/properties.c
@@ -463,23 +463,6 @@ | @@ -463,23 +463,6 @@ | ||
463 | 463 | ||
464 | } | 464 | } |
465 | 465 | ||
466 | - /* | ||
467 | - int lib3270_set_connected(H3270 *hSession, int state) { | ||
468 | - | ||
469 | - if(state) { | ||
470 | - | ||
471 | - if(lib3270_reconnect(hSession,120)) | ||
472 | - return -1; | ||
473 | - | ||
474 | - } else { | ||
475 | - | ||
476 | - return lib3270_disconnect(hSession); | ||
477 | - } | ||
478 | - | ||
479 | - return 0; | ||
480 | - } | ||
481 | - */ | ||
482 | - | ||
483 | int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) | 466 | int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) |
484 | { | 467 | { |
485 | size_t ix; | 468 | size_t ix; |