Commit 0f5a13fcb07e0aab1a7e8902d2abcb9c953b9148
1 parent
88832e03
Exists in
master
and in
3 other branches
Ajustes para compilar em android
Showing
10 changed files
with
205 additions
and
165 deletions
Show diff stats
XtGlue.c
| ... | ... | @@ -566,60 +566,6 @@ static int DefaultProcessEvents(int block) |
| 566 | 566 | |
| 567 | 567 | /*---[ Implement external calls ]---------------------------------------------------------------------------*/ |
| 568 | 568 | |
| 569 | -void * Malloc(size_t len) | |
| 570 | -{ | |
| 571 | - char *r; | |
| 572 | - | |
| 573 | - r = malloc(len); | |
| 574 | - if (r == (char *)NULL) | |
| 575 | - Error(NULL,"Out of memory"); | |
| 576 | - return r; | |
| 577 | -} | |
| 578 | - | |
| 579 | -void * Calloc(size_t nelem, size_t elsize) | |
| 580 | -{ | |
| 581 | - int sz = nelem * elsize; | |
| 582 | - char * r = malloc(sz); | |
| 583 | - | |
| 584 | - if(!r) | |
| 585 | - Error(NULL,"Out of memory"); | |
| 586 | - | |
| 587 | - memset(r, 0, sz); | |
| 588 | - return r; | |
| 589 | -} | |
| 590 | - | |
| 591 | -void * Realloc(void *p, size_t len) | |
| 592 | -{ | |
| 593 | - p = realloc(p, len); | |
| 594 | - if (p == NULL) | |
| 595 | - Error(NULL,"Out of memory"); | |
| 596 | - return p; | |
| 597 | -} | |
| 598 | - | |
| 599 | -void Free(void *p) | |
| 600 | -{ | |
| 601 | - if(p) | |
| 602 | - free(p); | |
| 603 | -} | |
| 604 | - | |
| 605 | -void * lib3270_calloc(size_t elsize, size_t nelem, void *ptr) | |
| 606 | -{ | |
| 607 | - size_t sz = nelem * elsize; | |
| 608 | - | |
| 609 | - if(ptr) | |
| 610 | - ptr = realloc(ptr,sz); | |
| 611 | - else | |
| 612 | - ptr = malloc(sz); | |
| 613 | - | |
| 614 | - if(ptr) | |
| 615 | - memset(ptr,0,sz); | |
| 616 | - else | |
| 617 | - Error(NULL,"Out of memory"); | |
| 618 | - | |
| 619 | - return ptr; | |
| 620 | -} | |
| 621 | - | |
| 622 | - | |
| 623 | 569 | static struct { |
| 624 | 570 | const char *name; |
| 625 | 571 | KeySym keysym; | ... | ... |
charset.c
| ... | ... | @@ -159,25 +159,28 @@ restore_charset(void) |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /* Get a character set definition. */ |
| 162 | -static const char * get_charset_def(const char *csname) | |
| 162 | +/* | |
| 163 | +static char * get_charset_def(const char *csname) | |
| 163 | 164 | { |
| 164 | - return get_fresource("%s.%s", ResCharset, csname); | |
| 165 | + return get_fresource("%s.%s", "charset", csname); | |
| 165 | 166 | } |
| 167 | +*/ | |
| 166 | 168 | |
| 167 | -#if defined(X3270_DBCS) /*[*/ | |
| 168 | 169 | /* |
| 169 | - * Initialize the DBCS conversion functions, based on resource values. | |
| 170 | - */ | |
| 170 | +#if defined(X3270_DBCS) | |
| 171 | +// | |
| 172 | +// Initialize the DBCS conversion functions, based on resource values. | |
| 173 | +// | |
| 171 | 174 | static int |
| 172 | 175 | wide_resource_init(char *csname) |
| 173 | 176 | { |
| 174 | 177 | char *cn, *en; |
| 175 | 178 | |
| 176 | - cn = get_fresource("%s.%s", ResDbcsConverters, csname); | |
| 179 | + cn = get_fresource("%s.%s", "dbcsConverters", csname); | |
| 177 | 180 | if (cn == CN) |
| 178 | 181 | return 0; |
| 179 | 182 | |
| 180 | - en = get_fresource("%s.%s", ResLocalEncoding, csname); | |
| 183 | + en = get_fresource("%s.%s", "localEncoding", csname); | |
| 181 | 184 | if (en == CN) |
| 182 | 185 | en = appres.local_encoding; |
| 183 | 186 | Replace(converter_names, cn); |
| ... | ... | @@ -186,78 +189,60 @@ wide_resource_init(char *csname) |
| 186 | 189 | return wide_init(cn, en); |
| 187 | 190 | |
| 188 | 191 | } |
| 189 | -#endif /*]*/ | |
| 192 | +#endif | |
| 193 | +*/ | |
| 190 | 194 | |
| 191 | 195 | /* |
| 192 | 196 | * Change character sets. |
| 193 | 197 | */ |
| 194 | 198 | enum cs_result charset_init(H3270 *session, char *csname) |
| 195 | 199 | { |
| 196 | - const char *cs; | |
| 200 | + char *cs; | |
| 197 | 201 | const char *ftcs; |
| 198 | 202 | enum cs_result rc; |
| 199 | 203 | char *ccs, *cftcs; |
| 200 | -/* | |
| 201 | -#if defined(X3270_DISPLAY) | |
| 202 | - char *xks; | |
| 203 | -#endif | |
| 204 | -*/ | |
| 205 | 204 | const char *ak; |
| 206 | 205 | |
| 207 | -/* | |
| 208 | -#if !defined(_WIN32) | |
| 209 | - char *codeset_name; | |
| 210 | -#endif | |
| 211 | - | |
| 212 | -#if !defined(_WIN32) | |
| 213 | - // Get all of the locale stuff right. | |
| 214 | - | |
| 215 | - // Figure out the locale code set (character set encoding). | |
| 216 | - codeset_name = nl_langinfo(CODESET); | |
| 217 | - Trace("codeset_name: %s",codeset_name); | |
| 218 | - set_codeset(codeset_name); | |
| 219 | -#endif | |
| 220 | -*/ | |
| 221 | - | |
| 222 | 206 | |
| 223 | 207 | /* Do nothing, successfully. */ |
| 224 | 208 | if (csname == CN || !strcasecmp(csname, "us")) |
| 225 | 209 | { |
| 226 | 210 | charset_defaults(); |
| 227 | 211 | set_cgcsgids(CN); |
| 228 | -// set_charset_name(CN); | |
| 229 | 212 | set_display_charset(session, "ISO-8859-1"); |
| 230 | 213 | return CS_OKAY; |
| 231 | 214 | } |
| 232 | 215 | |
| 233 | 216 | /* Figure out if it's already in a resource or in a file. */ |
| 234 | - cs = get_charset_def(csname); | |
| 235 | - if (cs == CN && | |
| 236 | - strlen(csname) > ES_SIZE && | |
| 237 | - !strcasecmp(csname + strlen(csname) - ES_SIZE, EURO_SUFFIX)) { | |
| 238 | - char *basename; | |
| 217 | +#ifdef ANDROID | |
| 218 | + ccs = strdup("0xad: [ \n 0xba: Yacute \n0xbd: ] \n 0xbb: diaeresis \n"); | |
| 219 | +#else | |
| 220 | + ccs = lib3270_get_resource_string("charset", csname, NULL); | |
| 221 | +#endif | |
| 222 | +/* | |
| 223 | + if (cs == CN && strlen(csname) > ES_SIZE && !strcasecmp(csname + strlen(csname) - ES_SIZE, EURO_SUFFIX)) | |
| 224 | + { | |
| 225 | + char *basename = | |
| 226 | + lib3270_free(cs); | |
| 239 | 227 | |
| 240 | - /* Grab the non-Euro definition. */ | |
| 228 | + // Grab the non-Euro definition. | |
| 241 | 229 | basename = xs_buffer("%.*s", (int) (strlen(csname) - ES_SIZE), csname); |
| 242 | 230 | cs = get_charset_def(basename); |
| 243 | 231 | Free(basename); |
| 244 | 232 | } |
| 245 | - if (cs == CN) | |
| 233 | +*/ | |
| 234 | + if (!ccs) | |
| 246 | 235 | return CS_NOTFOUND; |
| 247 | 236 | |
| 248 | 237 | /* Grab the File Transfer character set. */ |
| 249 | - ftcs = get_fresource("%s.%s", ResFtCharset, csname); | |
| 250 | - | |
| 251 | - /* Copy strings. */ | |
| 252 | - ccs = NewString(cs); | |
| 253 | - cftcs = (ftcs == NULL)? NULL: NewString(ftcs); | |
| 238 | + cftcs = lib3270_get_resource_string("ftCharset",csname,NULL); | |
| 254 | 239 | |
| 255 | 240 | /* Save the current definitions, and start over with the defaults. */ |
| 256 | 241 | save_charset(); |
| 257 | 242 | charset_defaults(); |
| 258 | 243 | |
| 259 | 244 | /* Check for auto-keymap. */ |
| 260 | - ak = get_fresource("%s.%s", ResAutoKeymap, csname); | |
| 245 | + ak = lib3270_get_resource_string("autoKeymap", csname, NULL); | |
| 261 | 246 | if (ak != NULL) |
| 262 | 247 | auto_keymap = !strcasecmp(ak, "true"); |
| 263 | 248 | else |
| ... | ... | @@ -277,12 +262,15 @@ enum cs_result charset_init(H3270 *session, char *csname) |
| 277 | 262 | |
| 278 | 263 | if (rc != CS_OKAY) |
| 279 | 264 | restore_charset(); |
| 280 | -#if defined(X3270_DBCS) /*[*/ | |
| 265 | + | |
| 266 | +/* | |
| 267 | +#if defined(X3270_DBCS) | |
| 281 | 268 | else if (wide_resource_init(csname) < 0) { |
| 282 | 269 | restore_charset(); |
| 283 | 270 | return CS_NOTFOUND; |
| 284 | 271 | } |
| 285 | -#endif /*]*/ | |
| 272 | +#endif | |
| 273 | +*/ | |
| 286 | 274 | |
| 287 | 275 | /* |
| 288 | 276 | #if defined(X3270_DISPLAY) |
| ... | ... | @@ -384,11 +372,11 @@ set_charset_name(char *csname) |
| 384 | 372 | /* Define a charset from resources. */ |
| 385 | 373 | static enum cs_result resource_charset(char *csname, char *cs, char *ftcs) |
| 386 | 374 | { |
| 387 | - enum cs_result rc; | |
| 388 | - int ne = 0; | |
| 389 | - const char *rcs = CN; | |
| 390 | - int n_rcs = 0; | |
| 391 | - const char *dcs; | |
| 375 | + enum cs_result rc; | |
| 376 | + int ne = 0; | |
| 377 | + char * rcs = CN; | |
| 378 | + int n_rcs = 0; | |
| 379 | + char * dcs; | |
| 392 | 380 | |
| 393 | 381 | /* Interpret the spec. */ |
| 394 | 382 | rc = remap_chars(csname, cs, (ftcs == NULL)? BOTH: CS_ONLY, &ne); |
| ... | ... | @@ -400,37 +388,44 @@ static enum cs_result resource_charset(char *csname, char *cs, char *ftcs) |
| 400 | 388 | return rc; |
| 401 | 389 | } |
| 402 | 390 | |
| 403 | - rcs = get_fresource("%s.%s", ResDisplayCharset, csname); | |
| 391 | +// rcs = get_fresource("%s.%s", "displayCharset", csname); | |
| 392 | + rcs = lib3270_get_resource_string("displayCharset", csname, NULL); | |
| 404 | 393 | |
| 405 | 394 | /* Isolate the pieces. */ |
| 406 | - if (rcs != CN) { | |
| 407 | - char *rcs_copy, *buf, *token; | |
| 395 | + if (rcs != CN) | |
| 396 | + { | |
| 397 | + char *buf, *token; | |
| 408 | 398 | |
| 409 | - buf = rcs_copy = NewString(rcs); | |
| 410 | - while ((token = strtok(buf, "+")) != CN) { | |
| 399 | + buf = rcs; | |
| 400 | + while ((token = strtok(buf, "+")) != CN) | |
| 401 | + { | |
| 411 | 402 | buf = CN; |
| 412 | - switch (n_rcs) { | |
| 403 | + switch (n_rcs) | |
| 404 | + { | |
| 413 | 405 | case 0: |
| 414 | -#if defined(X3270_DBCS) /*[*/ | |
| 406 | +#if defined(X3270_DBCS) | |
| 415 | 407 | case 1: |
| 416 | -#endif /*]*/ | |
| 408 | +#endif | |
| 417 | 409 | break; |
| 418 | 410 | default: |
| 419 | - popup_an_error(NULL,"Extra %s value(s), ignoring", | |
| 420 | - ResDisplayCharset); | |
| 411 | + popup_an_error(NULL,"Extra value(s) in displayCharset.%s, ignoring", csname); | |
| 421 | 412 | break; |
| 422 | 413 | } |
| 423 | 414 | n_rcs++; |
| 424 | 415 | } |
| 425 | 416 | } |
| 426 | 417 | |
| 427 | -#if defined(X3270_DBCS) /*[*/ | |
| 428 | - /* Can't swap DBCS modes while connected. */ | |
| 418 | + lib3270_free(rcs); | |
| 419 | + | |
| 420 | +/* | |
| 421 | +#if defined(X3270_DBCS) | |
| 422 | + // Can't swap DBCS modes while connected. | |
| 429 | 423 | if (IN_3270 && (n_rcs == 2) != dbcs) { |
| 430 | 424 | popup_an_error(NULL,"Can't change DBCS modes while connected"); |
| 431 | 425 | return CS_ILLEGAL; |
| 432 | 426 | } |
| 433 | -#endif /*]*/ | |
| 427 | +#endif | |
| 428 | +*/ | |
| 434 | 429 | |
| 435 | 430 | /* |
| 436 | 431 | #if !defined(_WIN32) |
| ... | ... | @@ -445,15 +440,23 @@ static enum cs_result resource_charset(char *csname, char *cs, char *ftcs) |
| 445 | 440 | */ |
| 446 | 441 | |
| 447 | 442 | /* Set up the cgcsgid. */ |
| 448 | - set_cgcsgids(get_fresource("%s.%s", ResCodepage, csname)); | |
| 443 | +// set_cgcsgids(get_fresource("%s.%s", "codepage", csname)); | |
| 444 | + { | |
| 445 | + char *ptr = lib3270_get_resource_string("codepage", csname, NULL); | |
| 446 | + set_cgcsgids(ptr); | |
| 447 | + lib3270_free(ptr); | |
| 448 | + } | |
| 449 | 449 | |
| 450 | - dcs = get_fresource("%s.%s", ResDisplayCharset, csname); | |
| 450 | +// dcs = get_fresource("%s.%s", "displayCharset", csname); | |
| 451 | + dcs = lib3270_get_resource_string("displayCharset", csname, NULL); | |
| 451 | 452 | |
| 452 | 453 | if (dcs != NULL) |
| 453 | 454 | set_display_charset(&h3270,dcs); |
| 454 | 455 | else |
| 455 | 456 | set_display_charset(&h3270,"ISO-8859-1"); |
| 456 | 457 | |
| 458 | + lib3270_free(dcs); | |
| 459 | + | |
| 457 | 460 | /* Set up the character set name. */ |
| 458 | 461 | // set_charset_name(csname); |
| 459 | 462 | ... | ... |
ctlr.c
| ... | ... | @@ -56,7 +56,7 @@ |
| 56 | 56 | #include "screenc.h" |
| 57 | 57 | #include "scrollc.h" |
| 58 | 58 | #include "seec.h" |
| 59 | -#include "sfc.h" | |
| 59 | +#include "sf.h" | |
| 60 | 60 | #include "statusc.h" |
| 61 | 61 | #include "tablesc.h" |
| 62 | 62 | #include "telnetc.h" |
| ... | ... | @@ -167,8 +167,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask) |
| 167 | 167 | struct ea *tmp; |
| 168 | 168 | size_t sz = (session->maxROWS * session->maxCOLS); |
| 169 | 169 | |
| 170 | - | |
| 171 | - session->buffer[0] = tmp = lib3270_calloc(sizeof(struct ea),sz+1, session->buffer[0]); | |
| 170 | + session->buffer[0] = tmp = lib3270_calloc(sizeof(struct ea), sz+1, session->buffer[0]); | |
| 172 | 171 | session->ea_buf = tmp + 1; |
| 173 | 172 | |
| 174 | 173 | session->buffer[1] = tmp = lib3270_calloc(sizeof(struct ea),sz+1,session->buffer[1]); | ... | ... |
kybd.c
| ... | ... | @@ -3461,7 +3461,7 @@ add_xk(KeySym key, KeySym assoc) |
| 3461 | 3461 | xk[i].assoc = assoc; |
| 3462 | 3462 | return; |
| 3463 | 3463 | } |
| 3464 | - xk = (struct xks *)Realloc(xk, (nxk + 1) * sizeof(struct xks)); | |
| 3464 | + xk = (struct xks *) Realloc(xk, (nxk + 1) * sizeof(struct xks)); | |
| 3465 | 3465 | xk[nxk].key = key; |
| 3466 | 3466 | xk[nxk].assoc = assoc; |
| 3467 | 3467 | nxk++; | ... | ... |
localdefs.h
| ... | ... | @@ -63,24 +63,15 @@ typedef struct _XtActionsRec{ |
| 63 | 63 | |
| 64 | 64 | /* These are local functions with similar semantics to X functions. */ |
| 65 | 65 | |
| 66 | -void * Malloc(size_t); | |
| 67 | -void Free(void *); | |
| 68 | -void * Calloc(size_t, size_t); | |
| 69 | -void * Realloc(void *, size_t); | |
| 66 | +// void * Malloc(size_t); | |
| 67 | +// void Free(void *); | |
| 68 | +// void * Calloc(size_t, size_t); | |
| 69 | +// void * Realloc(void *, size_t); | |
| 70 | 70 | |
| 71 | -/** | |
| 72 | - * Alloc/Realloc memory buffer. | |
| 73 | - * | |
| 74 | - * Allocate/reallocate an array. | |
| 75 | - * | |
| 76 | - * @param elsize Element size. | |
| 77 | - * @param nelem Number of elements in the array. | |
| 78 | - * @param ptr Pointer to the actual array. | |
| 79 | - * | |
| 80 | - * @return ptr allocated with the new array size. | |
| 81 | - * | |
| 82 | - */ | |
| 83 | -void * lib3270_calloc(size_t elsize, size_t nelem, void *ptr); | |
| 71 | +#define Malloc(x) lib3270_malloc(x) | |
| 72 | +#define Free(x) lib3270_free(x) | |
| 73 | +#define Calloc(e,n) lib3270_calloc(e,n,NULL) | |
| 74 | +#define Realloc(x,n) lib3270_realloc(x,n) | |
| 84 | 75 | |
| 85 | 76 | #define NewString(x) strdup(x) |
| 86 | 77 | //extern char *NewString(const char *); | ... | ... |
| ... | ... | @@ -64,6 +64,7 @@ |
| 64 | 64 | #include "telnetc.h" |
| 65 | 65 | #include "trace_dsc.h" |
| 66 | 66 | #include "utilc.h" |
| 67 | +#include "sf.h" | |
| 67 | 68 | |
| 68 | 69 | /* Statics */ |
| 69 | 70 | static Boolean select_rpq_terms(void); |
| ... | ... | @@ -121,8 +122,7 @@ static char *x3270rpq; |
| 121 | 122 | /* |
| 122 | 123 | * RPQNAMES query reply. |
| 123 | 124 | */ |
| 124 | -void | |
| 125 | -do_qr_rpqnames(void) | |
| 125 | +void do_qr_rpqnames(void) | |
| 126 | 126 | { |
| 127 | 127 | #define TERM_PREFIX_SIZE 2 /* Each term has 1 byte length and 1 |
| 128 | 128 | byte id */ | ... | ... |
| ... | ... | @@ -56,7 +56,7 @@ |
| 56 | 56 | #include "kybdc.h" |
| 57 | 57 | #include "screenc.h" |
| 58 | 58 | #include "seec.h" |
| 59 | -#include "sfc.h" | |
| 59 | +#include "sf.h" | |
| 60 | 60 | #include "tablesc.h" |
| 61 | 61 | #include "telnetc.h" |
| 62 | 62 | #include "trace_dsc.h" |
| ... | ... | @@ -92,13 +92,13 @@ static void query_reply_start(void); |
| 92 | 92 | static void do_query_reply(unsigned char code); |
| 93 | 93 | static void query_reply_end(void); |
| 94 | 94 | |
| 95 | -typedef void qr_single_fn_t(void); | |
| 96 | 95 | typedef Boolean qr_multi_fn_t(unsigned *subindex, Boolean *more); |
| 97 | 96 | |
| 98 | 97 | static qr_single_fn_t do_qr_summary, do_qr_usable_area, do_qr_alpha_part, |
| 99 | 98 | do_qr_charsets, do_qr_color, do_qr_highlighting, do_qr_reply_modes, |
| 100 | 99 | do_qr_imp_part, do_qr_null; |
| 101 | -extern qr_single_fn_t do_qr_rpqnames; | |
| 100 | + | |
| 101 | + | |
| 102 | 102 | #if defined(X3270_DBCS) /*[*/ |
| 103 | 103 | static qr_single_fn_t do_qr_dbcs_asia; |
| 104 | 104 | #endif /*]*/ |
| ... | ... | @@ -121,10 +121,15 @@ static struct reply { |
| 121 | 121 | #if defined(X3270_DBCS) /*[*/ |
| 122 | 122 | { QR_DBCS_ASIA, do_qr_dbcs_asia, NULL }, /* 0x91 */ |
| 123 | 123 | #endif /*]*/ |
| 124 | + | |
| 124 | 125 | #if defined(X3270_FT) /*[*/ |
| 125 | 126 | { QR_DDM, do_qr_ddm, NULL }, /* 0x95 */ |
| 126 | 127 | #endif /*]*/ |
| 128 | + | |
| 129 | +#ifndef ANDROID | |
| 127 | 130 | { QR_RPQNAMES, do_qr_rpqnames, NULL }, /* 0xa1 */ |
| 131 | +#endif // !ANDROID | |
| 132 | + | |
| 128 | 133 | { QR_IMP_PART, do_qr_imp_part, NULL }, /* 0xa6 */ |
| 129 | 134 | |
| 130 | 135 | /* QR_NULL must be last in the table */ | ... | ... |
| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | +/* | |
| 2 | + * Copyright 1995, 1999, 2000 by Paul Mattes. | |
| 3 | + * Permission to use, copy, modify, and distribute this software and its | |
| 4 | + * documentation for any purpose and without fee is hereby granted, | |
| 5 | + * provided that the above copyright notice appear in all copies and that | |
| 6 | + * both that copyright notice and this permission notice appear in | |
| 7 | + * supporting documentation. | |
| 8 | + * | |
| 9 | + * x3270, c3270, s3270, tcl3270 and pr3287 are distributed in the hope that | |
| 10 | + * they will be useful, but WITHOUT ANY WARRANTY; without even the implied | |
| 11 | + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + * file LICENSE for more details. | |
| 13 | + */ | |
| 14 | + | |
| 15 | +typedef void qr_single_fn_t(void); | |
| 16 | + | |
| 17 | +LIB3270_INTERNAL qr_single_fn_t do_qr_rpqnames; | |
| 18 | + | |
| 19 | +LIB3270_INTERNAL enum pds write_structured_field(unsigned char buf[], int buflen); | ... | ... |
sfc.h
| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | -/* | |
| 2 | - * Copyright 1995, 1999, 2000 by Paul Mattes. | |
| 3 | - * Permission to use, copy, modify, and distribute this software and its | |
| 4 | - * documentation for any purpose and without fee is hereby granted, | |
| 5 | - * provided that the above copyright notice appear in all copies and that | |
| 6 | - * both that copyright notice and this permission notice appear in | |
| 7 | - * supporting documentation. | |
| 8 | - * | |
| 9 | - * x3270, c3270, s3270, tcl3270 and pr3287 are distributed in the hope that | |
| 10 | - * they will be useful, but WITHOUT ANY WARRANTY; without even the implied | |
| 11 | - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | - * file LICENSE for more details. | |
| 13 | - */ | |
| 14 | - | |
| 15 | -/* | |
| 16 | - * sfc.h | |
| 17 | - * Global declarations for sf.c. | |
| 18 | - */ | |
| 19 | - | |
| 20 | -LIB3270_INTERNAL enum pds write_structured_field(unsigned char buf[], int buflen); |
util.c
| ... | ... | @@ -1087,3 +1087,100 @@ StringToKeysym(char *s) |
| 1087 | 1087 | } |
| 1088 | 1088 | #endif |
| 1089 | 1089 | */ |
| 1090 | + | |
| 1091 | +LIB3270_EXPORT void lib3270_free(void *p) | |
| 1092 | +{ | |
| 1093 | + if(p) | |
| 1094 | + free(p); | |
| 1095 | +} | |
| 1096 | + | |
| 1097 | +LIB3270_EXPORT void * lib3270_realloc(void *p, int len) | |
| 1098 | +{ | |
| 1099 | + p = realloc(p, len); | |
| 1100 | + if(!p) | |
| 1101 | + Error(NULL,"Out of memory"); | |
| 1102 | + return p; | |
| 1103 | +} | |
| 1104 | + | |
| 1105 | +LIB3270_EXPORT void * lib3270_calloc(int elsize, int nelem, void *ptr) | |
| 1106 | +{ | |
| 1107 | + size_t sz = nelem * elsize; | |
| 1108 | + | |
| 1109 | + if(ptr) | |
| 1110 | + ptr = realloc(ptr,sz); | |
| 1111 | + else | |
| 1112 | + ptr = malloc(sz); | |
| 1113 | + | |
| 1114 | + if(ptr) | |
| 1115 | + memset(ptr,0,sz); | |
| 1116 | + else | |
| 1117 | + Error(NULL,"Out of memory"); | |
| 1118 | + | |
| 1119 | + return ptr; | |
| 1120 | +} | |
| 1121 | + | |
| 1122 | + | |
| 1123 | +LIB3270_EXPORT void * lib3270_malloc(int len) | |
| 1124 | +{ | |
| 1125 | + char *r; | |
| 1126 | + | |
| 1127 | + r = malloc(len); | |
| 1128 | + if (r == (char *)NULL) | |
| 1129 | + { | |
| 1130 | + Error(NULL,"Out of memory"); | |
| 1131 | + return 0; | |
| 1132 | + } | |
| 1133 | + | |
| 1134 | + memset(r,0,len); | |
| 1135 | + return r; | |
| 1136 | +} | |
| 1137 | + | |
| 1138 | +/* | |
| 1139 | +void * Calloc(size_t nelem, size_t elsize) | |
| 1140 | +{ | |
| 1141 | + int sz = nelem * elsize; | |
| 1142 | + char * r = malloc(sz); | |
| 1143 | + | |
| 1144 | + if(!r) | |
| 1145 | + Error(NULL,"Out of memory"); | |
| 1146 | + | |
| 1147 | + memset(r, 0, sz); | |
| 1148 | + return r; | |
| 1149 | +} | |
| 1150 | +*/ | |
| 1151 | + | |
| 1152 | +LIB3270_EXPORT char * lib3270_get_resource_string(const char *first_element, ...) | |
| 1153 | +{ | |
| 1154 | +#ifndef ANDROID | |
| 1155 | + | |
| 1156 | + #warning Work in progress | |
| 1157 | + | |
| 1158 | + char buffer[4096]; | |
| 1159 | + char * ptr = buffer; | |
| 1160 | + const char * element; | |
| 1161 | + va_list args; | |
| 1162 | + const char * res; | |
| 1163 | + | |
| 1164 | + va_start(args, first_element); | |
| 1165 | + | |
| 1166 | + for(element = first_element;element;element = va_arg(args, const char *)) | |
| 1167 | + { | |
| 1168 | + if(ptr != buffer) | |
| 1169 | + *(ptr++) = '.'; | |
| 1170 | + | |
| 1171 | + strncpy(ptr,element,4096-strlen(buffer)); | |
| 1172 | + ptr += strlen(ptr); | |
| 1173 | + } | |
| 1174 | + | |
| 1175 | + va_end(args); | |
| 1176 | + | |
| 1177 | + *ptr = 0; | |
| 1178 | + | |
| 1179 | + trace("%s: %s",__FUNCTION__,buffer); | |
| 1180 | + | |
| 1181 | + res = get_resource(buffer); | |
| 1182 | + if(res) | |
| 1183 | + return strdup(res); | |
| 1184 | +#endif | |
| 1185 | + return NULL; | |
| 1186 | +} | ... | ... |