Commit 310529321e9b39dc183b929871a09b6d8e5764d7
1 parent
8cf46863
Exists in
master
and in
5 other branches
Atualizando tratamento de logs e popups de erro
Showing
17 changed files
with
206 additions
and
297 deletions
Show diff stats
src/gtk/Makefile.in
@@ -56,7 +56,7 @@ SOURCES=main.c mainwindow.c actions.c fonts.c \ | @@ -56,7 +56,7 @@ SOURCES=main.c mainwindow.c actions.c fonts.c \ | ||
56 | $(foreach SRC, $(COMMON_SRC), common/$(SRC)) \ | 56 | $(foreach SRC, $(COMMON_SRC), common/$(SRC)) \ |
57 | $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) | 57 | $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) |
58 | 58 | ||
59 | -DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h Makefile | 59 | +DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h |
60 | 60 | ||
61 | VALGRIND=@VALGRIND@ | 61 | VALGRIND=@VALGRIND@ |
62 | 62 |
src/gtk/v3270/widget.c
@@ -392,6 +392,13 @@ static void v3270_init(v3270 *widget) | @@ -392,6 +392,13 @@ static void v3270_init(v3270 *widget) | ||
392 | { | 392 | { |
393 | trace("%s",__FUNCTION__); | 393 | trace("%s",__FUNCTION__); |
394 | widget->host = lib3270_session_new(""); | 394 | widget->host = lib3270_session_new(""); |
395 | + | ||
396 | + if(widget->host->sz != sizeof(H3270)) | ||
397 | + { | ||
398 | + g_critical(N_( "Unexpected signature in H3270 object, possible version mismatch in lib3270") ); | ||
399 | + return; | ||
400 | + } | ||
401 | + | ||
395 | widget->host->widget = widget; | 402 | widget->host->widget = widget; |
396 | 403 | ||
397 | widget->host->update = v3270_update_char; | 404 | widget->host->update = v3270_update_char; |
src/include/rules.mak.in
@@ -52,14 +52,14 @@ OBJEXT=.o | @@ -52,14 +52,14 @@ OBJEXT=.o | ||
52 | 52 | ||
53 | #---[ Paths ]------------------------------------------------------------------ | 53 | #---[ Paths ]------------------------------------------------------------------ |
54 | 54 | ||
55 | -ROOTDIR ?= "." | 55 | +ROOTDIR ?= . |
56 | OBJDIR ?= $(ROOTDIR)/.obj | 56 | OBJDIR ?= $(ROOTDIR)/.obj |
57 | BINDIR ?= $(ROOTDIR)/.bin | 57 | BINDIR ?= $(ROOTDIR)/.bin |
58 | 58 | ||
59 | #---[ Rules ]------------------------------------------------------------------ | 59 | #---[ Rules ]------------------------------------------------------------------ |
60 | 60 | ||
61 | $(OBJDIR)/Debug/%.o: %.c $(DEPENDS) | 61 | $(OBJDIR)/Debug/%.o: %.c $(DEPENDS) |
62 | - @echo $< ... | 62 | + @echo `basename $@` ... |
63 | @$(MKDIR) `dirname $@` | 63 | @$(MKDIR) `dirname $@` |
64 | @$(CC) $(DEBUG_CFLAGS) $(CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< | 64 | @$(CC) $(DEBUG_CFLAGS) $(CFLAGS) $(LIB3270_CFLAGS) -o $@ -c $< |
65 | 65 |
src/lib3270/XtGlue.c
@@ -461,7 +461,7 @@ static int DefaultProcessEvents(int block) | @@ -461,7 +461,7 @@ static int DefaultProcessEvents(int block) | ||
461 | if (ns < 0) | 461 | if (ns < 0) |
462 | { | 462 | { |
463 | if (errno != EINTR) | 463 | if (errno != EINTR) |
464 | - Warning( "process_events: select() failed" ); | 464 | + Warning(NULL, "process_events: select() failed" ); |
465 | #endif | 465 | #endif |
466 | return processed_any; | 466 | return processed_any; |
467 | } | 467 | } |
@@ -555,7 +555,7 @@ Malloc(size_t len) | @@ -555,7 +555,7 @@ Malloc(size_t len) | ||
555 | 555 | ||
556 | r = malloc(len); | 556 | r = malloc(len); |
557 | if (r == (char *)NULL) | 557 | if (r == (char *)NULL) |
558 | - Error("Out of memory"); | 558 | + Error(NULL,"Out of memory"); |
559 | return r; | 559 | return r; |
560 | } | 560 | } |
561 | 561 | ||
@@ -566,7 +566,7 @@ Calloc(size_t nelem, size_t elsize) | @@ -566,7 +566,7 @@ Calloc(size_t nelem, size_t elsize) | ||
566 | char *r = malloc(sz); | 566 | char *r = malloc(sz); |
567 | 567 | ||
568 | if(!r) | 568 | if(!r) |
569 | - Error("Out of memory"); | 569 | + Error(NULL,"Out of memory"); |
570 | 570 | ||
571 | memset(r, 0, sz); | 571 | memset(r, 0, sz); |
572 | return r; | 572 | return r; |
@@ -577,7 +577,7 @@ Realloc(void *p, size_t len) | @@ -577,7 +577,7 @@ Realloc(void *p, size_t len) | ||
577 | { | 577 | { |
578 | p = realloc(p, len); | 578 | p = realloc(p, len); |
579 | if (p == NULL) | 579 | if (p == NULL) |
580 | - Error("Out of memory"); | 580 | + Error(NULL,"Out of memory"); |
581 | return p; | 581 | return p; |
582 | } | 582 | } |
583 | 583 |
src/lib3270/api.h
@@ -98,14 +98,14 @@ | @@ -98,14 +98,14 @@ | ||
98 | #endif | 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 | #ifdef LIB3270_MODULE_NAME | 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 | #else | 107 | #else |
108 | - #define Log(fmt, ...) WriteLog("MSG",fmt,__VA_ARGS__) | 108 | + #define Log(fmt, ...) lib3270_write_log(NULL,"MSG",fmt,__VA_ARGS__) |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | /** 3270 connection handle */ | 111 | /** 3270 connection handle */ |
@@ -179,13 +179,19 @@ | @@ -179,13 +179,19 @@ | ||
179 | 179 | ||
180 | 180 | ||
181 | /** Type of dialog boxes */ | 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 | /** extended attributes */ | 196 | /** extended attributes */ |
191 | struct ea | 197 | struct ea |
@@ -336,10 +342,7 @@ | @@ -336,10 +342,7 @@ | ||
336 | unsigned short sz; | 342 | unsigned short sz; |
337 | 343 | ||
338 | int (*init)(void); | 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 | void (*model_changed)(H3270 *session, const char *name, int model, int rows, int cols); | 346 | void (*model_changed)(H3270 *session, const char *name, int model, int rows, int cols); |
344 | int (*addch)(int row, int col, unsigned char c, unsigned short attr); | 347 | int (*addch)(int row, int col, unsigned char c, unsigned short attr); |
345 | void (*charset)(char *dcs); | 348 | void (*charset)(char *dcs); |
@@ -397,8 +400,8 @@ | @@ -397,8 +400,8 @@ | ||
397 | LOCAL_EXTERN const struct lib3270_option * get_3270_option_table(int sz); | 400 | LOCAL_EXTERN const struct lib3270_option * get_3270_option_table(int sz); |
398 | 401 | ||
399 | /* Popups */ | 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 | LOCAL_EXTERN void show_3270_popup_dialog(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, ...); | 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 | /* Set/Get screen contents */ | 407 | /* Set/Get screen contents */ |
@@ -420,9 +423,9 @@ | @@ -420,9 +423,9 @@ | ||
420 | LOCAL_EXTERN int Get3270Socket(void); | 423 | LOCAL_EXTERN int Get3270Socket(void); |
421 | 424 | ||
422 | /* Misc calls */ | 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 | #define query_3270_terminal_status(void) lib3270_get_program_message(NULL) | 430 | #define query_3270_terminal_status(void) lib3270_get_program_message(NULL) |
428 | 431 |
src/lib3270/charset.c
@@ -333,14 +333,13 @@ set_cgcsgids(char *spec) | @@ -333,14 +333,13 @@ set_cgcsgids(char *spec) | ||
333 | break; | 333 | break; |
334 | #endif /*]*/ | 334 | #endif /*]*/ |
335 | default: | 335 | default: |
336 | - popup_an_error("Extra CGCSGID(s), ignoring"); | 336 | + popup_an_error(NULL,"Extra CGCSGID(s), ignoring"); |
337 | break; | 337 | break; |
338 | } | 338 | } |
339 | if (idp == NULL) | 339 | if (idp == NULL) |
340 | break; | 340 | break; |
341 | if (set_cgcsgid(token, idp) < 0) { | 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 | n_ids = -1; | 343 | n_ids = -1; |
345 | break; | 344 | break; |
346 | } | 345 | } |
@@ -620,8 +619,7 @@ remap_chars(char *csname, char *spec, remap_scope scope, int *ne) | @@ -620,8 +619,7 @@ remap_chars(char *csname, char *spec, remap_scope scope, int *ne) | ||
620 | 619 | ||
621 | while ((tok = strtok(s, " \t\n")) != CN) { | 620 | while ((tok = strtok(s, " \t\n")) != CN) { |
622 | if (ebc >= 256) { | 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 | rc = CS_BAD; | 623 | rc = CS_BAD; |
626 | break; | 624 | break; |
627 | } | 625 | } |
@@ -635,7 +633,7 @@ remap_chars(char *csname, char *spec, remap_scope scope, int *ne) | @@ -635,7 +633,7 @@ remap_chars(char *csname, char *spec, remap_scope scope, int *ne) | ||
635 | if (strlen(tok) == 1) | 633 | if (strlen(tok) == 1) |
636 | iso = tok[0] & 0xff; | 634 | iso = tok[0] & 0xff; |
637 | else { | 635 | else { |
638 | - popup_an_error("Invalid charset " | 636 | + popup_an_error(NULL,"Invalid charset " |
639 | "entry '%s' (#%d)", | 637 | "entry '%s' (#%d)", |
640 | tok, ebc); | 638 | tok, ebc); |
641 | rc = CS_BAD; | 639 | rc = CS_BAD; |
src/lib3270/glue.c
@@ -988,7 +988,7 @@ read_resource_file(const char *filename, Boolean fatal) | @@ -988,7 +988,7 @@ read_resource_file(const char *filename, Boolean fatal) | ||
988 | if (*s == '#') { | 988 | if (*s == '#') { |
989 | (void) sprintf(where, "%s:%d: Invalid profile " | 989 | (void) sprintf(where, "%s:%d: Invalid profile " |
990 | "syntax ('#' ignored)", filename, lno); | 990 | "syntax ('#' ignored)", filename, lno); |
991 | - Warning(where); | 991 | + Warning(NULL,where); |
992 | ilen = 0; | 992 | ilen = 0; |
993 | continue; | 993 | continue; |
994 | } | 994 | } |
@@ -999,7 +999,7 @@ read_resource_file(const char *filename, Boolean fatal) | @@ -999,7 +999,7 @@ read_resource_file(const char *filename, Boolean fatal) | ||
999 | if (ilen >= sizeof(buf) - 1) { | 999 | if (ilen >= sizeof(buf) - 1) { |
1000 | (void) sprintf(where, "%s:%d: Line too long\n", | 1000 | (void) sprintf(where, "%s:%d: Line too long\n", |
1001 | filename, lno); | 1001 | filename, lno); |
1002 | - Warning(where); | 1002 | + Warning(NULL,where); |
1003 | break; | 1003 | break; |
1004 | } | 1004 | } |
1005 | continue; | 1005 | continue; |
@@ -1045,8 +1045,7 @@ Boolean error_popup_visible = False; | @@ -1045,8 +1045,7 @@ Boolean error_popup_visible = False; | ||
1045 | 1045 | ||
1046 | 1046 | ||
1047 | /* Pop up an error dialog, based on an error number. */ | 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 | char vmsgbuf[4096]; | 1050 | char vmsgbuf[4096]; |
1052 | va_list args; | 1051 | va_list args; |
@@ -1057,7 +1056,7 @@ popup_an_errno(int errn, const char *fmt, ...) | @@ -1057,7 +1056,7 @@ popup_an_errno(int errn, const char *fmt, ...) | ||
1057 | 1056 | ||
1058 | WriteLog("3270", "Error Popup:\n%s\nrc=%d (%s)",vmsgbuf,errn,strerror(errn)); | 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 | #ifdef DEBUG | 1062 | #ifdef DEBUG |
src/lib3270/host.c
@@ -225,7 +225,7 @@ parse_localprocess(const char *s) | @@ -225,7 +225,7 @@ parse_localprocess(const char *s) | ||
225 | * Returns NULL if there is a syntax error. | 225 | * Returns NULL if there is a syntax error. |
226 | */ | 226 | */ |
227 | static char * | 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 | char *non_e, char *secure, char *no_login, char *xluname, | 229 | char *non_e, char *secure, char *no_login, char *xluname, |
230 | char **port, char *needed) | 230 | char **port, char *needed) |
231 | { | 231 | { |
@@ -259,7 +259,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -259,7 +259,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
259 | while (*s && isspace(*s)) | 259 | while (*s && isspace(*s)) |
260 | s++; | 260 | s++; |
261 | if (!*s) { | 261 | if (!*s) { |
262 | - popup_an_error("Empty hostname"); | 262 | + popup_an_error(NULL,_( "Empty hostname" )); |
263 | goto split_fail; | 263 | goto split_fail; |
264 | } | 264 | } |
265 | 265 | ||
@@ -297,8 +297,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -297,8 +297,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
297 | *no_login = True; | 297 | *no_login = True; |
298 | break; | 298 | break; |
299 | default: | 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 | goto split_fail; | 301 | goto split_fail; |
303 | } | 302 | } |
304 | *needed = True; | 303 | *needed = True; |
@@ -319,8 +318,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -319,8 +318,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
319 | char *lu_last = at - 1; | 318 | char *lu_last = at - 1; |
320 | 319 | ||
321 | if (at == s) { | 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 | goto split_fail; | 322 | goto split_fail; |
325 | } | 323 | } |
326 | while (lu_last < s && isspace(*lu_last)) | 324 | while (lu_last < s && isspace(*lu_last)) |
@@ -332,9 +330,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -332,9 +330,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
332 | while (isspace(*u)) | 330 | while (isspace(*u)) |
333 | u++; | 331 | u++; |
334 | if (*u != '@') { | 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 | goto split_fail; | 334 | goto split_fail; |
339 | } | 335 | } |
340 | break; | 336 | break; |
@@ -360,8 +356,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -360,8 +356,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
360 | 356 | ||
361 | /* Check for junk before the '['. */ | 357 | /* Check for junk before the '['. */ |
362 | if (lbracket != s) { | 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 | goto split_fail; | 360 | goto split_fail; |
366 | } | 361 | } |
367 | 362 | ||
@@ -373,12 +368,11 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -373,12 +368,11 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
373 | */ | 368 | */ |
374 | rbracket = strchr(s, ']'); | 369 | rbracket = strchr(s, ']'); |
375 | if (rbracket == CN) { | 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 | goto split_fail; | 372 | goto split_fail; |
379 | } | 373 | } |
380 | if (rbracket == s) { | 374 | if (rbracket == s) { |
381 | - popup_an_error("Empty hostname"); | 375 | + popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Empty hostname")); |
382 | goto split_fail; | 376 | goto split_fail; |
383 | } | 377 | } |
384 | *rbracket = '\0'; | 378 | *rbracket = '\0'; |
@@ -395,7 +389,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -395,7 +389,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
395 | 389 | ||
396 | /* Check for an empty string. */ | 390 | /* Check for an empty string. */ |
397 | if (!*s || *s == ':') { | 391 | if (!*s || *s == ':') { |
398 | - popup_an_error("Empty hostname"); | 392 | + popup_an_error(hSession,"Empty hostname"); |
399 | goto split_fail; | 393 | goto split_fail; |
400 | } | 394 | } |
401 | 395 | ||
@@ -431,8 +425,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -431,8 +425,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
431 | while (*s && isspace(*s)) | 425 | while (*s && isspace(*s)) |
432 | s++; | 426 | s++; |
433 | if (!*s) { | 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 | goto split_fail; | 429 | goto split_fail; |
437 | } | 430 | } |
438 | } | 431 | } |
@@ -447,8 +440,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | @@ -447,8 +440,7 @@ split_host(char *s, char *ansi, char *std_ds, char *passthru, | ||
447 | while (*s && !isspace(*s) && *s != ':') | 440 | while (*s && !isspace(*s) && *s != ':') |
448 | s++; | 441 | s++; |
449 | if (*s != '\0') { | 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 | goto split_fail; | 444 | goto split_fail; |
453 | } | 445 | } |
454 | goto split_success; | 446 | goto split_success; |
@@ -482,7 +474,7 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -482,7 +474,7 @@ static int do_connect(H3270 *hSession, const char *n) | ||
482 | while (*n == ' ') | 474 | while (*n == ' ') |
483 | n++; | 475 | n++; |
484 | if (!*n) { | 476 | if (!*n) { |
485 | - popup_an_error("Invalid (empty) hostname"); | 477 | + popup_an_error(hSession,_( "Invalid (empty) hostname" )); |
486 | return -1; | 478 | return -1; |
487 | } | 479 | } |
488 | 480 | ||
@@ -512,7 +504,7 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -512,7 +504,7 @@ static int do_connect(H3270 *hSession, const char *n) | ||
512 | Boolean needed; | 504 | Boolean needed; |
513 | 505 | ||
514 | /* Strip off and remember leading qualifiers. */ | 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 | &hSession->passthru_host, &hSession->non_tn3270e_host, &hSession->ssl_host, | 508 | &hSession->passthru_host, &hSession->non_tn3270e_host, &hSession->ssl_host, |
517 | &hSession->no_login_host, hSession->luname, &port, | 509 | &hSession->no_login_host, hSession->luname, &port, |
518 | &needed)) == CN) | 510 | &needed)) == CN) |
src/lib3270/kybd.c
@@ -313,7 +313,7 @@ Boolean run_ta(void) | @@ -313,7 +313,7 @@ Boolean run_ta(void) | ||
313 | */ | 313 | */ |
314 | 314 | ||
315 | default: | 315 | default: |
316 | - popup_an_error( _( "Unexpected type %d in typeahead queue" ), ta->type); | 316 | + popup_an_error(NULL, _( "Unexpected type %d in typeahead queue" ), ta->type); |
317 | 317 | ||
318 | } | 318 | } |
319 | 319 |
src/lib3270/log.c
@@ -30,122 +30,56 @@ | @@ -30,122 +30,56 @@ | ||
30 | * | 30 | * |
31 | */ | 31 | */ |
32 | 32 | ||
33 | - | ||
34 | -#include <string.h> | ||
35 | #include <stdio.h> | 33 | #include <stdio.h> |
36 | #include <stdarg.h> | 34 | #include <stdarg.h> |
37 | -#include <errno.h> | ||
38 | -#include <time.h> | ||
39 | -#include <fcntl.h> | ||
40 | #include <lib3270/config.h> | 35 | #include <lib3270/config.h> |
41 | #include <lib3270.h> | 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 | /*---[ Constants ]------------------------------------------------------------------------------------------*/ | 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 | /*---[ Implementacao ]--------------------------------------------------------------------------------------*/ | 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 | - |
src/lib3270/printer.c
@@ -157,13 +157,13 @@ printer_start(const char *lu) | @@ -157,13 +157,13 @@ printer_start(const char *lu) | ||
157 | 157 | ||
158 | /* Can't start two. */ | 158 | /* Can't start two. */ |
159 | if (printer_pid != -1) { | 159 | if (printer_pid != -1) { |
160 | - popup_an_error("printer is already running"); | 160 | + popup_an_error(NULL,"printer is already running"); |
161 | return; | 161 | return; |
162 | } | 162 | } |
163 | 163 | ||
164 | /* Gotta be in 3270 mode. */ | 164 | /* Gotta be in 3270 mode. */ |
165 | if (!IN_3270) { | 165 | if (!IN_3270) { |
166 | - popup_an_error("Not in 3270 mode"); | 166 | + popup_an_error(NULL,"Not in 3270 mode"); |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | 169 | ||
@@ -173,13 +173,13 @@ printer_start(const char *lu) | @@ -173,13 +173,13 @@ printer_start(const char *lu) | ||
173 | 173 | ||
174 | /* Gotta be in TN3270E mode. */ | 174 | /* Gotta be in TN3270E mode. */ |
175 | if (!IN_TN3270E) { | 175 | if (!IN_TN3270E) { |
176 | - popup_an_error("Not in TN3270E mode"); | 176 | + popup_an_error(NULL,"Not in TN3270E mode"); |
177 | return; | 177 | return; |
178 | } | 178 | } |
179 | 179 | ||
180 | /* Gotta be connected to an LU. */ | 180 | /* Gotta be connected to an LU. */ |
181 | if (h3270.connected_lu == CN) { | 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 | return; | 183 | return; |
184 | } | 184 | } |
185 | lu = h3270.connected_lu; | 185 | lu = h3270.connected_lu; |
@@ -192,13 +192,13 @@ printer_start(const char *lu) | @@ -192,13 +192,13 @@ printer_start(const char *lu) | ||
192 | /* Fetch the command line and command resources. */ | 192 | /* Fetch the command line and command resources. */ |
193 | cmdline = get_resource(cmdlineName); | 193 | cmdline = get_resource(cmdlineName); |
194 | if (cmdline == CN) { | 194 | if (cmdline == CN) { |
195 | - popup_an_error("%s resource not defined", cmdlineName); | 195 | + popup_an_error(NULL,"%s resource not defined", cmdlineName); |
196 | return; | 196 | return; |
197 | } | 197 | } |
198 | #if !defined(_WIN32) /*[*/ | 198 | #if !defined(_WIN32) /*[*/ |
199 | cmd = get_resource(ResPrinterCommand); | 199 | cmd = get_resource(ResPrinterCommand); |
200 | if (cmd == CN) { | 200 | if (cmd == CN) { |
201 | - popup_an_error("printer.command resource not defined"); | 201 | + popup_an_error(NULL,"printer.command resource not defined"); |
202 | return; | 202 | return; |
203 | } | 203 | } |
204 | #else /*][*/ | 204 | #else /*][*/ |
@@ -496,7 +496,7 @@ printer_data(struct pr3o *p, Boolean is_err) | @@ -496,7 +496,7 @@ printer_data(struct pr3o *p, Boolean is_err) | ||
496 | p->count = PRINTER_BUF - 1; | 496 | p->count = PRINTER_BUF - 1; |
497 | printer_dump(p, True, True); | 497 | printer_dump(p, True, True); |
498 | } else { | 498 | } else { |
499 | - popup_an_error(exitmsg); | 499 | + popup_an_error(NULL,exitmsg); |
500 | } | 500 | } |
501 | printer_stop(); | 501 | printer_stop(); |
502 | return; | 502 | return; |
src/lib3270/proxy.c
@@ -158,7 +158,7 @@ proxy_setup(char **phost, char **pport) | @@ -158,7 +158,7 @@ proxy_setup(char **phost, char **pport) | ||
158 | return PT_NONE; | 158 | return PT_NONE; |
159 | 159 | ||
160 | if ((colon = strchr(proxy, ':')) == CN || (colon == proxy)) { | 160 | if ((colon = strchr(proxy, ':')) == CN || (colon == proxy)) { |
161 | - popup_an_error("Invalid proxy syntax"); | 161 | + popup_an_error(NULL,"Invalid proxy syntax"); |
162 | return -1; | 162 | return -1; |
163 | } | 163 | } |
164 | 164 | ||
@@ -187,7 +187,7 @@ proxy_setup(char **phost, char **pport) | @@ -187,7 +187,7 @@ proxy_setup(char **phost, char **pport) | ||
187 | if (parse_host_port(colon + 1, phost, pport) < 0) | 187 | if (parse_host_port(colon + 1, phost, pport) < 0) |
188 | return -1; | 188 | return -1; |
189 | if (*pport == CN) { | 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 | return -1; | 191 | return -1; |
192 | } | 192 | } |
193 | return PT_TELNET; | 193 | return PT_TELNET; |
@@ -255,7 +255,7 @@ parse_host_port(char *s, char **phost, char **pport) | @@ -255,7 +255,7 @@ parse_host_port(char *s, char **phost, char **pport) | ||
255 | rbrack == s + 1 || | 255 | rbrack == s + 1 || |
256 | (*(rbrack + 1) != '\0' && *(rbrack + 1) != ':')) { | 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 | return -1; | 259 | return -1; |
260 | } | 260 | } |
261 | if (*(rbrack + 1) == ':') | 261 | if (*(rbrack + 1) == ':') |
@@ -267,7 +267,7 @@ parse_host_port(char *s, char **phost, char **pport) | @@ -267,7 +267,7 @@ parse_host_port(char *s, char **phost, char **pport) | ||
267 | hstart = s; | 267 | hstart = s; |
268 | colon = strchr(s, ':'); | 268 | colon = strchr(s, ':'); |
269 | if (colon == s) { | 269 | if (colon == s) { |
270 | - popup_an_error("Invalid proxy hostname syntax"); | 270 | + popup_an_error(NULL,"Invalid proxy hostname syntax"); |
271 | return -1; | 271 | return -1; |
272 | } | 272 | } |
273 | if (colon == NULL) | 273 | if (colon == NULL) |
@@ -333,7 +333,7 @@ proxy_passthru(int fd, char *host, unsigned short port) | @@ -333,7 +333,7 @@ proxy_passthru(int fd, char *host, unsigned short port) | ||
333 | #endif /*]*/ | 333 | #endif /*]*/ |
334 | 334 | ||
335 | if (send(fd, buf, strlen(buf), 0) < 0) { | 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 | Free(buf); | 337 | Free(buf); |
338 | return -1; | 338 | return -1; |
339 | } | 339 | } |
@@ -368,7 +368,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -368,7 +368,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
368 | #endif /*]*/ | 368 | #endif /*]*/ |
369 | 369 | ||
370 | if (send(fd, buf, strlen(buf), 0) < 0) { | 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 | Free(buf); | 372 | Free(buf); |
373 | return -1; | 373 | return -1; |
374 | } | 374 | } |
@@ -385,7 +385,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -385,7 +385,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
385 | #endif /*]*/ | 385 | #endif /*]*/ |
386 | 386 | ||
387 | if (send(fd, buf, strlen(buf), 0) < 0) { | 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 | Free(buf); | 389 | Free(buf); |
390 | return -1; | 390 | return -1; |
391 | } | 391 | } |
@@ -397,7 +397,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -397,7 +397,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
397 | #endif /*]*/ | 397 | #endif /*]*/ |
398 | 398 | ||
399 | if (send(fd, buf, strlen(buf), 0) < 0) { | 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 | Free(buf); | 401 | Free(buf); |
402 | return -1; | 402 | return -1; |
403 | } | 403 | } |
@@ -416,7 +416,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -416,7 +416,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
416 | tv.tv_sec = 15; | 416 | tv.tv_sec = 15; |
417 | tv.tv_usec = 0; | 417 | tv.tv_usec = 0; |
418 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { | 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 | #if defined(X3270_TRACE) /*[*/ | 420 | #if defined(X3270_TRACE) /*[*/ |
421 | if (nread) | 421 | if (nread) |
422 | trace_netdata('<', (unsigned char *)rbuf, nread); | 422 | trace_netdata('<', (unsigned char *)rbuf, nread); |
@@ -426,7 +426,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -426,7 +426,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
426 | 426 | ||
427 | nr = recv(fd, &rbuf[nread], 1, 0); | 427 | nr = recv(fd, &rbuf[nread], 1, 0); |
428 | if (nr < 0) { | 428 | if (nr < 0) { |
429 | - popup_a_sockerr("HTTP Proxy: receive error"); | 429 | + popup_a_sockerr(NULL,"HTTP Proxy: receive error"); |
430 | #if defined(X3270_TRACE) /*[*/ | 430 | #if defined(X3270_TRACE) /*[*/ |
431 | if (nread) | 431 | if (nread) |
432 | trace_netdata('<', (unsigned char *)rbuf, nread); | 432 | trace_netdata('<', (unsigned char *)rbuf, nread); |
@@ -438,7 +438,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -438,7 +438,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
438 | if (nread) | 438 | if (nread) |
439 | trace_netdata('<', (unsigned char *)rbuf, nread); | 439 | trace_netdata('<', (unsigned char *)rbuf, nread); |
440 | #endif /*]*/ | 440 | #endif /*]*/ |
441 | - popup_an_error("HTTP Proxy: unexpected EOF"); | 441 | + popup_an_error(NULL,"HTTP Proxy: unexpected EOF"); |
442 | return -1; | 442 | return -1; |
443 | } | 443 | } |
444 | if (rbuf[nread] == '\r') | 444 | if (rbuf[nread] == '\r') |
@@ -458,11 +458,11 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -458,11 +458,11 @@ proxy_http(int fd, char *host, unsigned short port) | ||
458 | #endif /*]*/ | 458 | #endif /*]*/ |
459 | 459 | ||
460 | if (strncmp(rbuf, "HTTP/", 5) || (space = strchr(rbuf, ' ')) == CN) { | 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 | return -1; | 462 | return -1; |
463 | } | 463 | } |
464 | if (*(space + 1) != '2') { | 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 | return -1; | 466 | return -1; |
467 | } | 467 | } |
468 | 468 | ||
@@ -484,7 +484,7 @@ proxy_telnet(int fd, char *host, unsigned short port) | @@ -484,7 +484,7 @@ proxy_telnet(int fd, char *host, unsigned short port) | ||
484 | #endif /*]*/ | 484 | #endif /*]*/ |
485 | 485 | ||
486 | if (send(fd, buf, strlen(buf), 0) < 0) { | 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 | Free(buf); | 488 | Free(buf); |
489 | return -1; | 489 | return -1; |
490 | } | 490 | } |
@@ -550,7 +550,7 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) | @@ -550,7 +550,7 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) | ||
550 | #endif /*]*/ | 550 | #endif /*]*/ |
551 | 551 | ||
552 | if (send(fd, buf, s - buf, 0) < 0) { | 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 | Free(buf); | 554 | Free(buf); |
555 | return -1; | 555 | return -1; |
556 | } | 556 | } |
@@ -577,7 +577,7 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) | @@ -577,7 +577,7 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) | ||
577 | 577 | ||
578 | if (send(fd, buf, s - buf, 0) < 0) { | 578 | if (send(fd, buf, s - buf, 0) < 0) { |
579 | Free(buf); | 579 | Free(buf); |
580 | - popup_a_sockerr("SOCKS4 Proxy: send error"); | 580 | + popup_a_sockerr(NULL,"SOCKS4 Proxy: send error"); |
581 | return -1; | 581 | return -1; |
582 | } | 582 | } |
583 | Free(buf); | 583 | Free(buf); |
@@ -596,13 +596,13 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) | @@ -596,13 +596,13 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) | ||
596 | tv.tv_sec = 15; | 596 | tv.tv_sec = 15; |
597 | tv.tv_usec = 0; | 597 | tv.tv_usec = 0; |
598 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { | 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 | return -1; | 600 | return -1; |
601 | } | 601 | } |
602 | 602 | ||
603 | nr = recv(fd, &rbuf[nread], 1, 0); | 603 | nr = recv(fd, &rbuf[nread], 1, 0); |
604 | if (nr < 0) { | 604 | if (nr < 0) { |
605 | - popup_a_sockerr("SOCKS4 Proxy: receive error"); | 605 | + popup_a_sockerr(NULL,"SOCKS4 Proxy: receive error"); |
606 | return -1; | 606 | return -1; |
607 | } | 607 | } |
608 | if (nr == 0) | 608 | if (nr == 0) |
@@ -631,16 +631,16 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) | @@ -631,16 +631,16 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a) | ||
631 | case 0x5a: | 631 | case 0x5a: |
632 | break; | 632 | break; |
633 | case 0x5b: | 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 | return -1; | 635 | return -1; |
636 | case 0x5c: | 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 | return -1; | 638 | return -1; |
639 | case 0x5d: | 639 | case 0x5d: |
640 | - popup_an_error("SOCKS4 Proxy: userid error"); | 640 | + popup_an_error(NULL,"SOCKS4 Proxy: userid error"); |
641 | return -1; | 641 | return -1; |
642 | default: | 642 | default: |
643 | - popup_an_error("SOCKS4 Proxy: unknown status 0x%02x", | 643 | + popup_an_error(NULL,"SOCKS4 Proxy: unknown status 0x%02x", |
644 | rbuf[1]); | 644 | rbuf[1]); |
645 | return -1; | 645 | return -1; |
646 | } | 646 | } |
@@ -708,7 +708,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -708,7 +708,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
708 | trace_netdata('>', rbuf, 3); | 708 | trace_netdata('>', rbuf, 3); |
709 | #endif /*]*/ | 709 | #endif /*]*/ |
710 | if (send(fd, (const char *) rbuf, 3, 0) < 0) { | 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 | return -1; | 712 | return -1; |
713 | } | 713 | } |
714 | 714 | ||
@@ -726,7 +726,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -726,7 +726,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
726 | tv.tv_sec = 15; | 726 | tv.tv_sec = 15; |
727 | tv.tv_usec = 0; | 727 | tv.tv_usec = 0; |
728 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { | 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 | #if defined(X3270_TRACE) /*[*/ | 730 | #if defined(X3270_TRACE) /*[*/ |
731 | if (nread) | 731 | if (nread) |
732 | trace_netdata('<', rbuf, nread); | 732 | trace_netdata('<', rbuf, nread); |
@@ -736,7 +736,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -736,7 +736,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
736 | 736 | ||
737 | nr = recv(fd, (char *) &rbuf[nread], 1, 0); | 737 | nr = recv(fd, (char *) &rbuf[nread], 1, 0); |
738 | if (nr < 0) { | 738 | if (nr < 0) { |
739 | - popup_a_sockerr("SOCKS5 Proxy: receive error"); | 739 | + popup_a_sockerr(NULL,"SOCKS5 Proxy: receive error"); |
740 | #if defined(X3270_TRACE) /*[*/ | 740 | #if defined(X3270_TRACE) /*[*/ |
741 | if (nread) | 741 | if (nread) |
742 | trace_netdata('<', rbuf, nread); | 742 | trace_netdata('<', rbuf, nread); |
@@ -744,7 +744,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -744,7 +744,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
744 | return -1; | 744 | return -1; |
745 | } | 745 | } |
746 | if (nr == 0) { | 746 | if (nr == 0) { |
747 | - popup_a_sockerr("SOCKS5 Proxy: unexpected EOF"); | 747 | + popup_a_sockerr(NULL,"SOCKS5 Proxy: unexpected EOF"); |
748 | #if defined(X3270_TRACE) /*[*/ | 748 | #if defined(X3270_TRACE) /*[*/ |
749 | if (nread) | 749 | if (nread) |
750 | trace_netdata('<', rbuf, nread); | 750 | trace_netdata('<', rbuf, nread); |
@@ -760,7 +760,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -760,7 +760,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
760 | #endif /*]*/ | 760 | #endif /*]*/ |
761 | 761 | ||
762 | if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff)) { | 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 | return -1; | 764 | return -1; |
765 | } | 765 | } |
766 | 766 | ||
@@ -770,7 +770,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -770,7 +770,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
770 | #endif /*]*/ | 770 | #endif /*]*/ |
771 | 771 | ||
772 | if (rbuf[1] == 0xff) { | 772 | if (rbuf[1] == 0xff) { |
773 | - popup_an_error("SOCKS5 Proxy: authentication failure"); | 773 | + popup_an_error(NULL,"SOCKS5 Proxy: authentication failure"); |
774 | return -1; | 774 | return -1; |
775 | } | 775 | } |
776 | 776 | ||
@@ -811,7 +811,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -811,7 +811,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
811 | #endif /*]*/ | 811 | #endif /*]*/ |
812 | 812 | ||
813 | if (send(fd, buf, s - buf, 0) < 0) { | 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 | Free(buf); | 815 | Free(buf); |
816 | return -1; | 816 | return -1; |
817 | } | 817 | } |
@@ -835,13 +835,13 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -835,13 +835,13 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
835 | tv.tv_sec = 15; | 835 | tv.tv_sec = 15; |
836 | tv.tv_usec = 0; | 836 | tv.tv_usec = 0; |
837 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { | 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 | return -1; | 839 | return -1; |
840 | } | 840 | } |
841 | 841 | ||
842 | nr = recv(fd, (char *) &r, 1, 0); | 842 | nr = recv(fd, (char *) &r, 1, 0); |
843 | if (nr < 0) { | 843 | if (nr < 0) { |
844 | - popup_a_sockerr("SOCKS5 Proxy: receive error"); | 844 | + popup_a_sockerr(NULL,"SOCKS5 Proxy: receive error"); |
845 | #if defined(X3270_TRACE) /*[*/ | 845 | #if defined(X3270_TRACE) /*[*/ |
846 | if (nread) | 846 | if (nread) |
847 | trace_netdata('<', (unsigned char *)buf, nread); | 847 | trace_netdata('<', (unsigned char *)buf, nread); |
@@ -849,7 +849,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -849,7 +849,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
849 | return -1; | 849 | return -1; |
850 | } | 850 | } |
851 | if (nr == 0) { | 851 | if (nr == 0) { |
852 | - popup_an_error("SOCKS5 Proxy: unexpected EOF"); | 852 | + popup_an_error(NULL,"SOCKS5 Proxy: unexpected EOF"); |
853 | #if defined(X3270_TRACE) /*[*/ | 853 | #if defined(X3270_TRACE) /*[*/ |
854 | if (nread) | 854 | if (nread) |
855 | trace_netdata('<', (unsigned char *)buf, nread); | 855 | trace_netdata('<', (unsigned char *)buf, nread); |
@@ -881,37 +881,37 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -881,37 +881,37 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
881 | case 0x00: | 881 | case 0x00: |
882 | break; | 882 | break; |
883 | case 0x01: | 883 | case 0x01: |
884 | - popup_an_error("SOCKS5 Proxy: server failure"); | 884 | + popup_an_error(NULL,"SOCKS5 Proxy: server failure"); |
885 | return -1; | 885 | return -1; |
886 | case 0x02: | 886 | case 0x02: |
887 | - popup_an_error("SOCKS5 Proxy: connection not " | 887 | + popup_an_error(NULL,"SOCKS5 Proxy: connection not " |
888 | "allowed"); | 888 | "allowed"); |
889 | return -1; | 889 | return -1; |
890 | case 0x03: | 890 | case 0x03: |
891 | - popup_an_error("SOCKS5 Proxy: network " | 891 | + popup_an_error(NULL,"SOCKS5 Proxy: network " |
892 | "unreachable"); | 892 | "unreachable"); |
893 | return -1; | 893 | return -1; |
894 | case 0x04: | 894 | case 0x04: |
895 | - popup_an_error("SOCKS5 Proxy: host " | 895 | + popup_an_error(NULL,"SOCKS5 Proxy: host " |
896 | "unreachable"); | 896 | "unreachable"); |
897 | return -1; | 897 | return -1; |
898 | case 0x05: | 898 | case 0x05: |
899 | - popup_an_error("SOCKS5 Proxy: connection " | 899 | + popup_an_error(NULL,"SOCKS5 Proxy: connection " |
900 | "refused"); | 900 | "refused"); |
901 | return -1; | 901 | return -1; |
902 | case 0x06: | 902 | case 0x06: |
903 | - popup_an_error("SOCKS5 Proxy: ttl expired"); | 903 | + popup_an_error(NULL,"SOCKS5 Proxy: ttl expired"); |
904 | return -1; | 904 | return -1; |
905 | case 0x07: | 905 | case 0x07: |
906 | - popup_an_error("SOCKS5 Proxy: command not " | 906 | + popup_an_error(NULL,"SOCKS5 Proxy: command not " |
907 | "supported"); | 907 | "supported"); |
908 | return -1; | 908 | return -1; |
909 | case 0x08: | 909 | case 0x08: |
910 | - popup_an_error("SOCKS5 Proxy: address type " | 910 | + popup_an_error(NULL,"SOCKS5 Proxy: address type " |
911 | "not supported"); | 911 | "not supported"); |
912 | return -1; | 912 | return -1; |
913 | default: | 913 | default: |
914 | - popup_an_error("SOCKS5 Proxy: unknown server " | 914 | + popup_an_error(NULL,"SOCKS5 Proxy: unknown server " |
915 | "error 0x%02x", r); | 915 | "error 0x%02x", r); |
916 | return -1; | 916 | return -1; |
917 | } | 917 | } |
src/lib3270/rpq.c
@@ -213,7 +213,7 @@ do_qr_rpqnames(void) | @@ -213,7 +213,7 @@ do_qr_rpqnames(void) | ||
213 | break; | 213 | break; |
214 | 214 | ||
215 | default: /* unsupported ID, (can't happen) */ | 215 | default: /* unsupported ID, (can't happen) */ |
216 | - Error("Unsupported RPQ term"); | 216 | + Error(NULL,"Unsupported RPQ term"); |
217 | break; | 217 | break; |
218 | } | 218 | } |
219 | 219 | ||
@@ -752,7 +752,7 @@ rpq_dump_warnings(void) | @@ -752,7 +752,7 @@ rpq_dump_warnings(void) | ||
752 | { | 752 | { |
753 | /* If there's something to complain about, only complain once. */ | 753 | /* If there's something to complain about, only complain once. */ |
754 | if (!rpq_complained && rpq_wbcnt) { | 754 | if (!rpq_complained && rpq_wbcnt) { |
755 | - popup_an_error(rpq_warnbuf); | 755 | + popup_an_error(NULL,rpq_warnbuf); |
756 | rpq_wbcnt = 0; | 756 | rpq_wbcnt = 0; |
757 | rpq_complained = True; | 757 | rpq_complained = True; |
758 | 758 |
src/lib3270/screen.c
@@ -159,7 +159,7 @@ int screen_init(H3270 *session) | @@ -159,7 +159,7 @@ int screen_init(H3270 *session) | ||
159 | 159 | ||
160 | if(callbacks->init()) | 160 | if(callbacks->init()) |
161 | { | 161 | { |
162 | - popup_an_error("Can't initialize terminal."); | 162 | + popup_an_error(session,"Can't initialize terminal."); |
163 | return -1; | 163 | return -1; |
164 | } | 164 | } |
165 | } | 165 | } |
@@ -784,137 +784,114 @@ int Register3270ScreenCallbacks(const struct lib3270_screen_callbacks *cbk) | @@ -784,137 +784,114 @@ int Register3270ScreenCallbacks(const struct lib3270_screen_callbacks *cbk) | ||
784 | return 0; | 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 | if(!fmt) | 791 | if(!fmt) |
790 | fmt = ""; | 792 | fmt = ""; |
791 | 793 | ||
792 | va_list arg_ptr; | 794 | va_list arg_ptr; |
793 | va_start(arg_ptr, fmt); | 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 | va_end(arg_ptr); | 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 | va_list arg_ptr; | 809 | va_list arg_ptr; |
805 | 810 | ||
811 | + CHECK_SESSION_HANDLE(session); | ||
812 | + | ||
806 | va_start(arg_ptr, fmt); | 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 | va_end(arg_ptr); | 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 | va_list arg_ptr; | 826 | va_list arg_ptr; |
837 | 827 | ||
828 | + CHECK_SESSION_HANDLE(session); | ||
829 | + | ||
838 | va_start(arg_ptr, fmt); | 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 | va_end(arg_ptr); | 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 | CHECK_SESSION_HANDLE(session); | 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 | va_list args; | 861 | va_list args; |
885 | 862 | ||
863 | + CHECK_SESSION_HANDLE(session); | ||
864 | + | ||
886 | va_start(args, fmt); | 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 | LIB3270_ACTION( testpattern ) | 896 | LIB3270_ACTION( testpattern ) |
920 | { | 897 | { |
src/lib3270/telnet.c
@@ -404,7 +404,7 @@ void popup_a_sockerr(char *fmt, ...) | @@ -404,7 +404,7 @@ void popup_a_sockerr(char *fmt, ...) | ||
404 | 404 | ||
405 | } | 405 | } |
406 | #else | 406 | #else |
407 | -void popup_a_sockerr(char *fmt, ...) | 407 | +void popup_a_sockerr(H3270 *session, char *fmt, ...) |
408 | { | 408 | { |
409 | va_list args; | 409 | va_list args; |
410 | char buffer[4096]; | 410 | char buffer[4096]; |
@@ -413,7 +413,7 @@ void popup_a_sockerr(char *fmt, ...) | @@ -413,7 +413,7 @@ void popup_a_sockerr(char *fmt, ...) | ||
413 | vsprintf(buffer, fmt, args); | 413 | vsprintf(buffer, fmt, args); |
414 | va_end(args); | 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 | #endif | 419 | #endif |
@@ -522,7 +522,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving | @@ -522,7 +522,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving | ||
522 | if (resolve_host_and_port(proxy_host, proxy_portname, | 522 | if (resolve_host_and_port(proxy_host, proxy_portname, |
523 | &proxy_port, &haddr.sa, &ha_len, errmsg, | 523 | &proxy_port, &haddr.sa, &ha_len, errmsg, |
524 | sizeof(errmsg)) < 0) { | 524 | sizeof(errmsg)) < 0) { |
525 | - popup_an_error(errmsg); | 525 | + popup_an_error(NULL,errmsg); |
526 | status_resolving(&h3270,0); | 526 | status_resolving(&h3270,0); |
527 | return -1; | 527 | return -1; |
528 | status_resolving(&h3270,0); | 528 | status_resolving(&h3270,0); |
@@ -542,7 +542,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving | @@ -542,7 +542,7 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving | ||
542 | if (resolve_host_and_port(host, portname, | 542 | if (resolve_host_and_port(host, portname, |
543 | &h3270.current_port, &haddr.sa, &ha_len, | 543 | &h3270.current_port, &haddr.sa, &ha_len, |
544 | errmsg, sizeof(errmsg)) < 0) { | 544 | errmsg, sizeof(errmsg)) < 0) { |
545 | - popup_an_error(errmsg); | 545 | + popup_an_error(NULL,errmsg); |
546 | status_resolving(&h3270,0); | 546 | status_resolving(&h3270,0); |
547 | return -1; | 547 | return -1; |
548 | status_resolving(&h3270,0); | 548 | status_resolving(&h3270,0); |
@@ -600,19 +600,19 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving | @@ -600,19 +600,19 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving | ||
600 | */ | 600 | */ |
601 | /* create the socket */ | 601 | /* create the socket */ |
602 | if ((h3270.sock = socket(haddr.sa.sa_family, SOCK_STREAM, 0)) == -1) { | 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 | return -1; | 604 | return -1; |
605 | } | 605 | } |
606 | 606 | ||
607 | /* set options for inline out-of-band data and keepalives */ | 607 | /* set options for inline out-of-band data and keepalives */ |
608 | if (setsockopt(h3270.sock, SOL_SOCKET, SO_OOBINLINE, (char *)&on, | 608 | if (setsockopt(h3270.sock, SOL_SOCKET, SO_OOBINLINE, (char *)&on, |
609 | sizeof(on)) < 0) { | 609 | sizeof(on)) < 0) { |
610 | - popup_a_sockerr( N_( "setsockopt(%s)" ), "SO_OOBINLINE"); | 610 | + popup_a_sockerr(NULL, N_( "setsockopt(%s)" ), "SO_OOBINLINE"); |
611 | close_fail; | 611 | close_fail; |
612 | } | 612 | } |
613 | if (setsockopt(h3270.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, | 613 | if (setsockopt(h3270.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, |
614 | sizeof(on)) < 0) { | 614 | sizeof(on)) < 0) { |
615 | - popup_a_sockerr( N_( "setsockopt(%s)" ), "SO_KEEPALIVE"); | 615 | + popup_a_sockerr(NULL, N_( "setsockopt(%s)" ), "SO_KEEPALIVE"); |
616 | close_fail; | 616 | close_fail; |
617 | } | 617 | } |
618 | #if defined(OMTU) /*[*/ | 618 | #if defined(OMTU) /*[*/ |
@@ -1031,7 +1031,7 @@ void net_input(H3270 *session) | @@ -1031,7 +1031,7 @@ void net_input(H3270 *session) | ||
1031 | if (HALF_CONNECTED) { | 1031 | if (HALF_CONNECTED) { |
1032 | popup_a_sockerr( N_( "%s:%d" ),h3270.hostname, h3270.current_port); | 1032 | popup_a_sockerr( N_( "%s:%d" ),h3270.hostname, h3270.current_port); |
1033 | } else if (socket_errno() != SE_ECONNRESET) { | 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 | host_disconnect(session,True); | 1036 | host_disconnect(session,True); |
1037 | return; | 1037 | return; |
@@ -1249,7 +1249,7 @@ telnet_fsm(unsigned char c) | @@ -1249,7 +1249,7 @@ telnet_fsm(unsigned char c) | ||
1249 | if (process_eor()) | 1249 | if (process_eor()) |
1250 | return -1; | 1250 | return -1; |
1251 | } else | 1251 | } else |
1252 | - Warning( _( "EOR received when not in 3270 mode, ignored." )); | 1252 | + Warning(NULL, _( "EOR received when not in 3270 mode, ignored." )); |
1253 | trace_dsn("RCVD EOR\n"); | 1253 | trace_dsn("RCVD EOR\n"); |
1254 | ibptr = ibuf; | 1254 | ibptr = ibuf; |
1255 | telnet_state = TNS_DATA; | 1255 | telnet_state = TNS_DATA; |
@@ -1441,8 +1441,7 @@ telnet_fsm(unsigned char c) | @@ -1441,8 +1441,7 @@ telnet_fsm(unsigned char c) | ||
1441 | telquals[sbbuf[1]]); | 1441 | telquals[sbbuf[1]]); |
1442 | if (lus != (char **)NULL && try_lu == CN) { | 1442 | if (lus != (char **)NULL && try_lu == CN) { |
1443 | /* None of the LUs worked. */ | 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 | return -1; | 1445 | return -1; |
1447 | } | 1446 | } |
1448 | 1447 | ||
@@ -2032,7 +2031,7 @@ net_rawout(unsigned const char *buf, int len) | @@ -2032,7 +2031,7 @@ net_rawout(unsigned const char *buf, int len) | ||
2032 | } else if (socket_errno() == SE_EINTR) { | 2031 | } else if (socket_errno() == SE_EINTR) { |
2033 | goto bot; | 2032 | goto bot; |
2034 | } else { | 2033 | } else { |
2035 | - popup_a_sockerr( N_( "Socket write error" ) ); | 2034 | + popup_a_sockerr(NULL, N_( "Socket write error" ) ); |
2036 | host_disconnect(&h3270,True); | 2035 | host_disconnect(&h3270,True); |
2037 | return; | 2036 | return; |
2038 | } | 2037 | } |
src/lib3270/utf8.c
@@ -428,7 +428,7 @@ utf8_set_display_charsets(char *cslist, char *csname) | @@ -428,7 +428,7 @@ utf8_set_display_charsets(char *cslist, char *csname) | ||
428 | break; | 428 | break; |
429 | } | 429 | } |
430 | if (tok == CN) { | 430 | if (tok == CN) { |
431 | - popup_an_error("Invalid displayCharset specification"); | 431 | + popup_an_error(NULL,"Invalid displayCharset specification"); |
432 | Free(dup); | 432 | Free(dup); |
433 | return False; | 433 | return False; |
434 | } | 434 | } |
@@ -439,7 +439,7 @@ utf8_set_display_charsets(char *cslist, char *csname) | @@ -439,7 +439,7 @@ utf8_set_display_charsets(char *cslist, char *csname) | ||
439 | break; | 439 | break; |
440 | } | 440 | } |
441 | if (dcs[i] == CN) { | 441 | if (dcs[i] == CN) { |
442 | - popup_an_error("Unknown displayCharset specification '%s'", | 442 | + popup_an_error(NULL,"Unknown displayCharset specification '%s'", |
443 | csname); | 443 | csname); |
444 | Free(dup); | 444 | Free(dup); |
445 | return False; | 445 | return False; |
src/lib3270/util.c
@@ -172,7 +172,7 @@ xs_vsprintf(const char *fmt, va_list args) | @@ -172,7 +172,7 @@ xs_vsprintf(const char *fmt, va_list args) | ||
172 | 172 | ||
173 | nc = vsprintf(buf, fmt, args); | 173 | nc = vsprintf(buf, fmt, args); |
174 | if (nc > sizeof(buf)) | 174 | if (nc > sizeof(buf)) |
175 | - Error("Internal buffer overflow"); | 175 | + Error(NULL,"Internal buffer overflow"); |
176 | r = Malloc(nc + 1); | 176 | r = Malloc(nc + 1); |
177 | return strcpy(r, buf); | 177 | return strcpy(r, buf); |
178 | #endif /*]*/ | 178 | #endif /*]*/ |
@@ -205,7 +205,7 @@ xs_warning(const char *fmt, ...) | @@ -205,7 +205,7 @@ xs_warning(const char *fmt, ...) | ||
205 | va_start(args, fmt); | 205 | va_start(args, fmt); |
206 | r = xs_vsprintf(fmt, args); | 206 | r = xs_vsprintf(fmt, args); |
207 | va_end(args); | 207 | va_end(args); |
208 | - Warning(r); | 208 | + Warning(NULL,r); |
209 | Free(r); | 209 | Free(r); |
210 | } | 210 | } |
211 | 211 | ||
@@ -218,7 +218,7 @@ xs_error(const char *fmt, ...) | @@ -218,7 +218,7 @@ xs_error(const char *fmt, ...) | ||
218 | va_start(args, fmt); | 218 | va_start(args, fmt); |
219 | r = xs_vsprintf(fmt, args); | 219 | r = xs_vsprintf(fmt, args); |
220 | va_end(args); | 220 | va_end(args); |
221 | - Error(r); | 221 | + Error(NULL,r); |
222 | Free(r); | 222 | Free(r); |
223 | } | 223 | } |
224 | 224 | ||
@@ -856,7 +856,7 @@ rpf(rpf_t *r, char *fmt, ...) | @@ -856,7 +856,7 @@ rpf(rpf_t *r, char *fmt, ...) | ||
856 | ns = vsprintf(tbuf, fmt, a); /* XXX: dangerous, but so is vsnprintf */ | 856 | ns = vsprintf(tbuf, fmt, a); /* XXX: dangerous, but so is vsnprintf */ |
857 | va_end(a); | 857 | va_end(a); |
858 | if (ns >= SP_TMP_LEN) | 858 | if (ns >= SP_TMP_LEN) |
859 | - Error("rpf overrun"); | 859 | + Error(NULL,"rpf overrun"); |
860 | 860 | ||
861 | /* Make sure we have that. */ | 861 | /* Make sure we have that. */ |
862 | while (r->alloc_len - r->cur_len < ns + 1) { | 862 | while (r->alloc_len - r->cur_len < ns + 1) { |