Commit 6d5ff4a37dfe54f43c553515402d51cf49686ba4
1 parent
6a00696c
Exists in
master
and in
3 other branches
Removendo funções de charset antigas
Showing
5 changed files
with
126 additions
and
226 deletions
Show diff stats
charset.c
@@ -36,6 +36,8 @@ | @@ -36,6 +36,8 @@ | ||
36 | 36 | ||
37 | #include "globals.h" | 37 | #include "globals.h" |
38 | 38 | ||
39 | +/* | ||
40 | + | ||
39 | #include "resources.h" | 41 | #include "resources.h" |
40 | // #include "appres.h" | 42 | // #include "appres.h" |
41 | #include "cg.h" | 43 | #include "cg.h" |
@@ -59,15 +61,10 @@ | @@ -59,15 +61,10 @@ | ||
59 | #define EURO_SUFFIX "-euro" | 61 | #define EURO_SUFFIX "-euro" |
60 | #define ES_SIZE (sizeof(EURO_SUFFIX) - 1) | 62 | #define ES_SIZE (sizeof(EURO_SUFFIX) - 1) |
61 | 63 | ||
62 | -/* Globals. */ | ||
63 | -// unsigned long cgcsgid = LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET; | ||
64 | -// unsigned long cgcsgid_dbcs = 0L; | 64 | +// Globals. |
65 | const char *default_display_charset = "3270cg-1a,3270cg-1,iso8859-1"; | 65 | const char *default_display_charset = "3270cg-1a,3270cg-1,iso8859-1"; |
66 | -// char *encoding; | ||
67 | 66 | ||
68 | -// unsigned char auto_keymap = 0; | ||
69 | - | ||
70 | -/* Statics. */ | 67 | +// Statics. |
71 | static enum cs_result resource_charset(H3270 *hSession, const char *csname, char *cs, char *ftcs); | 68 | static enum cs_result resource_charset(H3270 *hSession, const char *csname, char *cs, char *ftcs); |
72 | 69 | ||
73 | typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; | 70 | typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; |
@@ -75,20 +72,16 @@ typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; | @@ -75,20 +72,16 @@ typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; | ||
75 | static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spec, remap_scope scope, int *ne); | 72 | static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spec, remap_scope scope, int *ne); |
76 | static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scope scope,Boolean one_way); | 73 | static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scope scope,Boolean one_way); |
77 | 74 | ||
78 | -#if defined(DEBUG_CHARSET) /*[*/ | 75 | +#if defined(DEBUG_CHARSET) |
79 | static enum cs_result check_charset(void); | 76 | static enum cs_result check_charset(void); |
80 | static char *char_if_ascii7(unsigned long l); | 77 | static char *char_if_ascii7(unsigned long l); |
81 | -#endif /*]*/ | 78 | +#endif |
82 | 79 | ||
83 | static void set_cgcsgids(H3270 *hSession, const char *spec); | 80 | static void set_cgcsgids(H3270 *hSession, const char *spec); |
84 | static int set_cgcsgid(char *spec, unsigned long *idp); | 81 | static int set_cgcsgid(char *spec, unsigned long *idp); |
85 | 82 | ||
86 | static KeySym StringToKeysym(char *s); | 83 | static KeySym StringToKeysym(char *s); |
87 | 84 | ||
88 | -// static void set_charset_name(char *csname); | ||
89 | -// static char *charset_name = CN; | ||
90 | - | ||
91 | - | ||
92 | struct charset_buffer | 85 | struct charset_buffer |
93 | { | 86 | { |
94 | unsigned char ebc2cg[256]; | 87 | unsigned char ebc2cg[256]; |
@@ -96,10 +89,10 @@ struct charset_buffer | @@ -96,10 +89,10 @@ struct charset_buffer | ||
96 | unsigned char ebc2asc[256]; | 89 | unsigned char ebc2asc[256]; |
97 | unsigned char asc2ebc[256]; | 90 | unsigned char asc2ebc[256]; |
98 | 91 | ||
99 | - #if defined(X3270_FT) /*[*/ | 92 | + #if defined(X3270_FT) |
100 | unsigned char ft2asc[256]; | 93 | unsigned char ft2asc[256]; |
101 | unsigned char asc2ft[256]; | 94 | unsigned char asc2ft[256]; |
102 | - #endif /*]*/ | 95 | + #endif |
103 | }; | 96 | }; |
104 | 97 | ||
105 | 98 | ||
@@ -109,10 +102,10 @@ static void save_charset(H3270 *hSession, struct charset_buffer *save) | @@ -109,10 +102,10 @@ static void save_charset(H3270 *hSession, struct charset_buffer *save) | ||
109 | (void) memcpy((char *)save->cg2ebc, (char *) hSession->charset.cg2ebc, 256); | 102 | (void) memcpy((char *)save->cg2ebc, (char *) hSession->charset.cg2ebc, 256); |
110 | (void) memcpy((char *)save->ebc2asc, (char *) hSession->charset.ebc2asc, 256); | 103 | (void) memcpy((char *)save->ebc2asc, (char *) hSession->charset.ebc2asc, 256); |
111 | (void) memcpy((char *)save->asc2ebc, (char *) hSession->charset.asc2ebc, 256); | 104 | (void) memcpy((char *)save->asc2ebc, (char *) hSession->charset.asc2ebc, 256); |
112 | -#if defined(X3270_FT) /*[*/ | 105 | +#if defined(X3270_FT) |
113 | (void) memcpy((char *)save->ft2asc, (char *) hSession->charset.ft2asc, 256); | 106 | (void) memcpy((char *)save->ft2asc, (char *) hSession->charset.ft2asc, 256); |
114 | (void) memcpy((char *)save->asc2ft, (char *) hSession->charset.asc2ft, 256); | 107 | (void) memcpy((char *)save->asc2ft, (char *) hSession->charset.asc2ft, 256); |
115 | -#endif /*]*/ | 108 | +#endif |
116 | } | 109 | } |
117 | 110 | ||
118 | static void restore_charset(H3270 *hSession, struct charset_buffer *save) | 111 | static void restore_charset(H3270 *hSession, struct charset_buffer *save) |
@@ -121,59 +114,23 @@ static void restore_charset(H3270 *hSession, struct charset_buffer *save) | @@ -121,59 +114,23 @@ static void restore_charset(H3270 *hSession, struct charset_buffer *save) | ||
121 | (void) memcpy((char *)hSession->charset.cg2ebc, (char *)save->cg2ebc, 256); | 114 | (void) memcpy((char *)hSession->charset.cg2ebc, (char *)save->cg2ebc, 256); |
122 | (void) memcpy((char *)hSession->charset.ebc2asc, (char *)save->ebc2asc, 256); | 115 | (void) memcpy((char *)hSession->charset.ebc2asc, (char *)save->ebc2asc, 256); |
123 | (void) memcpy((char *)hSession->charset.asc2ebc, (char *)save->asc2ebc, 256); | 116 | (void) memcpy((char *)hSession->charset.asc2ebc, (char *)save->asc2ebc, 256); |
124 | -#if defined(X3270_FT) /*[*/ | 117 | +#if defined(X3270_FT) |
125 | (void) memcpy((char *)hSession->charset.ft2asc, (char *)save->ft2asc, 256); | 118 | (void) memcpy((char *)hSession->charset.ft2asc, (char *)save->ft2asc, 256); |
126 | (void) memcpy((char *)hSession->charset.asc2ft, (char *)save->asc2ft, 256); | 119 | (void) memcpy((char *)hSession->charset.asc2ft, (char *)save->asc2ft, 256); |
127 | -#endif /*]*/ | ||
128 | -} | ||
129 | - | ||
130 | -/* Get a character set definition. */ | ||
131 | -/* | ||
132 | -static char * get_charset_def(const char *csname) | ||
133 | -{ | ||
134 | - return get_fresource("%s.%s", "charset", csname); | 120 | +#endif |
135 | } | 121 | } |
136 | -*/ | ||
137 | 122 | ||
138 | -/* | ||
139 | -#if defined(X3270_DBCS) | ||
140 | // | 123 | // |
141 | -// Initialize the DBCS conversion functions, based on resource values. | 124 | +// Change character sets. |
142 | // | 125 | // |
143 | -static int | ||
144 | -wide_resource_init(char *csname) | ||
145 | -{ | ||
146 | - char *cn, *en; | ||
147 | - | ||
148 | - cn = get_fresource("%s.%s", "dbcsConverters", csname); | ||
149 | - if (cn == CN) | ||
150 | - return 0; | ||
151 | - | ||
152 | - en = get_fresource("%s.%s", "localEncoding", csname); | ||
153 | - if (en == CN) | ||
154 | - en = appres.local_encoding; | ||
155 | - Replace(converter_names, cn); | ||
156 | - Replace(encoding, en); | ||
157 | - | ||
158 | - return wide_init(cn, en); | ||
159 | - | ||
160 | -} | ||
161 | -#endif | ||
162 | -*/ | ||
163 | - | ||
164 | -/* | ||
165 | - * Change character sets. | ||
166 | - */ | ||
167 | enum cs_result charset_init(H3270 *hSession, const char *csname) | 126 | enum cs_result charset_init(H3270 *hSession, const char *csname) |
168 | { | 127 | { |
169 | -// char *cs; | ||
170 | -// const char *ftcs; | ||
171 | enum cs_result rc; | 128 | enum cs_result rc; |
172 | char *ccs, *cftcs; | 129 | char *ccs, *cftcs; |
173 | const char *ak; | 130 | const char *ak; |
174 | struct charset_buffer save; | 131 | struct charset_buffer save; |
175 | 132 | ||
176 | - /* Do nothing, successfully. */ | 133 | + // Do nothing, successfully. |
177 | if (csname == CN || !strcasecmp(csname, "us")) | 134 | if (csname == CN || !strcasecmp(csname, "us")) |
178 | { | 135 | { |
179 | charset_defaults(hSession); | 136 | charset_defaults(hSession); |
@@ -182,81 +139,50 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) | @@ -182,81 +139,50 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) | ||
182 | return CS_OKAY; | 139 | return CS_OKAY; |
183 | } | 140 | } |
184 | 141 | ||
185 | - /* Figure out if it's already in a resource or in a file. */ | 142 | + // Figure out if it's already in a resource or in a file. |
186 | #ifdef ANDROID | 143 | #ifdef ANDROID |
187 | ccs = strdup("0xad: [ \n 0xba: Yacute \n0xbd: ] \n 0xbb: diaeresis \n"); | 144 | ccs = strdup("0xad: [ \n 0xba: Yacute \n0xbd: ] \n 0xbb: diaeresis \n"); |
188 | #else | 145 | #else |
189 | ccs = lib3270_get_resource_string(hSession,"charset", csname, NULL); | 146 | ccs = lib3270_get_resource_string(hSession,"charset", csname, NULL); |
190 | #endif | 147 | #endif |
191 | -/* | ||
192 | - if (cs == CN && strlen(csname) > ES_SIZE && !strcasecmp(csname + strlen(csname) - ES_SIZE, EURO_SUFFIX)) | ||
193 | - { | ||
194 | - char *basename = | ||
195 | - lib3270_free(cs); | ||
196 | - | ||
197 | - // Grab the non-Euro definition. | ||
198 | - basename = xs_buffer("%.*s", (int) (strlen(csname) - ES_SIZE), csname); | ||
199 | - cs = get_charset_def(basename); | ||
200 | - lib3270_free(basename); | ||
201 | - } | ||
202 | -*/ | ||
203 | if (!ccs) | 148 | if (!ccs) |
204 | return CS_NOTFOUND; | 149 | return CS_NOTFOUND; |
205 | 150 | ||
206 | - /* Grab the File Transfer character set. */ | 151 | + // Grab the File Transfer character set. |
207 | cftcs = lib3270_get_resource_string(hSession,"ftCharset",csname,NULL); | 152 | cftcs = lib3270_get_resource_string(hSession,"ftCharset",csname,NULL); |
208 | 153 | ||
209 | - /* Save the current definitions, and start over with the defaults. */ | 154 | + // Save the current definitions, and start over with the defaults. |
210 | save_charset(hSession,&save); | 155 | save_charset(hSession,&save); |
211 | charset_defaults(hSession); | 156 | charset_defaults(hSession); |
212 | 157 | ||
213 | - /* Check for auto-keymap. */ | 158 | + // Check for auto-keymap. |
214 | ak = lib3270_get_resource_string(hSession,"autoKeymap", csname, NULL); | 159 | ak = lib3270_get_resource_string(hSession,"autoKeymap", csname, NULL); |
215 | if (ak != NULL) | 160 | if (ak != NULL) |
216 | hSession->auto_keymap = strcasecmp(ak, "true") ? 0 : 1; | 161 | hSession->auto_keymap = strcasecmp(ak, "true") ? 0 : 1; |
217 | else | 162 | else |
218 | hSession->auto_keymap = 0; | 163 | hSession->auto_keymap = 0; |
219 | 164 | ||
220 | - /* Interpret them. */ | 165 | + // Interpret them. |
221 | rc = resource_charset(hSession,csname, ccs, cftcs); | 166 | rc = resource_charset(hSession,csname, ccs, cftcs); |
222 | 167 | ||
223 | - /* Free them. */ | 168 | + // Free them. |
224 | lib3270_free(ccs); | 169 | lib3270_free(ccs); |
225 | lib3270_free(cftcs); | 170 | lib3270_free(cftcs); |
226 | 171 | ||
227 | -#if defined(DEBUG_CHARSET) /*[*/ | 172 | +#if defined(DEBUG_CHARSET) |
228 | if (rc == CS_OKAY) | 173 | if (rc == CS_OKAY) |
229 | rc = check_charset(); | 174 | rc = check_charset(); |
230 | -#endif /*]*/ | 175 | +#endif |
231 | 176 | ||
232 | if (rc != CS_OKAY) | 177 | if (rc != CS_OKAY) |
233 | restore_charset(hSession,&save); | 178 | restore_charset(hSession,&save); |
234 | 179 | ||
235 | -/* | ||
236 | -#if defined(X3270_DBCS) | ||
237 | - else if (wide_resource_init(csname) < 0) { | ||
238 | - restore_charset(); | ||
239 | - return CS_NOTFOUND; | ||
240 | - } | ||
241 | -#endif | ||
242 | -*/ | ||
243 | - | ||
244 | -/* | ||
245 | -#if defined(X3270_DISPLAY) | ||
246 | - // Check for an XK selector. | ||
247 | - xks = get_fresource("%s.%s", ResXkSelector, csname); | ||
248 | - if (xks != NULL) | ||
249 | - xk_selector = (unsigned char) strtoul(xks, NULL, 0); | ||
250 | - else | ||
251 | - xk_selector = 0; | ||
252 | -#endif | ||
253 | -*/ | ||
254 | return rc; | 180 | return rc; |
255 | } | 181 | } |
256 | 182 | ||
257 | -/** | ||
258 | - * Set a CGCSGID. Return 0 for success, -1 for failure. | ||
259 | - */ | 183 | +// |
184 | +// Set a CGCSGID. Return 0 for success, -1 for failure. | ||
185 | +// | ||
260 | static int set_cgcsgid(char *spec, unsigned long *r) | 186 | static int set_cgcsgid(char *spec, unsigned long *r) |
261 | { | 187 | { |
262 | unsigned long cp; | 188 | unsigned long cp; |
@@ -275,7 +201,7 @@ static int set_cgcsgid(char *spec, unsigned long *r) | @@ -275,7 +201,7 @@ static int set_cgcsgid(char *spec, unsigned long *r) | ||
275 | return -1; | 201 | return -1; |
276 | } | 202 | } |
277 | 203 | ||
278 | -/* Set the CGCSGIDs. */ | 204 | +// Set the CGCSGIDs. |
279 | static void set_cgcsgids(H3270 *hSession, const char *spec) | 205 | static void set_cgcsgids(H3270 *hSession, const char *spec) |
280 | { | 206 | { |
281 | int n_ids = 0; | 207 | int n_ids = 0; |
@@ -293,11 +219,11 @@ static void set_cgcsgids(H3270 *hSession, const char *spec) | @@ -293,11 +219,11 @@ static void set_cgcsgids(H3270 *hSession, const char *spec) | ||
293 | case 0: | 219 | case 0: |
294 | idp = &hSession->cgcsgid; | 220 | idp = &hSession->cgcsgid; |
295 | break; | 221 | break; |
296 | -#if defined(X3270_DBCS) /*[*/ | 222 | +#if defined(X3270_DBCS) |
297 | case 1: | 223 | case 1: |
298 | idp = &hSession->cgcsgid_dbcs; | 224 | idp = &hSession->cgcsgid_dbcs; |
299 | break; | 225 | break; |
300 | -#endif /*]*/ | 226 | +#endif |
301 | default: | 227 | default: |
302 | popup_an_error(hSession,_( "Extra CGCSGID(s), ignoring" )); | 228 | popup_an_error(hSession,_( "Extra CGCSGID(s), ignoring" )); |
303 | break; | 229 | break; |
@@ -317,29 +243,12 @@ static void set_cgcsgids(H3270 *hSession, const char *spec) | @@ -317,29 +243,12 @@ static void set_cgcsgids(H3270 *hSession, const char *spec) | ||
317 | } | 243 | } |
318 | 244 | ||
319 | hSession->cgcsgid = LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET; | 245 | hSession->cgcsgid = LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET; |
320 | -#if defined(X3270_DBCS) /*[*/ | 246 | +#if defined(X3270_DBCS) |
321 | hSession->cgcsgid_dbcs = 0L; | 247 | hSession->cgcsgid_dbcs = 0L; |
322 | -#endif /*]*/ | ||
323 | -} | ||
324 | - | ||
325 | -/* Set the global charset name. */ /* | ||
326 | -static void | ||
327 | -set_charset_name(char *csname) | ||
328 | -{ | ||
329 | - if (csname == CN) { | ||
330 | - Replace(charset_name, NewString("us")); | ||
331 | - charset_changed = False; | ||
332 | - return; | ||
333 | - } | ||
334 | - if ((charset_name != CN && strcmp(charset_name, csname)) || | ||
335 | - (appres.charset != CN && strcmp(appres.charset, csname))) { | ||
336 | - Replace(charset_name, NewString(csname)); | ||
337 | - charset_changed = True; | ||
338 | - } | 248 | +#endif |
339 | } | 249 | } |
340 | -*/ | ||
341 | 250 | ||
342 | -/* Define a charset from resources. */ | 251 | +// Define a charset from resources. |
343 | static enum cs_result resource_charset(H3270 *hSession, const char *csname, char *cs, char *ftcs) | 252 | static enum cs_result resource_charset(H3270 *hSession, const char *csname, char *cs, char *ftcs) |
344 | { | 253 | { |
345 | enum cs_result rc; | 254 | enum cs_result rc; |
@@ -348,7 +257,7 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char | @@ -348,7 +257,7 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char | ||
348 | int n_rcs = 0; | 257 | int n_rcs = 0; |
349 | char * dcs; | 258 | char * dcs; |
350 | 259 | ||
351 | - /* Interpret the spec. */ | 260 | + // Interpret the spec. |
352 | rc = remap_chars(hSession, csname, cs, (ftcs == NULL)? BOTH: CS_ONLY, &ne); | 261 | rc = remap_chars(hSession, csname, cs, (ftcs == NULL)? BOTH: CS_ONLY, &ne); |
353 | if (rc != CS_OKAY) | 262 | if (rc != CS_OKAY) |
354 | return rc; | 263 | return rc; |
@@ -358,10 +267,9 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char | @@ -358,10 +267,9 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char | ||
358 | return rc; | 267 | return rc; |
359 | } | 268 | } |
360 | 269 | ||
361 | -// rcs = get_fresource("%s.%s", "displayCharset", csname); | ||
362 | rcs = lib3270_get_resource_string(hSession,"displayCharset", csname, NULL); | 270 | rcs = lib3270_get_resource_string(hSession,"displayCharset", csname, NULL); |
363 | 271 | ||
364 | - /* Isolate the pieces. */ | 272 | + // Isolate the pieces. |
365 | if (rcs != CN) | 273 | if (rcs != CN) |
366 | { | 274 | { |
367 | char *buf, *token; | 275 | char *buf, *token; |
@@ -387,29 +295,7 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char | @@ -387,29 +295,7 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char | ||
387 | 295 | ||
388 | lib3270_free(rcs); | 296 | lib3270_free(rcs); |
389 | 297 | ||
390 | -/* | ||
391 | -#if defined(X3270_DBCS) | ||
392 | - // Can't swap DBCS modes while connected. | ||
393 | - if (IN_3270 && (n_rcs == 2) != dbcs) { | ||
394 | - popup_an_error(NULL,"Can't change DBCS modes while connected"); | ||
395 | - return CS_ILLEGAL; | ||
396 | - } | ||
397 | -#endif | ||
398 | -*/ | ||
399 | - | ||
400 | -/* | ||
401 | -#if !defined(_WIN32) | ||
402 | - utf8_set_display_charsets(rcs? rcs: default_display_charset, csname); | ||
403 | -#endif | ||
404 | -#if defined(X3270_DBCS) | ||
405 | - if (n_rcs > 1) | ||
406 | - dbcs = True; | ||
407 | - else | ||
408 | - dbcs = False; | ||
409 | -#endif | ||
410 | -*/ | ||
411 | - | ||
412 | - /* Set up the cgcsgid. */ | 298 | + // Set up the cgcsgid. |
413 | // set_cgcsgids(get_fresource("%s.%s", "codepage", csname)); | 299 | // set_cgcsgids(get_fresource("%s.%s", "codepage", csname)); |
414 | { | 300 | { |
415 | char *ptr = lib3270_get_resource_string(hSession,"codepage", csname, NULL); | 301 | char *ptr = lib3270_get_resource_string(hSession,"codepage", csname, NULL); |
@@ -427,16 +313,16 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char | @@ -427,16 +313,16 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char | ||
427 | 313 | ||
428 | lib3270_free(dcs); | 314 | lib3270_free(dcs); |
429 | 315 | ||
430 | - /* Set up the character set name. */ | 316 | + // Set up the character set name. |
431 | // set_charset_name(csname); | 317 | // set_charset_name(csname); |
432 | 318 | ||
433 | return CS_OKAY; | 319 | return CS_OKAY; |
434 | } | 320 | } |
435 | 321 | ||
436 | -/* | ||
437 | - * Map a keysym name or literal string into a character. | ||
438 | - * Returns NoSymbol if there is a problem. | ||
439 | - */ | 322 | +// |
323 | +// Map a keysym name or literal string into a character. | ||
324 | +//Returns NoSymbol if there is a problem. | ||
325 | +// | ||
440 | static KeySym | 326 | static KeySym |
441 | parse_keysym(char *s, Boolean extended) | 327 | parse_keysym(char *s, Boolean extended) |
442 | { | 328 | { |
@@ -463,25 +349,25 @@ parse_keysym(char *s, Boolean extended) | @@ -463,25 +349,25 @@ parse_keysym(char *s, Boolean extended) | ||
463 | return k; | 349 | return k; |
464 | } | 350 | } |
465 | 351 | ||
466 | -/* Process a single character definition. */ | 352 | +// Process a single character definition. |
467 | static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) | 353 | static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) |
468 | { | 354 | { |
469 | unsigned char cg; | 355 | unsigned char cg; |
470 | 356 | ||
471 | - /* Ignore mappings of EBCDIC control codes and the space character. */ | 357 | + // Ignore mappings of EBCDIC control codes and the space character. |
472 | if (ebc <= 0x40) | 358 | if (ebc <= 0x40) |
473 | return; | 359 | return; |
474 | 360 | ||
475 | - /* If they want to map to a NULL or a blank, make it a one-way blank. */ | 361 | + // If they want to map to a NULL or a blank, make it a one-way blank. |
476 | if (iso == 0x0) | 362 | if (iso == 0x0) |
477 | iso = 0x20; | 363 | iso = 0x20; |
478 | if (iso == 0x20) | 364 | if (iso == 0x20) |
479 | one_way = True; | 365 | one_way = True; |
480 | 366 | ||
481 | if (!hSession->auto_keymap || iso <= 0xff) { | 367 | if (!hSession->auto_keymap || iso <= 0xff) { |
482 | -#if defined(X3270_FT) /*[*/ | 368 | +#if defined(X3270_FT) |
483 | unsigned char aa; | 369 | unsigned char aa; |
484 | -#endif /*]*/ | 370 | +#endif |
485 | 371 | ||
486 | if (scope == BOTH || scope == CS_ONLY) { | 372 | if (scope == BOTH || scope == CS_ONLY) { |
487 | if (iso <= 0xff) { | 373 | if (iso <= 0xff) { |
@@ -489,14 +375,14 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop | @@ -489,14 +375,14 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop | ||
489 | 375 | ||
490 | if (hSession->charset.cg2asc[cg] == iso || iso == 0) | 376 | if (hSession->charset.cg2asc[cg] == iso || iso == 0) |
491 | { | 377 | { |
492 | - /* well-defined */ | 378 | + // well-defined |
493 | hSession->charset.ebc2cg[ebc] = cg; | 379 | hSession->charset.ebc2cg[ebc] = cg; |
494 | if (!one_way) | 380 | if (!one_way) |
495 | hSession->charset.cg2ebc[cg] = ebc; | 381 | hSession->charset.cg2ebc[cg] = ebc; |
496 | } | 382 | } |
497 | else | 383 | else |
498 | { | 384 | { |
499 | - /* into a hole */ | 385 | + // into a hole |
500 | hSession->charset.ebc2cg[ebc] = CG_boxsolid; | 386 | hSession->charset.ebc2cg[ebc] = CG_boxsolid; |
501 | } | 387 | } |
502 | } | 388 | } |
@@ -507,57 +393,57 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop | @@ -507,57 +393,57 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop | ||
507 | hSession->charset.asc2ebc[iso] = ebc; | 393 | hSession->charset.asc2ebc[iso] = ebc; |
508 | } | 394 | } |
509 | } | 395 | } |
510 | -#if defined(X3270_FT) /*[*/ | 396 | +#if defined(X3270_FT) |
511 | if (iso <= 0xff && ebc > 0x40) { | 397 | if (iso <= 0xff && ebc > 0x40) { |
512 | - /* Change the file transfer translation table. */ | 398 | + // Change the file transfer translation table. |
513 | if (scope == BOTH) { | 399 | if (scope == BOTH) { |
514 | - /* | ||
515 | - * We have an alternate mapping of an EBCDIC | ||
516 | - * code to an ASCII code. Modify the existing | ||
517 | - * ASCII(ft)-to-ASCII(desired) maps. | ||
518 | - * | ||
519 | - * This is done by figuring out which ASCII | ||
520 | - * code the host usually translates the given | ||
521 | - * EBCDIC code to (asc2ft0[ebc2asc0[ebc]]). | ||
522 | - * Now we want to translate that code to the | ||
523 | - * given ISO code, and vice-versa. | ||
524 | - */ | 400 | + // |
401 | + // We have an alternate mapping of an EBCDIC | ||
402 | + // code to an ASCII code. Modify the existing | ||
403 | + // ASCII(ft)-to-ASCII(desired) maps. | ||
404 | + // | ||
405 | + // This is done by figuring out which ASCII | ||
406 | + // code the host usually translates the given | ||
407 | + // EBCDIC code to (asc2ft0[ebc2asc0[ebc]]). | ||
408 | + // Now we want to translate that code to the | ||
409 | + // given ISO code, and vice-versa. | ||
410 | + // | ||
525 | aa = asc2ft0[ebc2asc0[ebc]]; | 411 | aa = asc2ft0[ebc2asc0[ebc]]; |
526 | if (aa != ' ') { | 412 | if (aa != ' ') { |
527 | hSession->charset.ft2asc[aa] = iso; | 413 | hSession->charset.ft2asc[aa] = iso; |
528 | hSession->charset.asc2ft[iso] = aa; | 414 | hSession->charset.asc2ft[iso] = aa; |
529 | } | 415 | } |
530 | } else if (scope == FT_ONLY) { | 416 | } else if (scope == FT_ONLY) { |
531 | - /* | ||
532 | - * We have a map of how the host translates | ||
533 | - * the given EBCDIC code to an ASCII code. | ||
534 | - * Generate the translation between that code | ||
535 | - * and the ISO code that we would normally | ||
536 | - * use to display that EBCDIC code. | ||
537 | - */ | 417 | + // |
418 | + // We have a map of how the host translates | ||
419 | + // the given EBCDIC code to an ASCII code. | ||
420 | + // Generate the translation between that code | ||
421 | + // and the ISO code that we would normally | ||
422 | + // use to display that EBCDIC code. | ||
423 | + // | ||
538 | hSession->charset.ft2asc[iso] = hSession->charset.ebc2asc[ebc]; | 424 | hSession->charset.ft2asc[iso] = hSession->charset.ebc2asc[ebc]; |
539 | hSession->charset.asc2ft[hSession->charset.ebc2asc[ebc]] = iso; | 425 | hSession->charset.asc2ft[hSession->charset.ebc2asc[ebc]] = iso; |
540 | } | 426 | } |
541 | } | 427 | } |
542 | -#endif /*]*/ | 428 | +#endif |
543 | } else { | 429 | } else { |
544 | - /* Auto-keymap. */ | 430 | + // Auto-keymap. |
545 | add_xk(iso, (KeySym)hSession->charset.ebc2asc[ebc]); | 431 | add_xk(iso, (KeySym)hSession->charset.ebc2asc[ebc]); |
546 | } | 432 | } |
547 | } | 433 | } |
548 | 434 | ||
549 | -/** | ||
550 | - * Parse an EBCDIC character set map, a series of pairs of numeric EBCDIC codes and keysyms. | ||
551 | - * | ||
552 | - * If the keysym is in the range 1..255, it is a remapping of the EBCDIC code | ||
553 | - * for a standard Latin-1 graphic, and the CG-to-EBCDIC map will be modified | ||
554 | - * to match. | ||
555 | - * | ||
556 | - * Otherwise (keysym > 255), it is a definition for the EBCDIC code to use for | ||
557 | - * a multibyte keysym. This is intended for 8-bit fonts that with special | ||
558 | - * characters that replace certain standard Latin-1 graphics. The keysym | ||
559 | - * will be entered into the extended keysym translation table. | ||
560 | - */ | 435 | +// |
436 | +// Parse an EBCDIC character set map, a series of pairs of numeric EBCDIC codes and keysyms. | ||
437 | +// | ||
438 | +// If the keysym is in the range 1..255, it is a remapping of the EBCDIC code | ||
439 | +// for a standard Latin-1 graphic, and the CG-to-EBCDIC map will be modified | ||
440 | +// to match. | ||
441 | +// | ||
442 | +// Otherwise (keysym > 255), it is a definition for the EBCDIC code to use for | ||
443 | +// a multibyte keysym. This is intended for 8-bit fonts that with special | ||
444 | +// characters that replace certain standard Latin-1 graphics. The keysym | ||
445 | +// will be entered into the extended keysym translation table. | ||
446 | +// | ||
561 | static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spec, remap_scope scope, int *ne) | 447 | static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spec, remap_scope scope, int *ne) |
562 | { | 448 | { |
563 | char *s; | 449 | char *s; |
@@ -569,7 +455,7 @@ static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spe | @@ -569,7 +455,7 @@ static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spe | ||
569 | Boolean is_table = False; | 455 | Boolean is_table = False; |
570 | Boolean one_way = False; | 456 | Boolean one_way = False; |
571 | 457 | ||
572 | - /* Pick apart a copy of the spec. */ | 458 | + // Pick apart a copy of the spec. |
573 | s = spec = NewString(spec); | 459 | s = spec = NewString(spec); |
574 | while (isspace(*s)) { | 460 | while (isspace(*s)) { |
575 | s++; | 461 | s++; |
@@ -614,12 +500,12 @@ static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spe | @@ -614,12 +500,12 @@ static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spe | ||
614 | popup_an_error(NULL,_( "Charset has %d entries, need 256" ), ebc); | 500 | popup_an_error(NULL,_( "Charset has %d entries, need 256" ), ebc); |
615 | rc = CS_BAD; | 501 | rc = CS_BAD; |
616 | } else { | 502 | } else { |
617 | - /* | ||
618 | - * The entire EBCDIC-to-ASCII mapping has been defined. | ||
619 | - * Make sure that any printable ASCII character that | ||
620 | - * doesn't now map back onto itself is mapped onto an | ||
621 | - * EBCDIC NUL. | ||
622 | - */ | 503 | + // |
504 | + // The entire EBCDIC-to-ASCII mapping has been defined. | ||
505 | + // Make sure that any printable ASCII character that | ||
506 | + // doesn't now map back onto itself is mapped onto an | ||
507 | + // EBCDIC NUL. | ||
508 | + // | ||
623 | int i; | 509 | int i; |
624 | 510 | ||
625 | for (i = 0; i < 256; i++) { | 511 | for (i = 0; i < 256; i++) { |
@@ -655,7 +541,7 @@ static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spe | @@ -655,7 +541,7 @@ static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spe | ||
655 | return rc; | 541 | return rc; |
656 | } | 542 | } |
657 | 543 | ||
658 | -#if defined(DEBUG_CHARSET) /*[*/ | 544 | +#if defined(DEBUG_CHARSET) |
659 | static char * | 545 | static char * |
660 | char_if_ascii7(unsigned long l) | 546 | char_if_ascii7(unsigned long l) |
661 | { | 547 | { |
@@ -667,15 +553,15 @@ char_if_ascii7(unsigned long l) | @@ -667,15 +553,15 @@ char_if_ascii7(unsigned long l) | ||
667 | } else | 553 | } else |
668 | return ""; | 554 | return ""; |
669 | } | 555 | } |
670 | -#endif /*]*/ | 556 | +#endif |
671 | 557 | ||
672 | 558 | ||
673 | -#if defined(DEBUG_CHARSET) /*[*/ | ||
674 | -/* | ||
675 | - * Verify that a character set is not ambiguous. | ||
676 | - * (All this checks is that multiple EBCDIC codes map onto the same ISO code. | ||
677 | - * Hmm. God, I find the CG stuff confusing.) | ||
678 | - */ | 559 | +#if defined(DEBUG_CHARSET) |
560 | +// | ||
561 | +// Verify that a character set is not ambiguous. | ||
562 | +// (All this checks is that multiple EBCDIC codes map onto the same ISO code. | ||
563 | +// Hmm. God, I find the CG stuff confusing.) | ||
564 | +// | ||
679 | static enum cs_result | 565 | static enum cs_result |
680 | check_charset(void) | 566 | check_charset(void) |
681 | { | 567 | { |
@@ -706,24 +592,13 @@ check_charset(void) | @@ -706,24 +592,13 @@ check_charset(void) | ||
706 | } | 592 | } |
707 | return rc; | 593 | return rc; |
708 | } | 594 | } |
709 | -#endif /*]*/ | 595 | +#endif |
710 | 596 | ||
711 | void set_display_charset(H3270 *session, const char *dcs) | 597 | void set_display_charset(H3270 *session, const char *dcs) |
712 | { | 598 | { |
713 | session->charset.display = strdup(dcs); | 599 | session->charset.display = strdup(dcs); |
714 | } | 600 | } |
715 | 601 | ||
716 | -LIB3270_EXPORT const char * lib3270_get_default_charset(void) | ||
717 | -{ | ||
718 | - return "ISO-8859-1"; | ||
719 | -} | ||
720 | - | ||
721 | -LIB3270_EXPORT const char * lib3270_get_charset(H3270 *hSession) | ||
722 | -{ | ||
723 | - CHECK_SESSION_HANDLE(hSession); | ||
724 | - return hSession->charset.display ? hSession->charset.display : "ISO-8859-1"; | ||
725 | -} | ||
726 | - | ||
727 | static KeySym StringToKeysym(char *s) | 602 | static KeySym StringToKeysym(char *s) |
728 | { | 603 | { |
729 | static struct | 604 | static struct |
@@ -952,3 +827,17 @@ static KeySym StringToKeysym(char *s) | @@ -952,3 +827,17 @@ static KeySym StringToKeysym(char *s) | ||
952 | } | 827 | } |
953 | return NoSymbol; | 828 | return NoSymbol; |
954 | } | 829 | } |
830 | + | ||
831 | +*/ | ||
832 | + | ||
833 | +LIB3270_EXPORT const char * lib3270_get_default_charset(void) | ||
834 | +{ | ||
835 | + return "ISO-8859-1"; | ||
836 | +} | ||
837 | + | ||
838 | +LIB3270_EXPORT const char * lib3270_get_charset(H3270 *hSession) | ||
839 | +{ | ||
840 | + CHECK_SESSION_HANDLE(hSession); | ||
841 | + return hSession->charset.display ? hSession->charset.display : "ISO-8859-1"; | ||
842 | +} | ||
843 | + |
kybd.c
@@ -130,12 +130,14 @@ Boolean key_WCharacter(unsigned char code[], Boolean *skipped); | @@ -130,12 +130,14 @@ Boolean key_WCharacter(unsigned char code[], Boolean *skipped); | ||
130 | #endif | 130 | #endif |
131 | */ | 131 | */ |
132 | 132 | ||
133 | +/* | ||
133 | static int nxk = 0; | 134 | static int nxk = 0; |
134 | static struct xks | 135 | static struct xks |
135 | { | 136 | { |
136 | KeySym key; | 137 | KeySym key; |
137 | KeySym assoc; | 138 | KeySym assoc; |
138 | } *xk; | 139 | } *xk; |
140 | +*/ | ||
139 | 141 | ||
140 | // static Boolean reverse = False; /* reverse-input mode */ | 142 | // static Boolean reverse = False; /* reverse-input mode */ |
141 | 143 | ||
@@ -3070,6 +3072,7 @@ MyStringToKeysym(char *s, enum keytype *keytypep) | @@ -3070,6 +3072,7 @@ MyStringToKeysym(char *s, enum keytype *keytypep) | ||
3070 | */ | 3072 | */ |
3071 | 3073 | ||
3072 | /* Add a key to the extended association table. */ | 3074 | /* Add a key to the extended association table. */ |
3075 | +/* | ||
3073 | void | 3076 | void |
3074 | add_xk(KeySym key, KeySym assoc) | 3077 | add_xk(KeySym key, KeySym assoc) |
3075 | { | 3078 | { |
@@ -3085,10 +3088,11 @@ add_xk(KeySym key, KeySym assoc) | @@ -3085,10 +3088,11 @@ add_xk(KeySym key, KeySym assoc) | ||
3085 | xk[nxk].assoc = assoc; | 3088 | xk[nxk].assoc = assoc; |
3086 | nxk++; | 3089 | nxk++; |
3087 | } | 3090 | } |
3091 | +*/ | ||
3088 | 3092 | ||
3089 | /* Clear the extended association table. */ | 3093 | /* Clear the extended association table. */ |
3090 | -void | ||
3091 | -clear_xks(void) | 3094 | +/* |
3095 | +void clear_xks(void) | ||
3092 | { | 3096 | { |
3093 | if (nxk) { | 3097 | if (nxk) { |
3094 | lib3270_free(xk); | 3098 | lib3270_free(xk); |
@@ -3096,5 +3100,6 @@ clear_xks(void) | @@ -3096,5 +3100,6 @@ clear_xks(void) | ||
3096 | nxk = 0; | 3100 | nxk = 0; |
3097 | } | 3101 | } |
3098 | } | 3102 | } |
3103 | +*/ | ||
3099 | 3104 | ||
3100 | 3105 |
session.c
@@ -324,13 +324,14 @@ H3270 * lib3270_session_new(const char *model) | @@ -324,13 +324,14 @@ H3270 * lib3270_session_new(const char *model) | ||
324 | if(screen_init(hSession)) | 324 | if(screen_init(hSession)) |
325 | return NULL; | 325 | return NULL; |
326 | 326 | ||
327 | +/* | ||
327 | trace("Charset: %s",hSession->charset.host); | 328 | trace("Charset: %s",hSession->charset.host); |
328 | if (charset_init(hSession,hSession->charset.host) != CS_OKAY) | 329 | if (charset_init(hSession,hSession->charset.host) != CS_OKAY) |
329 | { | 330 | { |
330 | Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), hSession->charset.host); | 331 | Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), hSession->charset.host); |
331 | (void) charset_init(hSession,CN); | 332 | (void) charset_init(hSession,CN); |
332 | } | 333 | } |
333 | - | 334 | +*/ |
334 | trace("%s: Initializing KYBD",__FUNCTION__); | 335 | trace("%s: Initializing KYBD",__FUNCTION__); |
335 | lib3270_register_schange(hSession,LIB3270_STATE_CONNECT,kybd_connect,NULL); | 336 | lib3270_register_schange(hSession,LIB3270_STATE_CONNECT,kybd_connect,NULL); |
336 | lib3270_register_schange(hSession,LIB3270_STATE_3270_MODE,kybd_in3270,NULL); | 337 | lib3270_register_schange(hSession,LIB3270_STATE_3270_MODE,kybd_in3270,NULL); |
tables.c
@@ -40,6 +40,7 @@ | @@ -40,6 +40,7 @@ | ||
40 | 40 | ||
41 | #include "globals.h" | 41 | #include "globals.h" |
42 | #include "tablesc.h" | 42 | #include "tablesc.h" |
43 | +#include "kybdc.h" | ||
43 | 44 | ||
44 | static const unsigned short asc2cg[256] = { | 45 | static const unsigned short asc2cg[256] = { |
45 | /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 46 | /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
@@ -458,6 +459,7 @@ LIB3270_INTERNAL void initialize_tables(H3270 *hSession) | @@ -458,6 +459,7 @@ LIB3270_INTERNAL void initialize_tables(H3270 *hSession) | ||
458 | memcpy(hSession->charset.cg2asc, cg2asc, sizeof(hSession->charset.cg2asc)); | 459 | memcpy(hSession->charset.cg2asc, cg2asc, sizeof(hSession->charset.cg2asc)); |
459 | 460 | ||
460 | #ifdef EXTENDED_TABLES | 461 | #ifdef EXTENDED_TABLES |
462 | + #error Need implementation to the new format | ||
461 | memcpy(ebc2asc7, ebc2asc70, sizeof(ebc2asc7)); | 463 | memcpy(ebc2asc7, ebc2asc70, sizeof(ebc2asc7)); |
462 | #endif // EXTENDED_TABLES | 464 | #endif // EXTENDED_TABLES |
463 | 465 | ||
@@ -479,5 +481,5 @@ void charset_defaults(H3270 *hSession) | @@ -479,5 +481,5 @@ void charset_defaults(H3270 *hSession) | ||
479 | (void) memcpy((char *)hSession->charset.ft2asc, (const char *)ft2asc0, 256); | 481 | (void) memcpy((char *)hSession->charset.ft2asc, (const char *)ft2asc0, 256); |
480 | (void) memcpy((char *)hSession->charset.asc2ft, (const char *)asc2ft0, 256); | 482 | (void) memcpy((char *)hSession->charset.asc2ft, (const char *)asc2ft0, 256); |
481 | #endif /*]*/ | 483 | #endif /*]*/ |
482 | - clear_xks(); | 484 | + // clear_xks(); |
483 | } | 485 | } |
util.c
@@ -952,7 +952,7 @@ LIB3270_EXPORT void * lib3270_strdup(const char *str) | @@ -952,7 +952,7 @@ LIB3270_EXPORT void * lib3270_strdup(const char *str) | ||
952 | return r; | 952 | return r; |
953 | } | 953 | } |
954 | 954 | ||
955 | - | 955 | +/* |
956 | LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *first_element, ...) | 956 | LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *first_element, ...) |
957 | { | 957 | { |
958 | #ifdef ANDROID | 958 | #ifdef ANDROID |
@@ -993,6 +993,7 @@ LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *f | @@ -993,6 +993,7 @@ LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *f | ||
993 | #endif | 993 | #endif |
994 | return NULL; | 994 | return NULL; |
995 | } | 995 | } |
996 | +*/ | ||
996 | 997 | ||
997 | LIB3270_EXPORT const char * lib3270_get_version(void) | 998 | LIB3270_EXPORT const char * lib3270_get_version(void) |
998 | { | 999 | { |
@@ -1048,3 +1049,5 @@ int gettimeofday(struct timeval *tv, void *ignored) | @@ -1048,3 +1049,5 @@ int gettimeofday(struct timeval *tv, void *ignored) | ||
1048 | trace("%s(%p)",__FUNCTION__,h); | 1049 | trace("%s(%p)",__FUNCTION__,h); |
1049 | return h->print(h); | 1050 | return h->print(h); |
1050 | } | 1051 | } |
1052 | + | ||
1053 | + |