Commit b644c5fabe08f74fc4b44f0fca0ae3d01ab08b71
1 parent
63c47e5d
Exists in
master
and in
3 other branches
Atualizando tratamento de logs e popups de erro
Showing
14 changed files
with
196 additions
and
294 deletions
Show diff stats
XtGlue.c
| ... | ... | @@ -461,7 +461,7 @@ static int DefaultProcessEvents(int block) |
| 461 | 461 | if (ns < 0) |
| 462 | 462 | { |
| 463 | 463 | if (errno != EINTR) |
| 464 | - Warning( "process_events: select() failed" ); | |
| 464 | + Warning(NULL, "process_events: select() failed" ); | |
| 465 | 465 | #endif |
| 466 | 466 | return processed_any; |
| 467 | 467 | } |
| ... | ... | @@ -555,7 +555,7 @@ Malloc(size_t len) |
| 555 | 555 | |
| 556 | 556 | r = malloc(len); |
| 557 | 557 | if (r == (char *)NULL) |
| 558 | - Error("Out of memory"); | |
| 558 | + Error(NULL,"Out of memory"); | |
| 559 | 559 | return r; |
| 560 | 560 | } |
| 561 | 561 | |
| ... | ... | @@ -566,7 +566,7 @@ Calloc(size_t nelem, size_t elsize) |
| 566 | 566 | char *r = malloc(sz); |
| 567 | 567 | |
| 568 | 568 | if(!r) |
| 569 | - Error("Out of memory"); | |
| 569 | + Error(NULL,"Out of memory"); | |
| 570 | 570 | |
| 571 | 571 | memset(r, 0, sz); |
| 572 | 572 | return r; |
| ... | ... | @@ -577,7 +577,7 @@ Realloc(void *p, size_t len) |
| 577 | 577 | { |
| 578 | 578 | p = realloc(p, len); |
| 579 | 579 | if (p == NULL) |
| 580 | - Error("Out of memory"); | |
| 580 | + Error(NULL,"Out of memory"); | |
| 581 | 581 | return p; |
| 582 | 582 | } |
| 583 | 583 | ... | ... |
| ... | ... | @@ -98,14 +98,14 @@ |
| 98 | 98 | #endif |
| 99 | 99 | |
| 100 | 100 | |
| 101 | - LOCAL_EXTERN int Set3270Log(const char *filename); | |
| 102 | - LOCAL_EXTERN int WriteLog(const char *module, const char *fmt, ...); | |
| 103 | - LOCAL_EXTERN int WriteRCLog(const char *module, int rc, const char *fmt, ...); | |
| 101 | + #include <lib3270/log.h> | |
| 102 | + #define WriteLog(module,fmt, ...) lib3270_write_log(NULL,module,fmt,__VA_ARGS__) | |
| 103 | + #define WriteRCLog(module,rc,fmt, ...) lib3270_write_rc(NULL,module,fmt,__VA_ARGS__) | |
| 104 | 104 | |
| 105 | 105 | #ifdef LIB3270_MODULE_NAME |
| 106 | - #define Log(fmt, ...) WriteLog(LIB3270_MODULE_NAME,fmt,__VA_ARGS__) | |
| 106 | + #define Log(fmt, ...) lib3270_write_log(NULL,LIB3270_MODULE_NAME,fmt,__VA_ARGS__) | |
| 107 | 107 | #else |
| 108 | - #define Log(fmt, ...) WriteLog("MSG",fmt,__VA_ARGS__) | |
| 108 | + #define Log(fmt, ...) lib3270_write_log(NULL,"MSG",fmt,__VA_ARGS__) | |
| 109 | 109 | #endif |
| 110 | 110 | |
| 111 | 111 | /** 3270 connection handle */ |
| ... | ... | @@ -179,13 +179,19 @@ |
| 179 | 179 | |
| 180 | 180 | |
| 181 | 181 | /** Type of dialog boxes */ |
| 182 | - typedef enum _PW3270_DIALOG | |
| 182 | + typedef enum _LIB3270_NOTIFY | |
| 183 | 183 | { |
| 184 | - PW3270_DIALOG_INFO, /**< Simple information dialog */ | |
| 185 | - PW3270_DIALOG_CRITICAL, /**< Critical error, user can abort application */ | |
| 184 | + LIB3270_NOTIFY_INFO, /**< Simple information dialog */ | |
| 185 | + LIB3270_NOTIFY_WARNING, | |
| 186 | + LIB3270_NOTIFY_ERROR, | |
| 187 | + LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */ | |
| 186 | 188 | |
| 187 | - PW3270_DIALOG_USER | |
| 188 | - } PW3270_DIALOG; | |
| 189 | + LIB3270_NOTIFY_USER /**< Reserver, always the last one */ | |
| 190 | + } LIB3270_NOTIFY; | |
| 191 | + | |
| 192 | + #define PW3270_DIALOG_INFO LIB3270_NOTIFY_INFO | |
| 193 | + #define PW3270_DIALOG_CRITICAL LIB3270_NOTIFY_CRITICAL | |
| 194 | + #define PW3270_DIALOG LIB3270_NOTIFY | |
| 189 | 195 | |
| 190 | 196 | /** extended attributes */ |
| 191 | 197 | struct ea |
| ... | ... | @@ -336,10 +342,7 @@ |
| 336 | 342 | unsigned short sz; |
| 337 | 343 | |
| 338 | 344 | int (*init)(void); |
| 339 | - int (*popup_dialog)(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, va_list arg); | |
| 340 | - void (*Error)(const char *fmt, va_list arg); | |
| 341 | - void (*Warning)(const char *fmt, va_list arg); | |
| 342 | - void (*SysError)(const char *title, const char *message, const char *system); | |
| 345 | + int (*notify)(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); | |
| 343 | 346 | void (*model_changed)(H3270 *session, const char *name, int model, int rows, int cols); |
| 344 | 347 | int (*addch)(int row, int col, unsigned char c, unsigned short attr); |
| 345 | 348 | void (*charset)(char *dcs); |
| ... | ... | @@ -397,8 +400,8 @@ |
| 397 | 400 | LOCAL_EXTERN const struct lib3270_option * get_3270_option_table(int sz); |
| 398 | 401 | |
| 399 | 402 | /* Popups */ |
| 400 | - LOCAL_EXTERN void Error(const char *fmt, ...); | |
| 401 | - LOCAL_EXTERN void Warning(const char *fmt, ...); | |
| 403 | + LOCAL_EXTERN void Error(H3270 *session, const char *fmt, ...); | |
| 404 | + LOCAL_EXTERN void Warning(H3270 *session, const char *fmt, ...); | |
| 402 | 405 | LOCAL_EXTERN void show_3270_popup_dialog(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, ...); |
| 403 | 406 | |
| 404 | 407 | /* Set/Get screen contents */ |
| ... | ... | @@ -420,9 +423,9 @@ |
| 420 | 423 | LOCAL_EXTERN int Get3270Socket(void); |
| 421 | 424 | |
| 422 | 425 | /* Misc calls */ |
| 423 | - LOCAL_EXTERN void popup_an_error(const char *fmt, ...); | |
| 424 | - LOCAL_EXTERN void popup_system_error(const char *title, const char *message, const char *system); | |
| 425 | - LOCAL_EXTERN void popup_a_sockerr(char *fmt, ...); | |
| 426 | + LOCAL_EXTERN void popup_an_error(H3270 *session, const char *fmt, ...); | |
| 427 | + LOCAL_EXTERN void popup_system_error(H3270 *session, const char *title, const char *message, const char *fmt, ...); | |
| 428 | + LOCAL_EXTERN void popup_a_sockerr(H3270 *session, char *fmt, ...); | |
| 426 | 429 | |
| 427 | 430 | #define query_3270_terminal_status(void) lib3270_get_program_message(NULL) |
| 428 | 431 | ... | ... |
charset.c
| ... | ... | @@ -333,14 +333,13 @@ set_cgcsgids(char *spec) |
| 333 | 333 | break; |
| 334 | 334 | #endif /*]*/ |
| 335 | 335 | default: |
| 336 | - popup_an_error("Extra CGCSGID(s), ignoring"); | |
| 336 | + popup_an_error(NULL,"Extra CGCSGID(s), ignoring"); | |
| 337 | 337 | break; |
| 338 | 338 | } |
| 339 | 339 | if (idp == NULL) |
| 340 | 340 | break; |
| 341 | 341 | if (set_cgcsgid(token, idp) < 0) { |
| 342 | - popup_an_error("Invalid CGCSGID '%s', ignoring", | |
| 343 | - token); | |
| 342 | + popup_an_error(NULL,"Invalid CGCSGID '%s', ignoring",token); | |
| 344 | 343 | n_ids = -1; |
| 345 | 344 | break; |
| 346 | 345 | } |
| ... | ... | @@ -620,8 +619,7 @@ remap_chars(char *csname, char *spec, remap_scope scope, int *ne) |
| 620 | 619 | |
| 621 | 620 | while ((tok = strtok(s, " \t\n")) != CN) { |
| 622 | 621 | if (ebc >= 256) { |
| 623 | - popup_an_error("Charset has more than 256 " | |
| 624 | - "entries"); | |
| 622 | + popup_an_error(NULL,"Charset has more than 256 entries"); | |
| 625 | 623 | rc = CS_BAD; |
| 626 | 624 | break; |
| 627 | 625 | } |
| ... | ... | @@ -635,7 +633,7 @@ remap_chars(char *csname, char *spec, remap_scope scope, int *ne) |
| 635 | 633 | if (strlen(tok) == 1) |
| 636 | 634 | iso = tok[0] & 0xff; |
| 637 | 635 | else { |
| 638 | - popup_an_error("Invalid charset " | |
| 636 | + popup_an_error(NULL,"Invalid charset " | |
| 639 | 637 | "entry '%s' (#%d)", |
| 640 | 638 | tok, ebc); |
| 641 | 639 | rc = CS_BAD; | ... | ... |
glue.c
| ... | ... | @@ -988,7 +988,7 @@ read_resource_file(const char *filename, Boolean fatal) |
| 988 | 988 | if (*s == '#') { |
| 989 | 989 | (void) sprintf(where, "%s:%d: Invalid profile " |
| 990 | 990 | "syntax ('#' ignored)", filename, lno); |
| 991 | - Warning(where); | |
| 991 | + Warning(NULL,where); | |
| 992 | 992 | ilen = 0; |
| 993 | 993 | continue; |
| 994 | 994 | } |
| ... | ... | @@ -999,7 +999,7 @@ read_resource_file(const char *filename, Boolean fatal) |
| 999 | 999 | if (ilen >= sizeof(buf) - 1) { |
| 1000 | 1000 | (void) sprintf(where, "%s:%d: Line too long\n", |
| 1001 | 1001 | filename, lno); |
| 1002 | - Warning(where); | |
| 1002 | + Warning(NULL,where); | |
| 1003 | 1003 | break; |
| 1004 | 1004 | } |
| 1005 | 1005 | continue; |
| ... | ... | @@ -1045,8 +1045,7 @@ Boolean error_popup_visible = False; |
| 1045 | 1045 | |
| 1046 | 1046 | |
| 1047 | 1047 | /* Pop up an error dialog, based on an error number. */ |
| 1048 | -void | |
| 1049 | -popup_an_errno(int errn, const char *fmt, ...) | |
| 1048 | +void popup_an_errno(int errn, const char *fmt, ...) | |
| 1050 | 1049 | { |
| 1051 | 1050 | char vmsgbuf[4096]; |
| 1052 | 1051 | va_list args; |
| ... | ... | @@ -1057,7 +1056,7 @@ popup_an_errno(int errn, const char *fmt, ...) |
| 1057 | 1056 | |
| 1058 | 1057 | WriteLog("3270", "Error Popup:\n%s\nrc=%d (%s)",vmsgbuf,errn,strerror(errn)); |
| 1059 | 1058 | |
| 1060 | - Error(vmsgbuf); | |
| 1059 | + Error(NULL,vmsgbuf); | |
| 1061 | 1060 | } |
| 1062 | 1061 | |
| 1063 | 1062 | #ifdef DEBUG | ... | ... |
host.c
| ... | ... | @@ -225,7 +225,7 @@ parse_localprocess(const char *s) |
| 225 | 225 | * Returns NULL if there is a syntax error. |
| 226 | 226 | */ |
| 227 | 227 | static char * |
| 228 | -split_host(char *s, char *ansi, char *std_ds, char *passthru, | |
| 228 | +split_host(H3270 *hSession, char *s, char *ansi, char *std_ds, char *passthru, | |
| 229 | 229 | char *non_e, char *secure, char *no_login, char *xluname, |
| 230 | 230 | char **port, char *needed) |
| 231 | 231 | { |
| ... | ... | @@ -259,7 +259,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 259 | 259 | while (*s && isspace(*s)) |
| 260 | 260 | s++; |
| 261 | 261 | if (!*s) { |
| 262 | - popup_an_error("Empty hostname"); | |
| 262 | + popup_an_error(NULL,_( "Empty hostname" )); | |
| 263 | 263 | goto split_fail; |
| 264 | 264 | } |
| 265 | 265 | |
| ... | ... | @@ -297,8 +297,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 297 | 297 | *no_login = True; |
| 298 | 298 | break; |
| 299 | 299 | default: |
| 300 | - popup_an_error("Hostname syntax error:\n" | |
| 301 | - "Option '%c:' not supported", *s); | |
| 300 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),_("Option '%c:' not supported"),*s); | |
| 302 | 301 | goto split_fail; |
| 303 | 302 | } |
| 304 | 303 | *needed = True; |
| ... | ... | @@ -319,8 +318,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 319 | 318 | char *lu_last = at - 1; |
| 320 | 319 | |
| 321 | 320 | if (at == s) { |
| 322 | - popup_an_error("Hostname syntax error:\n" | |
| 323 | - "Empty LU name"); | |
| 321 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Empty LU name")); | |
| 324 | 322 | goto split_fail; |
| 325 | 323 | } |
| 326 | 324 | while (lu_last < s && isspace(*lu_last)) |
| ... | ... | @@ -332,9 +330,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 332 | 330 | while (isspace(*u)) |
| 333 | 331 | u++; |
| 334 | 332 | if (*u != '@') { |
| 335 | - popup_an_error("Hostname syntax " | |
| 336 | - "error:\n" | |
| 337 | - "Space in LU name"); | |
| 333 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Space in LU name")); | |
| 338 | 334 | goto split_fail; |
| 339 | 335 | } |
| 340 | 336 | break; |
| ... | ... | @@ -360,8 +356,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 360 | 356 | |
| 361 | 357 | /* Check for junk before the '['. */ |
| 362 | 358 | if (lbracket != s) { |
| 363 | - popup_an_error("Hostname syntax error:\n" | |
| 364 | - "Text before '['"); | |
| 359 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Text before '['")); | |
| 365 | 360 | goto split_fail; |
| 366 | 361 | } |
| 367 | 362 | |
| ... | ... | @@ -373,12 +368,11 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 373 | 368 | */ |
| 374 | 369 | rbracket = strchr(s, ']'); |
| 375 | 370 | if (rbracket == CN) { |
| 376 | - popup_an_error("Hostname syntax error:\n" | |
| 377 | - "Missing ']'"); | |
| 371 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Missing ']'")); | |
| 378 | 372 | goto split_fail; |
| 379 | 373 | } |
| 380 | 374 | if (rbracket == s) { |
| 381 | - popup_an_error("Empty hostname"); | |
| 375 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Empty hostname")); | |
| 382 | 376 | goto split_fail; |
| 383 | 377 | } |
| 384 | 378 | *rbracket = '\0'; |
| ... | ... | @@ -395,7 +389,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 395 | 389 | |
| 396 | 390 | /* Check for an empty string. */ |
| 397 | 391 | if (!*s || *s == ':') { |
| 398 | - popup_an_error("Empty hostname"); | |
| 392 | + popup_an_error(hSession,"Empty hostname"); | |
| 399 | 393 | goto split_fail; |
| 400 | 394 | } |
| 401 | 395 | |
| ... | ... | @@ -431,8 +425,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 431 | 425 | while (*s && isspace(*s)) |
| 432 | 426 | s++; |
| 433 | 427 | if (!*s) { |
| 434 | - popup_an_error("Hostname syntax error:\n" | |
| 435 | - "Empty port name"); | |
| 428 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Empty port name")); | |
| 436 | 429 | goto split_fail; |
| 437 | 430 | } |
| 438 | 431 | } |
| ... | ... | @@ -447,8 +440,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, |
| 447 | 440 | while (*s && !isspace(*s) && *s != ':') |
| 448 | 441 | s++; |
| 449 | 442 | if (*s != '\0') { |
| 450 | - popup_an_error("Hostname syntax error:\n" | |
| 451 | - "Multiple port names"); | |
| 443 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Multiple port names")); | |
| 452 | 444 | goto split_fail; |
| 453 | 445 | } |
| 454 | 446 | goto split_success; |
| ... | ... | @@ -482,7 +474,7 @@ static int do_connect(H3270 *hSession, const char *n) |
| 482 | 474 | while (*n == ' ') |
| 483 | 475 | n++; |
| 484 | 476 | if (!*n) { |
| 485 | - popup_an_error("Invalid (empty) hostname"); | |
| 477 | + popup_an_error(hSession,_( "Invalid (empty) hostname" )); | |
| 486 | 478 | return -1; |
| 487 | 479 | } |
| 488 | 480 | |
| ... | ... | @@ -512,7 +504,7 @@ static int do_connect(H3270 *hSession, const char *n) |
| 512 | 504 | Boolean needed; |
| 513 | 505 | |
| 514 | 506 | /* Strip off and remember leading qualifiers. */ |
| 515 | - if ((s = split_host(nb, &ansi_host, &hSession->std_ds_host, | |
| 507 | + if ((s = split_host(hSession, nb, &ansi_host, &hSession->std_ds_host, | |
| 516 | 508 | &hSession->passthru_host, &hSession->non_tn3270e_host, &hSession->ssl_host, |
| 517 | 509 | &hSession->no_login_host, hSession->luname, &port, |
| 518 | 510 | &needed)) == CN) | ... | ... |
kybd.c
| ... | ... | @@ -30,122 +30,56 @@ |
| 30 | 30 | * |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | - | |
| 34 | -#include <string.h> | |
| 35 | 33 | #include <stdio.h> |
| 36 | 34 | #include <stdarg.h> |
| 37 | -#include <errno.h> | |
| 38 | -#include <time.h> | |
| 39 | -#include <fcntl.h> | |
| 40 | 35 | #include <lib3270/config.h> |
| 41 | 36 | #include <lib3270.h> |
| 37 | +#include <lib3270/log.h> | |
| 38 | +#include "api.h" | |
| 39 | + | |
| 40 | +/*---[ Prototipes ]-----------------------------------------------------------------------------------------*/ | |
| 41 | + | |
| 42 | + static void defaultlog(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr); | |
| 42 | 43 | |
| 43 | 44 | /*---[ Constants ]------------------------------------------------------------------------------------------*/ |
| 44 | 45 | |
| 45 | - static char logfile[FILENAME_MAX] = PACKAGE_NAME ".log"; | |
| 46 | + static void (*loghandler)(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr) = defaultlog; | |
| 46 | 47 | |
| 47 | 48 | /*---[ Implementacao ]--------------------------------------------------------------------------------------*/ |
| 48 | 49 | |
| 49 | - int Set3270Log(const char *filename) | |
| 50 | + LIB3270_EXPORT void lib3270_set_log_handler(void (*handler)(H3270 *, const char *, int, const char *, va_list)) | |
| 50 | 51 | { |
| 51 | - FILE *out; | |
| 52 | - | |
| 53 | - if(strlen(filename) >= FILENAME_MAX) | |
| 54 | - return EINVAL; | |
| 55 | - | |
| 56 | - out = fopen(filename,"a"); | |
| 57 | - | |
| 58 | - if(out) | |
| 59 | - { | |
| 60 | - strcpy(logfile,filename); | |
| 61 | - fclose(out); | |
| 62 | -#if defined(linux) | |
| 63 | - printf("Logfile set to %s\n",logfile); | |
| 64 | -#endif | |
| 65 | - return 0; | |
| 66 | - } | |
| 67 | - | |
| 68 | - return errno; | |
| 52 | + loghandler = handler ? handler : defaultlog; | |
| 69 | 53 | } |
| 70 | 54 | |
| 71 | - static void writetime(FILE *out, const char *module) | |
| 55 | + LIB3270_EXPORT int lib3270_write_log(H3270 *session, const char *module, const char *fmt, ...) | |
| 72 | 56 | { |
| 73 | - time_t ltime; | |
| 74 | - char wrk[40]; | |
| 75 | - | |
| 76 | - time(<ime); | |
| 77 | - strftime(wrk, 39, "%d/%m/%Y %H:%M:%S", localtime(<ime)); | |
| 78 | - fprintf(out,"%s %-8s\t",wrk,module); | |
| 57 | + va_list arg_ptr; | |
| 58 | + va_start(arg_ptr, fmt); | |
| 59 | + loghandler(session,module,0,fmt,arg_ptr); | |
| 60 | + va_end(arg_ptr); | |
| 61 | + return 0; | |
| 79 | 62 | } |
| 80 | 63 | |
| 81 | - static FILE *prefix(const char *module) | |
| 64 | + LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc, const char *fmt, ...) | |
| 82 | 65 | { |
| 83 | - FILE *out = fopen(logfile,"a"); | |
| 84 | - if(out) | |
| 85 | - writetime(out,module); | |
| 86 | - return out; | |
| 66 | + va_list arg_ptr; | |
| 67 | + va_start(arg_ptr, fmt); | |
| 68 | + loghandler(session,module,rc,fmt,arg_ptr); | |
| 69 | + va_end(arg_ptr); | |
| 70 | + return rc; | |
| 87 | 71 | } |
| 88 | 72 | |
| 89 | - /** | |
| 90 | - * Grava uma entrada no arquivo de log. | |
| 91 | - * | |
| 92 | - * @param module Identificador do modulo para gravacao no arquivo | |
| 93 | - * @param fmt String de formatacao para a mensagem no mesmo formato da funcao printf() | |
| 94 | - * @param ... Argumentos de acordo com a string de formatacao | |
| 95 | - */ | |
| 96 | - int WriteLog(const char *module, const char *fmt, ...) | |
| 73 | + LIB3270_EXPORT void lib3270_write_va_log(H3270 *session, const char *module, const char *fmt, va_list arg) | |
| 97 | 74 | { |
| 98 | - va_list arg_ptr; | |
| 99 | - FILE *out; | |
| 100 | - | |
| 101 | - out = prefix(module); | |
| 102 | - if(!out) | |
| 103 | - return -1; | |
| 104 | - | |
| 105 | - va_start(arg_ptr, fmt); | |
| 106 | - vfprintf(out, fmt, arg_ptr); | |
| 107 | - va_end(arg_ptr); | |
| 108 | - fprintf(out,"\n"); | |
| 109 | - | |
| 110 | - fclose(out); | |
| 111 | - | |
| 112 | - return 0; | |
| 75 | + loghandler(session,module,0,fmt,arg); | |
| 113 | 76 | } |
| 114 | 77 | |
| 115 | - /** | |
| 116 | - * Grava mensagem de erro. | |
| 117 | - * | |
| 118 | - * Grava uma mensagem de erro no arquivo de log. | |
| 119 | - * | |
| 120 | - * @param module Identificador do modulo para gravacao no arquivo | |
| 121 | - * @param rc Codigo de erro ou -1 para usar o valor de errno | |
| 122 | - * @param fmt String de formatacao para a mensagem no mesmo formato da funcao printf() | |
| 123 | - * @param ... Argumentos de acordo com a string de formatacao | |
| 124 | - */ | |
| 125 | - int WriteRCLog(const char *module, int rc, const char *fmt, ...) | |
| 78 | + static void defaultlog(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr) | |
| 126 | 79 | { |
| 127 | - FILE *out; | |
| 128 | - va_list arg_ptr; | |
| 129 | - | |
| 130 | - if(rc == -1) | |
| 131 | - rc = errno; | |
| 132 | - | |
| 133 | - if(!rc) | |
| 134 | - return 0; | |
| 135 | - | |
| 136 | - out = prefix(module); | |
| 137 | - if(!out) | |
| 138 | - return -1; | |
| 139 | - | |
| 140 | - va_start(arg_ptr, fmt); | |
| 141 | - vfprintf(out, fmt, arg_ptr); | |
| 142 | - va_end(arg_ptr); | |
| 143 | - | |
| 144 | - fprintf(out,": %s (rc=%d)\n",strerror(rc),rc); | |
| 145 | - | |
| 146 | - fclose(out); | |
| 147 | - | |
| 148 | - return rc; | |
| 80 | + fprintf(stderr,"%s:\t",module); | |
| 81 | + vfprintf(stderr,fmt,arg_ptr); | |
| 82 | + fprintf(stderr,"\n"); | |
| 83 | + fflush(stderr); | |
| 149 | 84 | } |
| 150 | 85 | |
| 151 | - | ... | ... |
printer.c
| ... | ... | @@ -157,13 +157,13 @@ printer_start(const char *lu) |
| 157 | 157 | |
| 158 | 158 | /* Can't start two. */ |
| 159 | 159 | if (printer_pid != -1) { |
| 160 | - popup_an_error("printer is already running"); | |
| 160 | + popup_an_error(NULL,"printer is already running"); | |
| 161 | 161 | return; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /* Gotta be in 3270 mode. */ |
| 165 | 165 | if (!IN_3270) { |
| 166 | - popup_an_error("Not in 3270 mode"); | |
| 166 | + popup_an_error(NULL,"Not in 3270 mode"); | |
| 167 | 167 | return; |
| 168 | 168 | } |
| 169 | 169 | |
| ... | ... | @@ -173,13 +173,13 @@ printer_start(const char *lu) |
| 173 | 173 | |
| 174 | 174 | /* Gotta be in TN3270E mode. */ |
| 175 | 175 | if (!IN_TN3270E) { |
| 176 | - popup_an_error("Not in TN3270E mode"); | |
| 176 | + popup_an_error(NULL,"Not in TN3270E mode"); | |
| 177 | 177 | return; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /* Gotta be connected to an LU. */ |
| 181 | 181 | if (h3270.connected_lu == CN) { |
| 182 | - popup_an_error("Not connected to a specific LU"); | |
| 182 | + popup_an_error(NULL,"Not connected to a specific LU"); | |
| 183 | 183 | return; |
| 184 | 184 | } |
| 185 | 185 | lu = h3270.connected_lu; |
| ... | ... | @@ -192,13 +192,13 @@ printer_start(const char *lu) |
| 192 | 192 | /* Fetch the command line and command resources. */ |
| 193 | 193 | cmdline = get_resource(cmdlineName); |
| 194 | 194 | if (cmdline == CN) { |
| 195 | - popup_an_error("%s resource not defined", cmdlineName); | |
| 195 | + popup_an_error(NULL,"%s resource not defined", cmdlineName); | |
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | #if !defined(_WIN32) /*[*/ |
| 199 | 199 | cmd = get_resource(ResPrinterCommand); |
| 200 | 200 | if (cmd == CN) { |
| 201 | - popup_an_error("printer.command resource not defined"); | |
| 201 | + popup_an_error(NULL,"printer.command resource not defined"); | |
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | #else /*][*/ |
| ... | ... | @@ -496,7 +496,7 @@ printer_data(struct pr3o *p, Boolean is_err) |
| 496 | 496 | p->count = PRINTER_BUF - 1; |
| 497 | 497 | printer_dump(p, True, True); |
| 498 | 498 | } else { |
| 499 | - popup_an_error(exitmsg); | |
| 499 | + popup_an_error(NULL,exitmsg); | |
| 500 | 500 | } |
| 501 | 501 | printer_stop(); |
| 502 | 502 | return; | ... | ... |
proxy.c
| ... | ... | @@ -158,7 +158,7 @@ proxy_setup(char **phost, char **pport) |
| 158 | 158 | return PT_NONE; |
| 159 | 159 | |
| 160 | 160 | if ((colon = strchr(proxy, ':')) == CN || (colon == proxy)) { |
| 161 | - popup_an_error("Invalid proxy syntax"); | |
| 161 | + popup_an_error(NULL,"Invalid proxy syntax"); | |
| 162 | 162 | return -1; |
| 163 | 163 | } |
| 164 | 164 | |
| ... | ... | @@ -187,7 +187,7 @@ proxy_setup(char **phost, char **pport) |
| 187 | 187 | if (parse_host_port(colon + 1, phost, pport) < 0) |
| 188 | 188 | return -1; |
| 189 | 189 | if (*pport == CN) { |
| 190 | - popup_an_error("Must specify port for telnet proxy"); | |
| 190 | + popup_an_error(NULL,"Must specify port for telnet proxy"); | |
| 191 | 191 | return -1; |
| 192 | 192 | } |
| 193 | 193 | return PT_TELNET; |
| ... | ... | @@ -255,7 +255,7 @@ parse_host_port(char *s, char **phost, char **pport) |
| 255 | 255 | rbrack == s + 1 || |
| 256 | 256 | (*(rbrack + 1) != '\0' && *(rbrack + 1) != ':')) { |
| 257 | 257 | |
| 258 | - popup_an_error("Invalid proxy hostname syntax"); | |
| 258 | + popup_an_error(NULL,"Invalid proxy hostname syntax"); | |
| 259 | 259 | return -1; |
| 260 | 260 | } |
| 261 | 261 | if (*(rbrack + 1) == ':') |
| ... | ... | @@ -267,7 +267,7 @@ parse_host_port(char *s, char **phost, char **pport) |
| 267 | 267 | hstart = s; |
| 268 | 268 | colon = strchr(s, ':'); |
| 269 | 269 | if (colon == s) { |
| 270 | - popup_an_error("Invalid proxy hostname syntax"); | |
| 270 | + popup_an_error(NULL,"Invalid proxy hostname syntax"); | |
| 271 | 271 | return -1; |
| 272 | 272 | } |
| 273 | 273 | if (colon == NULL) |
| ... | ... | @@ -333,7 +333,7 @@ proxy_passthru(int fd, char *host, unsigned short port) |
| 333 | 333 | #endif /*]*/ |
| 334 | 334 | |
| 335 | 335 | if (send(fd, buf, strlen(buf), 0) < 0) { |
| 336 | - popup_a_sockerr("Passthru Proxy: send error"); | |
| 336 | + popup_a_sockerr(NULL,"Passthru Proxy: send error"); | |
| 337 | 337 | Free(buf); |
| 338 | 338 | return -1; |
| 339 | 339 | } |
| ... | ... | @@ -368,7 +368,7 @@ proxy_http(int fd, char *host, unsigned short port) |
| 368 | 368 | #endif /*]*/ |
| 369 | 369 | |
| 370 | 370 | if (send(fd, buf, strlen(buf), 0) < 0) { |
| 371 | - popup_a_sockerr("HTTP Proxy: send error"); | |
| 371 | + popup_a_sockerr(NULL,"HTTP Proxy: send error"); | |
| 372 | 372 | Free(buf); |
| 373 | 373 | return -1; |
| 374 | 374 | } |
| ... | ... | @@ -385,7 +385,7 @@ proxy_http(int fd, char *host, unsigned short port) |
| 385 | 385 | #endif /*]*/ |
| 386 | 386 | |
| 387 | 387 | if (send(fd, buf, strlen(buf), 0) < 0) { |
| 388 | - popup_a_sockerr("HTTP Proxy: send error"); | |
| 388 | + popup_a_sockerr(NULL,"HTTP Proxy: send error"); | |
| 389 | 389 | Free(buf); |
| 390 | 390 | return -1; |
| 391 | 391 | } |
| ... | ... | @@ -397,7 +397,7 @@ proxy_http(int fd, char *host, unsigned short port) |
| 397 | 397 | #endif /*]*/ |
| 398 | 398 | |
| 399 | 399 | if (send(fd, buf, strlen(buf), 0) < 0) { |
| 400 | - popup_a_sockerr("HTTP Proxy: send error"); | |
| 400 | + popup_a_sockerr(NULL,"HTTP Proxy: send error"); | |
| 401 | 401 | Free(buf); |
| 402 | 402 | return -1; |
| 403 | 403 | } |
| ... | ... | @@ -416,7 +416,7 @@ proxy_http(int fd, char *host, unsigned short port) |
| 416 | 416 | tv.tv_sec = 15; |
| 417 | 417 | tv.tv_usec = 0; |
| 418 | 418 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { |
| 419 | - popup_an_error("HTTP Proxy: server timeout"); | |
| 419 | + popup_an_error(NULL,"HTTP Proxy: server timeout"); | |
| 420 | 420 | #if defined(X3270_TRACE) /*[*/ |
| 421 | 421 | if (nread) |
| 422 | 422 | trace_netdata('<', (unsigned char *)rbuf, nread); |
| ... | ... | @@ -426,7 +426,7 @@ proxy_http(int fd, char *host, unsigned short port) |
| 426 | 426 | |
| 427 | 427 | nr = recv(fd, &rbuf[nread], 1, 0); |
| 428 | 428 | if (nr < 0) { |
| 429 | - popup_a_sockerr("HTTP Proxy: receive error"); | |
| 429 | + popup_a_sockerr(NULL,"HTTP Proxy: receive error"); | |
| 430 | 430 | #if defined(X3270_TRACE) /*[*/ |
| 431 | 431 | if (nread) |
| 432 | 432 | trace_netdata('<', (unsigned char *)rbuf, nread); |
| ... | ... | @@ -438,7 +438,7 @@ proxy_http(int fd, char *host, unsigned short port) |
| 438 | 438 | if (nread) |
| 439 | 439 | trace_netdata('<', (unsigned char *)rbuf, nread); |
| 440 | 440 | #endif /*]*/ |
| 441 | - popup_an_error("HTTP Proxy: unexpected EOF"); | |
| 441 | + popup_an_error(NULL,"HTTP Proxy: unexpected EOF"); | |
| 442 | 442 | return -1; |
| 443 | 443 | } |
| 444 | 444 | if (rbuf[nread] == '\r') |
| ... | ... | @@ -458,11 +458,11 @@ proxy_http(int fd, char *host, unsigned short port) |
| 458 | 458 | #endif /*]*/ |
| 459 | 459 | |
| 460 | 460 | if (strncmp(rbuf, "HTTP/", 5) || (space = strchr(rbuf, ' ')) == CN) { |
| 461 | - popup_an_error("HTTP Proxy: unrecognized reply"); | |
| 461 | + popup_an_error(NULL,"HTTP Proxy: unrecognized reply"); | |
| 462 | 462 | return -1; |
| 463 | 463 | } |
| 464 | 464 | if (*(space + 1) != '2') { |
| 465 | - popup_an_error("HTTP Proxy: CONNECT failed:\n%s", rbuf); | |
| 465 | + popup_an_error(NULL,"HTTP Proxy: CONNECT failed:\n%s", rbuf); | |
| 466 | 466 | return -1; |
| 467 | 467 | } |
| 468 | 468 | |
| ... | ... | @@ -484,7 +484,7 @@ proxy_telnet(int fd, char *host, unsigned short port) |
| 484 | 484 | #endif /*]*/ |
| 485 | 485 | |
| 486 | 486 | if (send(fd, buf, strlen(buf), 0) < 0) { |
| 487 | - popup_a_sockerr("TELNET Proxy: send error"); | |
| 487 | + popup_a_sockerr(NULL,"TELNET Proxy: send error"); | |
| 488 | 488 | Free(buf); |
| 489 | 489 | return -1; |
| 490 | 490 | } |
| ... | ... | @@ -550,7 +550,7 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) |
| 550 | 550 | #endif /*]*/ |
| 551 | 551 | |
| 552 | 552 | if (send(fd, buf, s - buf, 0) < 0) { |
| 553 | - popup_a_sockerr("SOCKS4 Proxy: send error"); | |
| 553 | + popup_a_sockerr(NULL,"SOCKS4 Proxy: send error"); | |
| 554 | 554 | Free(buf); |
| 555 | 555 | return -1; |
| 556 | 556 | } |
| ... | ... | @@ -577,7 +577,7 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) |
| 577 | 577 | |
| 578 | 578 | if (send(fd, buf, s - buf, 0) < 0) { |
| 579 | 579 | Free(buf); |
| 580 | - popup_a_sockerr("SOCKS4 Proxy: send error"); | |
| 580 | + popup_a_sockerr(NULL,"SOCKS4 Proxy: send error"); | |
| 581 | 581 | return -1; |
| 582 | 582 | } |
| 583 | 583 | Free(buf); |
| ... | ... | @@ -596,13 +596,13 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) |
| 596 | 596 | tv.tv_sec = 15; |
| 597 | 597 | tv.tv_usec = 0; |
| 598 | 598 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { |
| 599 | - popup_an_error("SOCKS4 Proxy: server timeout"); | |
| 599 | + popup_an_error(NULL,"SOCKS4 Proxy: server timeout"); | |
| 600 | 600 | return -1; |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | nr = recv(fd, &rbuf[nread], 1, 0); |
| 604 | 604 | if (nr < 0) { |
| 605 | - popup_a_sockerr("SOCKS4 Proxy: receive error"); | |
| 605 | + popup_a_sockerr(NULL,"SOCKS4 Proxy: receive error"); | |
| 606 | 606 | return -1; |
| 607 | 607 | } |
| 608 | 608 | if (nr == 0) |
| ... | ... | @@ -631,16 +631,16 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) |
| 631 | 631 | case 0x5a: |
| 632 | 632 | break; |
| 633 | 633 | case 0x5b: |
| 634 | - popup_an_error("SOCKS4 Proxy: request rejected or failed"); | |
| 634 | + popup_an_error(NULL,"SOCKS4 Proxy: request rejected or failed"); | |
| 635 | 635 | return -1; |
| 636 | 636 | case 0x5c: |
| 637 | - popup_an_error("SOCKS4 Proxy: client is not reachable"); | |
| 637 | + popup_an_error(NULL,"SOCKS4 Proxy: client is not reachable"); | |
| 638 | 638 | return -1; |
| 639 | 639 | case 0x5d: |
| 640 | - popup_an_error("SOCKS4 Proxy: userid error"); | |
| 640 | + popup_an_error(NULL,"SOCKS4 Proxy: userid error"); | |
| 641 | 641 | return -1; |
| 642 | 642 | default: |
| 643 | - popup_an_error("SOCKS4 Proxy: unknown status 0x%02x", | |
| 643 | + popup_an_error(NULL,"SOCKS4 Proxy: unknown status 0x%02x", | |
| 644 | 644 | rbuf[1]); |
| 645 | 645 | return -1; |
| 646 | 646 | } |
| ... | ... | @@ -708,7 +708,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 708 | 708 | trace_netdata('>', rbuf, 3); |
| 709 | 709 | #endif /*]*/ |
| 710 | 710 | if (send(fd, (const char *) rbuf, 3, 0) < 0) { |
| 711 | - popup_a_sockerr("SOCKS5 Proxy: send error"); | |
| 711 | + popup_a_sockerr(NULL,"SOCKS5 Proxy: send error"); | |
| 712 | 712 | return -1; |
| 713 | 713 | } |
| 714 | 714 | |
| ... | ... | @@ -726,7 +726,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 726 | 726 | tv.tv_sec = 15; |
| 727 | 727 | tv.tv_usec = 0; |
| 728 | 728 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { |
| 729 | - popup_an_error("SOCKS5 Proxy: server timeout"); | |
| 729 | + popup_an_error(NULL,"SOCKS5 Proxy: server timeout"); | |
| 730 | 730 | #if defined(X3270_TRACE) /*[*/ |
| 731 | 731 | if (nread) |
| 732 | 732 | trace_netdata('<', rbuf, nread); |
| ... | ... | @@ -736,7 +736,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 736 | 736 | |
| 737 | 737 | nr = recv(fd, (char *) &rbuf[nread], 1, 0); |
| 738 | 738 | if (nr < 0) { |
| 739 | - popup_a_sockerr("SOCKS5 Proxy: receive error"); | |
| 739 | + popup_a_sockerr(NULL,"SOCKS5 Proxy: receive error"); | |
| 740 | 740 | #if defined(X3270_TRACE) /*[*/ |
| 741 | 741 | if (nread) |
| 742 | 742 | trace_netdata('<', rbuf, nread); |
| ... | ... | @@ -744,7 +744,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 744 | 744 | return -1; |
| 745 | 745 | } |
| 746 | 746 | if (nr == 0) { |
| 747 | - popup_a_sockerr("SOCKS5 Proxy: unexpected EOF"); | |
| 747 | + popup_a_sockerr(NULL,"SOCKS5 Proxy: unexpected EOF"); | |
| 748 | 748 | #if defined(X3270_TRACE) /*[*/ |
| 749 | 749 | if (nread) |
| 750 | 750 | trace_netdata('<', rbuf, nread); |
| ... | ... | @@ -760,7 +760,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 760 | 760 | #endif /*]*/ |
| 761 | 761 | |
| 762 | 762 | if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff)) { |
| 763 | - popup_an_error("SOCKS5 Proxy: bad authentication response"); | |
| 763 | + popup_an_error(NULL,"SOCKS5 Proxy: bad authentication response"); | |
| 764 | 764 | return -1; |
| 765 | 765 | } |
| 766 | 766 | |
| ... | ... | @@ -770,7 +770,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 770 | 770 | #endif /*]*/ |
| 771 | 771 | |
| 772 | 772 | if (rbuf[1] == 0xff) { |
| 773 | - popup_an_error("SOCKS5 Proxy: authentication failure"); | |
| 773 | + popup_an_error(NULL,"SOCKS5 Proxy: authentication failure"); | |
| 774 | 774 | return -1; |
| 775 | 775 | } |
| 776 | 776 | |
| ... | ... | @@ -811,7 +811,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 811 | 811 | #endif /*]*/ |
| 812 | 812 | |
| 813 | 813 | if (send(fd, buf, s - buf, 0) < 0) { |
| 814 | - popup_a_sockerr("SOCKS5 Proxy: send error"); | |
| 814 | + popup_a_sockerr(NULL,"SOCKS5 Proxy: send error"); | |
| 815 | 815 | Free(buf); |
| 816 | 816 | return -1; |
| 817 | 817 | } |
| ... | ... | @@ -835,13 +835,13 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 835 | 835 | tv.tv_sec = 15; |
| 836 | 836 | tv.tv_usec = 0; |
| 837 | 837 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { |
| 838 | - popup_an_error("SOCKS5 Proxy: server timeout"); | |
| 838 | + popup_an_error(NULL,"SOCKS5 Proxy: server timeout"); | |
| 839 | 839 | return -1; |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | nr = recv(fd, (char *) &r, 1, 0); |
| 843 | 843 | if (nr < 0) { |
| 844 | - popup_a_sockerr("SOCKS5 Proxy: receive error"); | |
| 844 | + popup_a_sockerr(NULL,"SOCKS5 Proxy: receive error"); | |
| 845 | 845 | #if defined(X3270_TRACE) /*[*/ |
| 846 | 846 | if (nread) |
| 847 | 847 | trace_netdata('<', (unsigned char *)buf, nread); |
| ... | ... | @@ -849,7 +849,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 849 | 849 | return -1; |
| 850 | 850 | } |
| 851 | 851 | if (nr == 0) { |
| 852 | - popup_an_error("SOCKS5 Proxy: unexpected EOF"); | |
| 852 | + popup_an_error(NULL,"SOCKS5 Proxy: unexpected EOF"); | |
| 853 | 853 | #if defined(X3270_TRACE) /*[*/ |
| 854 | 854 | if (nread) |
| 855 | 855 | trace_netdata('<', (unsigned char *)buf, nread); |
| ... | ... | @@ -881,37 +881,37 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) |
| 881 | 881 | case 0x00: |
| 882 | 882 | break; |
| 883 | 883 | case 0x01: |
| 884 | - popup_an_error("SOCKS5 Proxy: server failure"); | |
| 884 | + popup_an_error(NULL,"SOCKS5 Proxy: server failure"); | |
| 885 | 885 | return -1; |
| 886 | 886 | case 0x02: |
| 887 | - popup_an_error("SOCKS5 Proxy: connection not " | |
| 887 | + popup_an_error(NULL,"SOCKS5 Proxy: connection not " | |
| 888 | 888 | "allowed"); |
| 889 | 889 | return -1; |
| 890 | 890 | case 0x03: |
| 891 | - popup_an_error("SOCKS5 Proxy: network " | |
| 891 | + popup_an_error(NULL,"SOCKS5 Proxy: network " | |
| 892 | 892 | "unreachable"); |
| 893 | 893 | return -1; |
| 894 | 894 | case 0x04: |
| 895 | - popup_an_error("SOCKS5 Proxy: host " | |
| 895 | + popup_an_error(NULL,"SOCKS5 Proxy: host " | |
| 896 | 896 | "unreachable"); |
| 897 | 897 | return -1; |
| 898 | 898 | case 0x05: |
| 899 | - popup_an_error("SOCKS5 Proxy: connection " | |
| 899 | + popup_an_error(NULL,"SOCKS5 Proxy: connection " | |
| 900 | 900 | "refused"); |
| 901 | 901 | return -1; |
| 902 | 902 | case 0x06: |
| 903 | - popup_an_error("SOCKS5 Proxy: ttl expired"); | |
| 903 | + popup_an_error(NULL,"SOCKS5 Proxy: ttl expired"); | |
| 904 | 904 | return -1; |
| 905 | 905 | case 0x07: |
| 906 | - popup_an_error("SOCKS5 Proxy: command not " | |
| 906 | + popup_an_error(NULL,"SOCKS5 Proxy: command not " | |
| 907 | 907 | "supported"); |
| 908 | 908 | return -1; |
| 909 | 909 | case 0x08: |
| 910 | - popup_an_error("SOCKS5 Proxy: address type " | |
| 910 | + popup_an_error(NULL,"SOCKS5 Proxy: address type " | |
| 911 | 911 | "not supported"); |
| 912 | 912 | return -1; |
| 913 | 913 | default: |
| 914 | - popup_an_error("SOCKS5 Proxy: unknown server " | |
| 914 | + popup_an_error(NULL,"SOCKS5 Proxy: unknown server " | |
| 915 | 915 | "error 0x%02x", r); |
| 916 | 916 | return -1; |
| 917 | 917 | } | ... | ... |
| ... | ... | @@ -213,7 +213,7 @@ do_qr_rpqnames(void) |
| 213 | 213 | break; |
| 214 | 214 | |
| 215 | 215 | default: /* unsupported ID, (can't happen) */ |
| 216 | - Error("Unsupported RPQ term"); | |
| 216 | + Error(NULL,"Unsupported RPQ term"); | |
| 217 | 217 | break; |
| 218 | 218 | } |
| 219 | 219 | |
| ... | ... | @@ -752,7 +752,7 @@ rpq_dump_warnings(void) |
| 752 | 752 | { |
| 753 | 753 | /* If there's something to complain about, only complain once. */ |
| 754 | 754 | if (!rpq_complained && rpq_wbcnt) { |
| 755 | - popup_an_error(rpq_warnbuf); | |
| 755 | + popup_an_error(NULL,rpq_warnbuf); | |
| 756 | 756 | rpq_wbcnt = 0; |
| 757 | 757 | rpq_complained = True; |
| 758 | 758 | ... | ... |
screen.c
| ... | ... | @@ -159,7 +159,7 @@ int screen_init(H3270 *session) |
| 159 | 159 | |
| 160 | 160 | if(callbacks->init()) |
| 161 | 161 | { |
| 162 | - popup_an_error("Can't initialize terminal."); | |
| 162 | + popup_an_error(session,"Can't initialize terminal."); | |
| 163 | 163 | return -1; |
| 164 | 164 | } |
| 165 | 165 | } |
| ... | ... | @@ -784,137 +784,114 @@ int Register3270ScreenCallbacks(const struct lib3270_screen_callbacks *cbk) |
| 784 | 784 | return 0; |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | -void show_3270_popup_dialog(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, ...) | |
| 787 | +void show_3270_popup_dialog(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, ...) | |
| 788 | 788 | { |
| 789 | + CHECK_SESSION_HANDLE(session); | |
| 790 | + | |
| 789 | 791 | if(!fmt) |
| 790 | 792 | fmt = ""; |
| 791 | 793 | |
| 792 | 794 | va_list arg_ptr; |
| 793 | 795 | va_start(arg_ptr, fmt); |
| 794 | 796 | |
| 795 | - if(callbacks && callbacks->popup_dialog) | |
| 796 | - callbacks->popup_dialog(session,type,title,msg,fmt,arg_ptr); | |
| 797 | + if(callbacks && callbacks->notify) | |
| 798 | + callbacks->notify(session,type,title,msg,fmt,arg_ptr); | |
| 799 | + else | |
| 800 | + lib3270_write_va_log(session,"lib3270",fmt,arg_ptr); | |
| 797 | 801 | |
| 798 | 802 | va_end(arg_ptr); |
| 799 | 803 | |
| 800 | 804 | } |
| 801 | 805 | |
| 802 | -void Error(const char *fmt, ...) | |
| 806 | + | |
| 807 | +void Error(H3270 *session, const char *fmt, ...) | |
| 803 | 808 | { |
| 804 | 809 | va_list arg_ptr; |
| 805 | 810 | |
| 811 | + CHECK_SESSION_HANDLE(session); | |
| 812 | + | |
| 806 | 813 | va_start(arg_ptr, fmt); |
| 807 | 814 | |
| 808 | - if(callbacks && callbacks->Warning) | |
| 809 | - callbacks->Warning(fmt,arg_ptr); | |
| 815 | + if(callbacks && callbacks->notify) | |
| 816 | + callbacks->notify(session,LIB3270_NOTIFY_ERROR, _( "3270 Error" ),NULL,fmt,arg_ptr); | |
| 817 | + else | |
| 818 | + lib3270_write_va_log(&h3270,"lib3270",fmt,arg_ptr); | |
| 810 | 819 | |
| 811 | 820 | va_end(arg_ptr); |
| 812 | 821 | |
| 813 | 822 | } |
| 814 | 823 | |
| 815 | -/* | |
| 816 | -void notify_toggle_changed(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason) | |
| 817 | -{ | |
| 818 | - if(callbacks && callbacks->toggle_changed) | |
| 819 | - callbacks->toggle_changed(session,ix,value,reason,toggle_names[ix]); | |
| 820 | -} | |
| 821 | -*/ | |
| 822 | - | |
| 823 | -LIB3270_EXPORT void update_toggle_actions(void) | |
| 824 | -{ | |
| 825 | - int f; | |
| 826 | - | |
| 827 | - if(callbacks && callbacks->toggle_changed) | |
| 828 | - { | |
| 829 | - for(f=0;f< N_TOGGLES;f++) | |
| 830 | - callbacks->toggle_changed(&h3270,f,appres.toggle[f].value,TT_UPDATE,toggle_names[f]); | |
| 831 | - } | |
| 832 | -} | |
| 833 | - | |
| 834 | -void Warning(const char *fmt, ...) | |
| 824 | +void Warning(H3270 *session, const char *fmt, ...) | |
| 835 | 825 | { |
| 836 | 826 | va_list arg_ptr; |
| 837 | 827 | |
| 828 | + CHECK_SESSION_HANDLE(session); | |
| 829 | + | |
| 838 | 830 | va_start(arg_ptr, fmt); |
| 839 | 831 | |
| 840 | - if(callbacks && callbacks->Warning) | |
| 841 | - callbacks->Warning(fmt,arg_ptr); | |
| 832 | + if(callbacks && callbacks->notify) | |
| 833 | + callbacks->notify(session,LIB3270_NOTIFY_WARNING, _( "3270 Warning" ),NULL,fmt,arg_ptr); | |
| 834 | + else | |
| 835 | + lib3270_write_va_log(&h3270,"lib3270",fmt,arg_ptr); | |
| 842 | 836 | |
| 843 | 837 | va_end(arg_ptr); |
| 844 | 838 | |
| 845 | 839 | } |
| 846 | 840 | |
| 847 | -void mcursor_set(H3270 *session,LIB3270_CURSOR m) | |
| 841 | +/* Pop up an error dialog. */ | |
| 842 | +extern void popup_an_error(H3270 *session, const char *fmt, ...) | |
| 848 | 843 | { |
| 849 | - CHECK_SESSION_HANDLE(session); | |
| 850 | - | |
| 851 | - if(session->cursor) | |
| 852 | - session->cursor(session,m); | |
| 853 | -} | |
| 844 | + va_list args; | |
| 854 | 845 | |
| 855 | -/* | |
| 856 | -void mcursor_locked(H3270 *session) | |
| 857 | -{ | |
| 858 | 846 | CHECK_SESSION_HANDLE(session); |
| 859 | 847 | |
| 860 | - if(callbacks && callbacks->cursor) | |
| 861 | - callbacks->cursor(CURSOR_MODE_LOCKED); | |
| 862 | -} | |
| 863 | - | |
| 864 | -extern void mcursor_normal(H3270 *session) | |
| 865 | -{ | |
| 866 | - CHECK_SESSION_HANDLE(session); | |
| 848 | + va_start(args, fmt); | |
| 867 | 849 | |
| 868 | - if(callbacks && callbacks->cursor) | |
| 869 | - callbacks->cursor(CURSOR_MODE_NORMAL); | |
| 870 | -} | |
| 850 | + if(callbacks && callbacks->notify) | |
| 851 | + callbacks->notify(session,LIB3270_NOTIFY_ERROR,_( "3270 Error" ),NULL,fmt,args); | |
| 852 | + else | |
| 853 | + lib3270_write_va_log(&h3270,"lib3270",fmt,args); | |
| 871 | 854 | |
| 872 | -extern void mcursor_waiting(H3270 *session) | |
| 873 | -{ | |
| 874 | - CHECK_SESSION_HANDLE(session); | |
| 855 | + va_end(args); | |
| 875 | 856 | |
| 876 | - if(callbacks && callbacks->cursor) | |
| 877 | - callbacks->cursor(CURSOR_MODE_WAITING); | |
| 878 | 857 | } |
| 879 | -*/ | |
| 880 | 858 | |
| 881 | -/* Pop up an error dialog. */ | |
| 882 | -extern void popup_an_error(const char *fmt, ...) | |
| 859 | +void popup_system_error(H3270 *session, const char *title, const char *message, const char *fmt, ...) | |
| 883 | 860 | { |
| 884 | 861 | va_list args; |
| 885 | 862 | |
| 863 | + CHECK_SESSION_HANDLE(session); | |
| 864 | + | |
| 886 | 865 | va_start(args, fmt); |
| 887 | - if(callbacks && callbacks->Error) | |
| 888 | - callbacks->Error(fmt,args); | |
| 889 | - va_end(args); | |
| 890 | 866 | |
| 867 | + if(callbacks && callbacks->notify) | |
| 868 | + callbacks->notify(session,LIB3270_NOTIFY_ERROR,title ? title : _( "3270 Error" ), message,fmt,args); | |
| 869 | + else | |
| 870 | + lib3270_write_va_log(&h3270,"lib3270",fmt,args); | |
| 871 | + | |
| 872 | + va_end(args); | |
| 891 | 873 | } |
| 892 | 874 | |
| 893 | -void popup_system_error(const char *title, const char *message, const char *system) | |
| 875 | + | |
| 876 | + | |
| 877 | +LIB3270_EXPORT void update_toggle_actions(void) | |
| 894 | 878 | { |
| 895 | - if(callbacks && callbacks->SysError) | |
| 879 | + int f; | |
| 880 | + | |
| 881 | + if(callbacks && callbacks->toggle_changed) | |
| 896 | 882 | { |
| 897 | - callbacks->SysError(title,message,system); | |
| 898 | - return; | |
| 883 | + for(f=0;f< N_TOGGLES;f++) | |
| 884 | + callbacks->toggle_changed(&h3270,f,appres.toggle[f].value,TT_UPDATE,toggle_names[f]); | |
| 899 | 885 | } |
| 900 | - | |
| 901 | - popup_an_error("%s\n%s\n%s",title,message,system); | |
| 902 | 886 | } |
| 903 | 887 | |
| 904 | -/* | |
| 905 | -int set_device_buffer(struct ea *src, int el) | |
| 888 | +void mcursor_set(H3270 *session,LIB3270_CURSOR m) | |
| 906 | 889 | { |
| 890 | + CHECK_SESSION_HANDLE(session); | |
| 907 | 891 | |
| 908 | - if(el > (h3270.maxROWS * h3270.maxCOLS)) | |
| 909 | - return EINVAL; | |
| 910 | - | |
| 911 | - memcpy(ea_buf,src,sizeof(struct ea) * el); | |
| 912 | - | |
| 913 | - screen_disp(&h3270); | |
| 914 | - | |
| 915 | - return 0; | |
| 892 | + if(session->cursor) | |
| 893 | + session->cursor(session,m); | |
| 916 | 894 | } |
| 917 | -*/ | |
| 918 | 895 | |
| 919 | 896 | LIB3270_ACTION( testpattern ) |
| 920 | 897 | { | ... | ... |
telnet.c
| ... | ... | @@ -404,7 +404,7 @@ void popup_a_sockerr(char *fmt, ...) |
| 404 | 404 | |
| 405 | 405 | } |
| 406 | 406 | #else |
| 407 | -void popup_a_sockerr(char *fmt, ...) | |
| 407 | +void popup_a_sockerr(H3270 *session, char *fmt, ...) | |
| 408 | 408 | { |
| 409 | 409 | va_list args; |
| 410 | 410 | char buffer[4096]; |
| ... | ... | @@ -413,7 +413,7 @@ void popup_a_sockerr(char *fmt, ...) |
| 413 | 413 | vsprintf(buffer, fmt, args); |
| 414 | 414 | va_end(args); |
| 415 | 415 | |
| 416 | - popup_system_error( N_( "Network error" ), buffer, strerror(errno)); | |
| 416 | + popup_system_error(session, N_( "Network error" ), buffer, strerror(errno)); | |
| 417 | 417 | |
| 418 | 418 | } |
| 419 | 419 | #endif |
| ... | ... | @@ -522,7 +522,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
| 522 | 522 | if (resolve_host_and_port(proxy_host, proxy_portname, |
| 523 | 523 | &proxy_port, &haddr.sa, &ha_len, errmsg, |
| 524 | 524 | sizeof(errmsg)) < 0) { |
| 525 | - popup_an_error(errmsg); | |
| 525 | + popup_an_error(NULL,errmsg); | |
| 526 | 526 | status_resolving(&h3270,0); |
| 527 | 527 | return -1; |
| 528 | 528 | status_resolving(&h3270,0); |
| ... | ... | @@ -542,7 +542,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
| 542 | 542 | if (resolve_host_and_port(host, portname, |
| 543 | 543 | &h3270.current_port, &haddr.sa, &ha_len, |
| 544 | 544 | errmsg, sizeof(errmsg)) < 0) { |
| 545 | - popup_an_error(errmsg); | |
| 545 | + popup_an_error(NULL,errmsg); | |
| 546 | 546 | status_resolving(&h3270,0); |
| 547 | 547 | return -1; |
| 548 | 548 | status_resolving(&h3270,0); |
| ... | ... | @@ -600,19 +600,19 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
| 600 | 600 | */ |
| 601 | 601 | /* create the socket */ |
| 602 | 602 | if ((h3270.sock = socket(haddr.sa.sa_family, SOCK_STREAM, 0)) == -1) { |
| 603 | - popup_a_sockerr( N_( "socket" ) ); | |
| 603 | + popup_a_sockerr(NULL, N_( "socket" ) ); | |
| 604 | 604 | return -1; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /* set options for inline out-of-band data and keepalives */ |
| 608 | 608 | if (setsockopt(h3270.sock, SOL_SOCKET, SO_OOBINLINE, (char *)&on, |
| 609 | 609 | sizeof(on)) < 0) { |
| 610 | - popup_a_sockerr( N_( "setsockopt(%s)" ), "SO_OOBINLINE"); | |
| 610 | + popup_a_sockerr(NULL, N_( "setsockopt(%s)" ), "SO_OOBINLINE"); | |
| 611 | 611 | close_fail; |
| 612 | 612 | } |
| 613 | 613 | if (setsockopt(h3270.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, |
| 614 | 614 | sizeof(on)) < 0) { |
| 615 | - popup_a_sockerr( N_( "setsockopt(%s)" ), "SO_KEEPALIVE"); | |
| 615 | + popup_a_sockerr(NULL, N_( "setsockopt(%s)" ), "SO_KEEPALIVE"); | |
| 616 | 616 | close_fail; |
| 617 | 617 | } |
| 618 | 618 | #if defined(OMTU) /*[*/ |
| ... | ... | @@ -1031,7 +1031,7 @@ void net_input(H3270 *session) |
| 1031 | 1031 | if (HALF_CONNECTED) { |
| 1032 | 1032 | popup_a_sockerr( N_( "%s:%d" ),h3270.hostname, h3270.current_port); |
| 1033 | 1033 | } else if (socket_errno() != SE_ECONNRESET) { |
| 1034 | - popup_a_sockerr( N_( "Socket read error" ) ); | |
| 1034 | + popup_a_sockerr(NULL, N_( "Socket read error" ) ); | |
| 1035 | 1035 | } |
| 1036 | 1036 | host_disconnect(session,True); |
| 1037 | 1037 | return; |
| ... | ... | @@ -1249,7 +1249,7 @@ telnet_fsm(unsigned char c) |
| 1249 | 1249 | if (process_eor()) |
| 1250 | 1250 | return -1; |
| 1251 | 1251 | } else |
| 1252 | - Warning( _( "EOR received when not in 3270 mode, ignored." )); | |
| 1252 | + Warning(NULL, _( "EOR received when not in 3270 mode, ignored." )); | |
| 1253 | 1253 | trace_dsn("RCVD EOR\n"); |
| 1254 | 1254 | ibptr = ibuf; |
| 1255 | 1255 | telnet_state = TNS_DATA; |
| ... | ... | @@ -1441,8 +1441,7 @@ telnet_fsm(unsigned char c) |
| 1441 | 1441 | telquals[sbbuf[1]]); |
| 1442 | 1442 | if (lus != (char **)NULL && try_lu == CN) { |
| 1443 | 1443 | /* None of the LUs worked. */ |
| 1444 | - popup_an_error("Cannot connect to " | |
| 1445 | - "specified LU"); | |
| 1444 | + popup_an_error(NULL,"Cannot connect to specified LU"); | |
| 1446 | 1445 | return -1; |
| 1447 | 1446 | } |
| 1448 | 1447 | |
| ... | ... | @@ -2032,7 +2031,7 @@ net_rawout(unsigned const char *buf, int len) |
| 2032 | 2031 | } else if (socket_errno() == SE_EINTR) { |
| 2033 | 2032 | goto bot; |
| 2034 | 2033 | } else { |
| 2035 | - popup_a_sockerr( N_( "Socket write error" ) ); | |
| 2034 | + popup_a_sockerr(NULL, N_( "Socket write error" ) ); | |
| 2036 | 2035 | host_disconnect(&h3270,True); |
| 2037 | 2036 | return; |
| 2038 | 2037 | } | ... | ... |
utf8.c
| ... | ... | @@ -428,7 +428,7 @@ utf8_set_display_charsets(char *cslist, char *csname) |
| 428 | 428 | break; |
| 429 | 429 | } |
| 430 | 430 | if (tok == CN) { |
| 431 | - popup_an_error("Invalid displayCharset specification"); | |
| 431 | + popup_an_error(NULL,"Invalid displayCharset specification"); | |
| 432 | 432 | Free(dup); |
| 433 | 433 | return False; |
| 434 | 434 | } |
| ... | ... | @@ -439,7 +439,7 @@ utf8_set_display_charsets(char *cslist, char *csname) |
| 439 | 439 | break; |
| 440 | 440 | } |
| 441 | 441 | if (dcs[i] == CN) { |
| 442 | - popup_an_error("Unknown displayCharset specification '%s'", | |
| 442 | + popup_an_error(NULL,"Unknown displayCharset specification '%s'", | |
| 443 | 443 | csname); |
| 444 | 444 | Free(dup); |
| 445 | 445 | return False; | ... | ... |
util.c
| ... | ... | @@ -172,7 +172,7 @@ xs_vsprintf(const char *fmt, va_list args) |
| 172 | 172 | |
| 173 | 173 | nc = vsprintf(buf, fmt, args); |
| 174 | 174 | if (nc > sizeof(buf)) |
| 175 | - Error("Internal buffer overflow"); | |
| 175 | + Error(NULL,"Internal buffer overflow"); | |
| 176 | 176 | r = Malloc(nc + 1); |
| 177 | 177 | return strcpy(r, buf); |
| 178 | 178 | #endif /*]*/ |
| ... | ... | @@ -205,7 +205,7 @@ xs_warning(const char *fmt, ...) |
| 205 | 205 | va_start(args, fmt); |
| 206 | 206 | r = xs_vsprintf(fmt, args); |
| 207 | 207 | va_end(args); |
| 208 | - Warning(r); | |
| 208 | + Warning(NULL,r); | |
| 209 | 209 | Free(r); |
| 210 | 210 | } |
| 211 | 211 | |
| ... | ... | @@ -218,7 +218,7 @@ xs_error(const char *fmt, ...) |
| 218 | 218 | va_start(args, fmt); |
| 219 | 219 | r = xs_vsprintf(fmt, args); |
| 220 | 220 | va_end(args); |
| 221 | - Error(r); | |
| 221 | + Error(NULL,r); | |
| 222 | 222 | Free(r); |
| 223 | 223 | } |
| 224 | 224 | |
| ... | ... | @@ -856,7 +856,7 @@ rpf(rpf_t *r, char *fmt, ...) |
| 856 | 856 | ns = vsprintf(tbuf, fmt, a); /* XXX: dangerous, but so is vsnprintf */ |
| 857 | 857 | va_end(a); |
| 858 | 858 | if (ns >= SP_TMP_LEN) |
| 859 | - Error("rpf overrun"); | |
| 859 | + Error(NULL,"rpf overrun"); | |
| 860 | 860 | |
| 861 | 861 | /* Make sure we have that. */ |
| 862 | 862 | while (r->alloc_len - r->cur_len < ns + 1) { | ... | ... |