Commit ea9215dc1672713a3fde97ef5564e395fb07da46
1 parent
4a7c0b1b
Exists in
master
and in
5 other branches
Reincluindo função screen-trace
Showing
7 changed files
with
44 additions
and
674 deletions
Show diff stats
src/lib3270/ctlr.c
... | ... | @@ -2320,7 +2320,7 @@ ctlr_clear(H3270 *session, Boolean can_snap) |
2320 | 2320 | if (ctlr_any_data()) { |
2321 | 2321 | #if defined(X3270_TRACE) /*[*/ |
2322 | 2322 | if (can_snap && !trace_skipping && lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE)) |
2323 | - trace_screen(); | |
2323 | + trace_screen(session); | |
2324 | 2324 | #endif /*]*/ |
2325 | 2325 | // scroll_save(session->maxROWS, ever_3270 ? False : True); |
2326 | 2326 | } |
... | ... | @@ -2380,7 +2380,7 @@ void ctlr_add(int baddr, unsigned char c, unsigned char cs) |
2380 | 2380 | { |
2381 | 2381 | #if defined(X3270_TRACE) /*[*/ |
2382 | 2382 | if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_SCREEN_TRACE)) |
2383 | - trace_screen(); | |
2383 | + trace_screen(&h3270); | |
2384 | 2384 | #endif /*]*/ |
2385 | 2385 | trace_primed = False; |
2386 | 2386 | } | ... | ... |
src/lib3270/kybd.c
... | ... | @@ -181,7 +181,7 @@ static const char dxl[] = "0123456789abcdef"; |
181 | 181 | /* |
182 | 182 | * Check if the typeahead queue is available |
183 | 183 | */ |
184 | -static int enq_chk(void) | |
184 | +static int enq_chk(H3270 *session) | |
185 | 185 | { |
186 | 186 | /* If no connection, forget it. */ |
187 | 187 | if (!CONNECTED) |
... | ... | @@ -191,23 +191,23 @@ static int enq_chk(void) |
191 | 191 | } |
192 | 192 | |
193 | 193 | /* If operator error, complain and drop it. */ |
194 | - if (h3270.kybdlock & KL_OERR_MASK) | |
194 | + if (session->kybdlock & KL_OERR_MASK) | |
195 | 195 | { |
196 | - lib3270_ring_bell(NULL); | |
196 | + lib3270_ring_bell(session); | |
197 | 197 | trace_event(" dropped (operator error)\n"); |
198 | 198 | return -1; |
199 | 199 | } |
200 | 200 | |
201 | 201 | /* If scroll lock, complain and drop it. */ |
202 | - if (h3270.kybdlock & KL_SCROLLED) | |
202 | + if (session->kybdlock & KL_SCROLLED) | |
203 | 203 | { |
204 | - lib3270_ring_bell(&h3270); | |
204 | + lib3270_ring_bell(session); | |
205 | 205 | trace_event(" dropped (scrolled)\n"); |
206 | 206 | return -1; |
207 | 207 | } |
208 | 208 | |
209 | 209 | /* If typeahead disabled, complain and drop it. */ |
210 | - if (!h3270.typeahead) | |
210 | + if (!session->typeahead) | |
211 | 211 | { |
212 | 212 | trace_event(" dropped (no typeahead)\n"); |
213 | 213 | return -1; |
... | ... | @@ -219,11 +219,11 @@ static int enq_chk(void) |
219 | 219 | /* |
220 | 220 | * Put a "Key-aid" on the typeahead queue |
221 | 221 | */ |
222 | - static void enq_key(unsigned char aid_code) | |
222 | + static void enq_key(H3270 *session, unsigned char aid_code) | |
223 | 223 | { |
224 | 224 | struct ta *ta; |
225 | 225 | |
226 | - if(enq_chk()) | |
226 | + if(enq_chk(session)) | |
227 | 227 | return; |
228 | 228 | |
229 | 229 | ta = (struct ta *) lib3270_malloc(sizeof(*ta)); |
... | ... | @@ -240,11 +240,11 @@ static int enq_chk(void) |
240 | 240 | else |
241 | 241 | { |
242 | 242 | ta_head = ta; |
243 | - status_typeahead(&h3270,True); | |
243 | + status_typeahead(session,True); | |
244 | 244 | } |
245 | 245 | ta_tail = ta; |
246 | 246 | |
247 | - trace_event(" Key-aid queued (kybdlock 0x%x)\n", h3270.kybdlock); | |
247 | + trace_event(" Key-aid queued (kybdlock 0x%x)\n", session->kybdlock); | |
248 | 248 | } |
249 | 249 | |
250 | 250 | /* |
... | ... | @@ -254,7 +254,7 @@ static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char |
254 | 254 | { |
255 | 255 | struct ta *ta; |
256 | 256 | |
257 | - if(enq_chk()) | |
257 | + if(enq_chk(hSession)) | |
258 | 258 | return; |
259 | 259 | |
260 | 260 | CHECK_SESSION_HANDLE(hSession); |
... | ... | @@ -566,7 +566,7 @@ LIB3270_FKEY_ACTION( pfkey ) |
566 | 566 | if (hSession->kybdlock & KL_OIA_MINUS) |
567 | 567 | return -1; |
568 | 568 | else if (hSession->kybdlock) |
569 | - enq_key(pf_xlate[key-1]); | |
569 | + enq_key(hSession,pf_xlate[key-1]); | |
570 | 570 | else |
571 | 571 | key_AID(hSession,pf_xlate[key-1]); |
572 | 572 | |
... | ... | @@ -583,7 +583,7 @@ LIB3270_FKEY_ACTION( pakey ) |
583 | 583 | if (hSession->kybdlock & KL_OIA_MINUS) |
584 | 584 | return -1; |
585 | 585 | else if (hSession->kybdlock) |
586 | - enq_key(pa_xlate[key-1]); | |
586 | + enq_key(hSession,pa_xlate[key-1]); | |
587 | 587 | else |
588 | 588 | key_AID(hSession,pa_xlate[key-1]); |
589 | 589 | ... | ... |
src/lib3270/printc.h
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | * Global declarations for print.c. |
18 | 18 | */ |
19 | 19 | |
20 | -LIB3270_INTERNAL Boolean fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html); | |
20 | +// LIB3270_INTERNAL Boolean fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html); | |
21 | 21 | LIB3270_INTERNAL void PrintText_action(Widget w, XEvent *event, String *params, |
22 | 22 | Cardinal *num_params); |
23 | 23 | LIB3270_INTERNAL void PrintWindow_action(Widget w, XEvent *event, String *params, | ... | ... |
src/lib3270/screen.c
... | ... | @@ -78,7 +78,7 @@ static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const cha |
78 | 78 | |
79 | 79 | static int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list) = logpopup; |
80 | 80 | |
81 | -enum ts { TS_AUTO, TS_ON, TS_OFF }; | |
81 | +// enum ts { TS_AUTO, TS_ON, TS_OFF }; | |
82 | 82 | |
83 | 83 | static void status_connect(H3270 *session, int ignored, void *dunno); |
84 | 84 | static void status_3270_mode(H3270 *session, int ignored, void *dunno); | ... | ... |
src/lib3270/trace_ds.c
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple |
19 | 19 | * Place, Suite 330, Boston, MA, 02111-1307, USA |
20 | 20 | * |
21 | - * Este programa está nomeado como trace_ds.c e possui 1089 linhas de código. | |
21 | + * Este programa está nomeado como trace_ds.c e possui - linhas de código. | |
22 | 22 | * |
23 | 23 | * Contatos: |
24 | 24 | * |
... | ... | @@ -280,544 +280,37 @@ LIB3270_EXPORT void lib3270_trace_event(H3270 *session, const char *fmt, ...) |
280 | 280 | va_end(args); |
281 | 281 | } |
282 | 282 | |
283 | - | |
284 | - | |
285 | -/* | |
286 | -static void stop_tracing(void) | |
287 | -{ | |
288 | - if (tracef != NULL && tracef != stdout) | |
289 | - (void) fclose(tracef); | |
290 | - tracef = NULL; | |
291 | - if (tracef_pipe != NULL) { | |
292 | - (void) fclose(tracef_pipe); | |
293 | - tracef_pipe = NULL; | |
294 | - } | |
295 | - | |
296 | - lib3270_set_toggle(&h3270,DS_TRACE,0); | |
297 | - lib3270_set_toggle(&h3270,EVENT_TRACE,0); | |
298 | - | |
299 | -} | |
300 | -*/ | |
301 | - | |
302 | -/* Check for a trace file rollover event. | |
303 | -void | |
304 | -trace_rollover_check(void) | |
305 | -{ | |
306 | - if (tracef == NULL || tracef_max == 0) | |
307 | - return; | |
308 | - | |
309 | - // See if we've reached the midpoint. | |
310 | - if (!tracef_midpoint) { | |
311 | - if (tracef_size >= tracef_max / 2) { | |
312 | - tracef_midpoint = ftello(tracef); | |
313 | -#if defined(ROLLOVER_DEBUG) | |
314 | - printf("midpoint is %lld\n", tracef_midpoint); | |
315 | -#endif | |
316 | - tracef_midpoint_header = | |
317 | - create_tracefile_header("rolled over"); | |
318 | - } | |
319 | - return; | |
320 | - } | |
321 | - | |
322 | - // See if we've reached a rollover point. | |
323 | - if (tracef_size >= tracef_max) { | |
324 | - char buf[8*1024]; | |
325 | - int nr; | |
326 | - off_t rpos = tracef_midpoint, wpos = 0; | |
327 | - | |
328 | - if (!tracef_midpoint) | |
329 | - Error("Tracefile rollover logic error"); | |
330 | -#if defined(ROLLOVER_DEBUG) | |
331 | - printf("rolling over at %lld\n", tracef_size); | |
332 | -#endif | |
333 | - // | |
334 | - // Overwrite the file with the midpoint header, and the data | |
335 | - // which follows the midpoint. | |
336 | - // | |
337 | - if (fseeko(tracef, 0, SEEK_SET) < 0) { | |
338 | - popup_an_errno(errno, "trace file fseeko(0) failed"); | |
339 | - stop_tracing(); | |
340 | - return; | |
341 | - } | |
342 | - wtrace("%s", tracef_midpoint_header); | |
343 | - wpos = ftello(tracef); | |
344 | - if (wpos < 0) { | |
345 | - popup_an_errno(errno, "trace file ftello() failed"); | |
346 | - stop_tracing(); | |
347 | - return; | |
348 | - } | |
349 | - if (fseeko(tracef, rpos, SEEK_SET) < 0) { | |
350 | - popup_an_errno(errno, "trace file fseeko(%ld) failed", | |
351 | - (long)rpos); | |
352 | - stop_tracing(); | |
353 | - return; | |
354 | - } | |
355 | -#if defined(ROLLOVER_DEBUG) | |
356 | - printf("rpos = %lld, wpos = %lld\n", rpos, wpos); | |
357 | -#endif | |
358 | - while ((nr = fread(buf, 1, sizeof(buf), tracef)) > 0) { | |
359 | - rpos = ftello(tracef); | |
360 | - if (fseeko(tracef, wpos, SEEK_SET) < 0) { | |
361 | - popup_an_errno(errno, "trace file fseeko(%ld) " | |
362 | - "failed", (long)wpos); | |
363 | - stop_tracing(); | |
364 | - return; | |
365 | - } | |
366 | - if (fwrite(buf, nr, 1, tracef) < 1) | |
367 | - break; | |
368 | - wpos = ftello(tracef); | |
369 | - if (wpos < 0) { | |
370 | - popup_an_errno(errno, "trace file ftello() " | |
371 | - "failed"); | |
372 | - stop_tracing(); | |
373 | - return; | |
374 | - } | |
375 | - if (fseeko(tracef, rpos, SEEK_SET) < 0) { | |
376 | - popup_an_errno(errno, "trace file fseeko(%ld)" | |
377 | - "failed", (long)rpos); | |
378 | - stop_tracing(); | |
379 | - return; | |
380 | - } | |
381 | - } | |
382 | - if (ferror(tracef)) { | |
383 | - popup_an_errno(errno, "trace file rollover copy " | |
384 | - "failed"); | |
385 | - stop_tracing(); | |
386 | - return; | |
387 | - } | |
388 | -#if defined(ROLLOVER_DEBUG) | |
389 | - printf("final wpos = %lld\n", wpos); | |
390 | -#endif | |
391 | - if (ftruncate(fileno(tracef), wpos) < 0) { | |
392 | - popup_an_errno(errno, "trace file ftruncate(%ld) " | |
393 | - "failed", (long)wpos); | |
394 | - stop_tracing(); | |
395 | - return; | |
396 | - } | |
397 | - if (fseeko(tracef, wpos, SEEK_SET) < 0) { | |
398 | - popup_an_errno(errno, "trace file fseeko(%ld) failed", | |
399 | - (long)wpos); | |
400 | - stop_tracing(); | |
401 | - return; | |
402 | - } | |
403 | - tracef_size = wpos; | |
404 | - tracef_midpoint = wpos; | |
405 | - Replace(tracef_midpoint_header, | |
406 | - create_tracefile_header("rolled over")); | |
407 | - } | |
408 | -} | |
409 | -*/ | |
410 | - | |
411 | -/* | |
412 | -#if defined(X3270_DISPLAY) | |
413 | -static Widget trace_shell = (Widget)NULL; | |
414 | -#endif | |
415 | -static int trace_reason; | |
416 | -*/ | |
417 | - | |
418 | -/* Create a trace file header. */ /* | |
419 | -static char * create_tracefile_header(const char *mode) | |
420 | -{ | |
421 | - char *buf; | |
422 | - time_t clk; | |
423 | - | |
424 | - // Create a buffer and redirect output. | |
425 | - buf = lib3270_malloc(MAX_HEADER_SIZE); | |
426 | - tracef_bufptr = buf; | |
427 | - | |
428 | - // Display current status | |
429 | - clk = time((time_t *)0); | |
430 | - wtrace("Trace %s %s", mode, ctime(&clk)); | |
431 | - wtrace(" Version: %s\n", build); | |
432 | - wtrace(" Model %s", h3270.model_name); | |
433 | - wtrace(", %s display", appres.mono ? "monochrome" : "color"); | |
434 | - if (appres.extended) | |
435 | - wtrace(", extended data stream"); | |
436 | - wtrace(", %s emulation", appres.m3279 ? "color" : "monochrome"); | |
437 | - wtrace(", %s charset", lib3270_get_charset(&h3270)); | |
438 | - if (appres.apl_mode) | |
439 | - wtrace(", APL mode"); | |
440 | - wtrace("\n"); | |
441 | - if (CONNECTED) | |
442 | - wtrace(" Connected to %s, port %u\n",h3270.current_host, h3270.current_port); | |
443 | - | |
444 | - // Snap the current TELNET options. | |
445 | - if (net_snap_options()) { | |
446 | - wtrace(" TELNET state:\n"); | |
447 | - trace_netdata('<', obuf, obptr - obuf); | |
448 | - } | |
449 | - | |
450 | - // Dump the screen contents and modes into the trace file. | |
451 | - if (CONNECTED) { | |
452 | - // | |
453 | - // Note that if the screen is not formatted, we do not | |
454 | - // attempt to save what's on it. However, if we're in | |
455 | - // 3270 SSCP-LU or NVT mode, we'll do a dummy, empty | |
456 | - // write to ensure that the display is in the right | |
457 | - // mode. | |
458 | - // | |
459 | - if (h3270.formatted) { | |
460 | - wtrace(" Screen contents:\n"); | |
461 | - obptr = obuf; | |
462 | -#if defined(X3270_TN3270E) | |
463 | - (void) net_add_dummy_tn3270e(); | |
464 | -#endif | |
465 | - ctlr_snap_buffer(); | |
466 | - space3270out(2); | |
467 | - net_add_eor(obuf, obptr - obuf); | |
468 | - obptr += 2; | |
469 | - trace_netdata('<', obuf, obptr - obuf); | |
470 | - | |
471 | - obptr = obuf; | |
472 | -#if defined(X3270_TN3270E) | |
473 | - (void) net_add_dummy_tn3270e(); | |
474 | -#endif | |
475 | - if (ctlr_snap_modes()) { | |
476 | - wtrace(" 3270 modes:\n"); | |
477 | - space3270out(2); | |
478 | - net_add_eor(obuf, obptr - obuf); | |
479 | - obptr += 2; | |
480 | - trace_netdata('<', obuf, obptr - obuf); | |
481 | - } | |
482 | - } | |
483 | -#if defined(X3270_TN3270E) | |
484 | - else if (IN_E) { | |
485 | - obptr = obuf; | |
486 | - if (net_add_dummy_tn3270e()) { | |
487 | - wtrace(" Screen contents:\n"); | |
488 | - space3270out(2); | |
489 | - net_add_eor(obuf, obptr - obuf); | |
490 | - obptr += 2; | |
491 | - trace_netdata('<', obuf, obptr - obuf); | |
492 | - } | |
493 | - } | |
494 | -#endif | |
495 | - } | |
496 | - | |
497 | - wtrace(" Data stream:\n"); | |
498 | - | |
499 | - // Return the buffer. | |
500 | - tracef_bufptr = CN; | |
501 | - return buf; | |
502 | -} | |
503 | -*/ | |
504 | - | |
505 | -/* Calculate the tracefile maximum size. */ /* | |
506 | -static void | |
507 | -get_tracef_max(void) | |
508 | -{ | |
509 | - static Boolean calculated = False; | |
510 | - char *ptr; | |
511 | - Boolean bad = False; | |
512 | - | |
513 | - if (calculated) | |
514 | - return; | |
515 | - | |
516 | - calculated = True; | |
517 | - | |
518 | - if (appres.trace_file_size == CN || | |
519 | - !strcmp(appres.trace_file_size, "0") || | |
520 | - !strncasecmp(appres.trace_file_size, "none", | |
521 | - strlen(appres.trace_file_size))) { | |
522 | - tracef_max = 0; | |
523 | - return; | |
524 | - } | |
525 | - | |
526 | - tracef_max = strtoul(appres.trace_file_size, &ptr, 0); | |
527 | - if (tracef_max == 0 || ptr == appres.trace_file_size || *(ptr + 1)) { | |
528 | - bad = True; | |
529 | - } else switch (*ptr) { | |
530 | - case 'k': | |
531 | - case 'K': | |
532 | - tracef_max *= 1024; | |
533 | - break; | |
534 | - case 'm': | |
535 | - case 'M': | |
536 | - tracef_max *= 1024 * 1024; | |
537 | - break; | |
538 | - case '\0': | |
539 | - break; | |
540 | - default: | |
541 | - bad = True; | |
542 | - break; | |
543 | - } | |
544 | - | |
545 | - if (bad) { | |
546 | - tracef_max = MIN_TRACEFILE_SIZE; | |
547 | -#if defined(X3270_DISPLAY) | |
548 | - popup_an_info("Invalid %s '%s', assuming " | |
549 | - MIN_TRACEFILE_SIZE_NAME, | |
550 | - ResTraceFileSize, | |
551 | - appres.trace_file_size); | |
552 | -#endif | |
553 | - } else if (tracef_max < MIN_TRACEFILE_SIZE) { | |
554 | - tracef_max = MIN_TRACEFILE_SIZE; | |
555 | - } | |
556 | -} | |
557 | -*/ | |
558 | - | |
559 | -/* Parse the name '/dev/fd<n>', so we can simulate it. */ /* | |
560 | -static int | |
561 | -get_devfd(const char *pathname) | |
562 | -{ | |
563 | - unsigned long fd; | |
564 | - char *ptr; | |
565 | - | |
566 | - if (strncmp(pathname, "/dev/fd/", 8)) | |
567 | - return -1; | |
568 | - fd = strtoul(pathname + 8, &ptr, 10); | |
569 | - if (ptr == pathname + 8 || *ptr != '\0' || fd < 0) | |
570 | - return -1; | |
571 | - return fd; | |
572 | -} | |
573 | -*/ | |
574 | - | |
575 | -/* Callback for "OK" button on trace popup */ /* | |
576 | -static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_data unused) | |
283 | +/** | |
284 | + * Screen trace function, called when the host clears the screen. | |
285 | + * | |
286 | + * @param session Session Handle | |
287 | + */ | |
288 | +void trace_screen(H3270 *session) | |
577 | 289 | { |
578 | - char *tfn = CN; | |
579 | - int devfd = -1; | |
580 | - char *buf; | |
581 | - | |
582 | - tfn = (char *)client_data; | |
583 | - tfn = do_subst(tfn, True, True); | |
584 | - if (strchr(tfn, '\'') || ((int)strlen(tfn) > 0 && tfn[strlen(tfn)-1] == '\\')) | |
585 | - { | |
586 | - popup_an_error("Illegal file name: %s", tfn); | |
587 | - lib3270_free(tfn); | |
588 | - return; | |
589 | - } | |
590 | - | |
591 | - tracef_max = 0; | |
592 | - tracef_midpoint = 0; | |
593 | - Replace(tracef_midpoint_header, CN); | |
290 | + trace_skipping = False; | |
594 | 291 | |
595 | - if (!strcmp(tfn, "stdout")) | |
292 | + if (lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE)) | |
596 | 293 | { |
597 | - tracef = stdout; | |
598 | - } | |
599 | - else | |
600 | - { | |
601 | - // Get the trace file maximum. | |
602 | - get_tracef_max(); | |
603 | - | |
604 | - // If there's a limit, the file can't exist. | |
605 | - if (tracef_max && !access(tfn, R_OK)) | |
606 | - { | |
607 | - popup_an_error("Trace file '%s' already exists",tfn); | |
608 | - lib3270_free(tfn); | |
609 | - return; | |
610 | - } | |
294 | + int row, baddr; | |
611 | 295 | |
612 | - // Open and configure the file. | |
613 | - if ((devfd = get_devfd(tfn)) >= 0) | |
614 | - tracef = fdopen(dup(devfd), "a"); | |
615 | - else | |
616 | - tracef = fopen(tfn, tracef_max? "w+": "a"); | |
617 | - if (tracef == (FILE *)NULL) | |
296 | + for(row=baddr=0;row < session->rows;row++) | |
618 | 297 | { |
619 | - popup_an_errno(errno, tfn); | |
620 | - lib3270_free(tfn); | |
621 | - return; | |
298 | + int col; | |
299 | + wtrace("%02d ",row+1); | |
300 | + | |
301 | + for(col = 0; col < session->cols;col++) | |
302 | + { | |
303 | + if(session->text[baddr].attr & LIB3270_ATTR_CG) | |
304 | + wtrace("%c",'.'); | |
305 | + else if(session->text[baddr].chr) | |
306 | + wtrace("%c",session->text[baddr].chr); | |
307 | + else | |
308 | + wtrace("%c",'.'); | |
309 | + baddr++; | |
310 | + } | |
311 | + wtrace("%s\n",""); | |
622 | 312 | } |
623 | - (void) SETLINEBUF(tracef); | |
624 | -#if !defined(_WIN32) | |
625 | - (void) fcntl(fileno(tracef), F_SETFD, 1); | |
626 | -#endif | |
627 | 313 | } |
628 | - | |
629 | - // Open pw3270's console window | |
630 | - if(!tracewindow_handle) | |
631 | - tracewindow_handle = console_window_new( tfn, NULL ); | |
632 | - | |
633 | - lib3270_free(tfn); | |
634 | - | |
635 | - // We're really tracing, turn the flag on. | |
636 | - appres.toggle[trace_reason].value = True; | |
637 | -// appres.toggle[trace_reason].changed = True; | |
638 | -// menubar_retoggle(&appres.toggle[trace_reason]); | |
639 | - | |
640 | - // Display current status | |
641 | - buf = create_tracefile_header("started"); | |
642 | - wtrace("%s", buf); | |
643 | - lib3270_free(buf); | |
644 | - | |
645 | -} | |
646 | - | |
647 | -#if defined(X3270_DISPLAY) | |
648 | -// Callback for "No File" button on trace popup | |
649 | -static void | |
650 | -no_tracefile_callback(Widget w, XtPointer client_data, | |
651 | - XtPointer call_data unused) | |
652 | -{ | |
653 | - tracefile_callback((Widget)NULL, "", PN); | |
654 | - XtPopdown(trace_shell); | |
655 | -} | |
656 | -#endif | |
657 | -*/ | |
658 | - | |
659 | -/* Open the trace file. | |
660 | -static void | |
661 | -tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt) | |
662 | -{ | |
663 | - char *tracefile_buf = NULL; | |
664 | - char *tracefile; | |
665 | - | |
666 | - if (tracef != (FILE *)NULL) | |
667 | - return; | |
668 | - | |
669 | - trace_reason = reason; | |
670 | - if (appres.secure && tt != TT_INITIAL) { | |
671 | - tracefile_callback((Widget)NULL, "none", PN); | |
672 | - return; | |
673 | - } | |
674 | - if (appres.trace_file) | |
675 | - { | |
676 | - tracefile = appres.trace_file; | |
677 | - } | |
678 | - else | |
679 | - { | |
680 | -#if defined(_WIN32) | |
681 | - tracefile_buf = xs_buffer("%sx3trc.%u.txt", PROGRAM_DATA,getpid()); | |
682 | -#else | |
683 | - | |
684 | - if(appres.trace_dir) | |
685 | - tracefile_buf = xs_buffer("%s/x3trc.%u", appres.trace_dir,getpid()); | |
686 | - else | |
687 | - tracefile_buf = xs_buffer("%s/x3trc.%u", ".",getpid()); | |
688 | - | |
689 | -#endif | |
690 | - tracefile = tracefile_buf; | |
691 | - } | |
692 | - | |
693 | - | |
694 | -#if defined(X3270_DISPLAY) | |
695 | - if (tt == TT_INITIAL || tt == TT_ACTION) | |
696 | -#endif | |
697 | - { | |
698 | - tracefile_callback((Widget)NULL, tracefile, PN); | |
699 | - if (tracefile_buf != NULL) | |
700 | - lib3270_free(tracefile_buf); | |
701 | - return; | |
702 | - } | |
703 | -#if defined(X3270_DISPLAY) | |
704 | - if (trace_shell == NULL) { | |
705 | - trace_shell = create_form_popup("trace", | |
706 | - tracefile_callback, | |
707 | - appres.trace_monitor? no_tracefile_callback: NULL, | |
708 | - FORM_NO_WHITE); | |
709 | - XtVaSetValues(XtNameToWidget(trace_shell, ObjDialog), | |
710 | - XtNvalue, tracefile, | |
711 | - NULL); | |
712 | - } | |
713 | - | |
714 | - // Turn the toggle _off_ until the popup succeeds. | |
715 | - appres.toggle[reason].value = False; | |
716 | - appres.toggle[reason].changed = True; | |
717 | - | |
718 | - popup_popup(trace_shell, XtGrabExclusive); | |
719 | -#endif | |
720 | - | |
721 | - if (tracefile_buf != NULL) | |
722 | - lib3270_free(tracefile_buf); | |
723 | -} | |
724 | - | |
725 | -// Close the trace file. | |
726 | -static void tracefile_off(void) | |
727 | -{ | |
728 | - time_t clk; | |
729 | - | |
730 | - clk = time((time_t *)0); | |
731 | - wtrace("Trace stopped %s", ctime(&clk)); | |
732 | - | |
733 | -#if defined (LIB3270) | |
734 | - | |
735 | - if(tracewindow_handle != NULL) | |
736 | - { | |
737 | - console_window_delete(tracewindow_handle); | |
738 | - tracewindow_handle = NULL; | |
739 | - } | |
740 | - | |
741 | -#elif !defined(_WIN32) | |
742 | - | |
743 | - if (tracewindow_pid != -1) | |
744 | - (void) kill(tracewindow_pid, SIGKILL); | |
745 | - tracewindow_pid = -1; | |
746 | - | |
747 | -#else | |
748 | - | |
749 | - if (tracewindow_handle != NULL) | |
750 | - { | |
751 | - TerminateProcess(tracewindow_handle, 0); | |
752 | - CloseHandle(tracewindow_handle); | |
753 | - tracewindow_handle = NULL; | |
754 | - } | |
755 | - | |
756 | -#endif | |
757 | - | |
758 | - stop_tracing(); | |
759 | -} | |
760 | - | |
761 | - | |
762 | -void toggle_dsTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt) | |
763 | -{ | |
764 | - if (lib3270_get_toggle(&h3270,DS_TRACE) && tracef == NULL) | |
765 | - tracefile_on(DS_TRACE, tt); | |
766 | - | |
767 | - // If turning off trace and not still tracing events, close the trace file. | |
768 | - else if (!lib3270_get_toggle(&h3270,DS_TRACE) && !lib3270_get_toggle(&h3270,EVENT_TRACE)) | |
769 | - tracefile_off(); | |
770 | - | |
771 | - if (lib3270_get_toggle(&h3270,DS_TRACE)) | |
772 | - (void) gettimeofday(&ds_ts, (struct timezone *)NULL); | |
773 | -} | |
774 | -*/ | |
775 | - | |
776 | -/* | |
777 | -void toggle_eventTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt) | |
778 | -{ | |
779 | - // If turning on event debug, and no trace file, open one. | |
780 | - | |
781 | - if (lib3270_get_toggle(&h3270,EVENT_TRACE) && tracef == NULL) | |
782 | - tracefile_on(EVENT_TRACE, tt); | |
783 | - | |
784 | - // If turning off event debug, and not tracing the data stream, close the trace file. | |
785 | - else if (!lib3270_get_toggle(&h3270,EVENT_TRACE) && !lib3270_get_toggle(&h3270,DS_TRACE)) | |
786 | - tracefile_off(); | |
787 | -} | |
788 | -*/ | |
789 | - | |
790 | -/* Screen trace file support. */ | |
791 | - | |
792 | -/* | |
793 | -#if defined(X3270_DISPLAY) | |
794 | -static Widget screentrace_shell = (Widget)NULL; | |
795 | -#endif | |
796 | -static FILE *screentracef = (FILE *)0; | |
797 | -*/ | |
798 | -/* | |
799 | - * Screen trace function, called when the host clears the screen. | |
800 | - */ | |
801 | -static void do_screentrace(void) | |
802 | -{ | |
803 | - wtrace("\n%s - Not implemented\n",__FUNCTION__); | |
804 | -/* | |
805 | - register int i; | |
806 | - | |
807 | - if (fprint_screen(screentracef, False, False)) { | |
808 | - for (i = 0; i < h3270.cols; i++) | |
809 | - (void) fputc('=', screentracef); | |
810 | - (void) fputc('\n', screentracef); | |
811 | - } | |
812 | -*/ | |
813 | -} | |
814 | - | |
815 | -void trace_screen(void) | |
816 | -{ | |
817 | - trace_skipping = False; | |
818 | - | |
819 | - if (!lib3270_get_toggle(&h3270,LIB3270_TOGGLE_SCREEN_TRACE)) | |
820 | - do_screentrace(); | |
821 | 314 | } |
822 | 315 | |
823 | 316 | /* Called from ANSI emulation code to log a single character. */ |
... | ... | @@ -846,128 +339,5 @@ void trace_ansi_disc(void) |
846 | 339 | trace_skipping = True; |
847 | 340 | } |
848 | 341 | |
849 | -/* | |
850 | - * Screen tracing callback. | |
851 | - * Returns True for success, False for failure. | |
852 | - */ /* | |
853 | -static Boolean | |
854 | -screentrace_cb(char *tfn) | |
855 | -{ | |
856 | - tfn = do_subst(tfn, True, True); | |
857 | - screentracef = fopen(tfn, "a"); | |
858 | - if (screentracef == (FILE *)NULL) { | |
859 | - popup_an_errno(errno, tfn); | |
860 | - lib3270_free(tfn); | |
861 | - return False; | |
862 | - } | |
863 | - lib3270_free(tfn); | |
864 | - (void) SETLINEBUF(screentracef); | |
865 | -#if !defined(_WIN32) | |
866 | - (void) fcntl(fileno(screentracef), F_SETFD, 1); | |
867 | -#endif | |
868 | - | |
869 | - // We're really tracing, turn the flag on. | |
870 | - appres.toggle[SCREEN_TRACE].value = True; | |
871 | -// appres.toggle[SCREEN_TRACE].changed = True; | |
872 | -// menubar_retoggle(&appres.toggle[SCREEN_TRACE]); | |
873 | - return True; | |
874 | -} | |
875 | -*/ | |
876 | 342 | |
877 | -/* | |
878 | -#if defined(X3270_DISPLAY) | |
879 | -// Callback for "OK" button on screentrace popup | |
880 | -static void | |
881 | -screentrace_callback(Widget w unused, XtPointer client_data, | |
882 | - XtPointer call_data unused) | |
883 | -{ | |
884 | - if (screentrace_cb(XawDialogGetValueString((Widget)client_data))) | |
885 | - XtPopdown(screentrace_shell); | |
886 | -} | |
887 | - | |
888 | -// Callback for second "OK" button on screentrace popup | |
889 | -static void | |
890 | -onescreen_callback(Widget w, XtPointer client_data, XtPointer call_data unused) | |
891 | -{ | |
892 | - char *tfn; | |
893 | - | |
894 | - if (w) | |
895 | - tfn = XawDialogGetValueString((Widget)client_data); | |
896 | - else | |
897 | - tfn = (char *)client_data; | |
898 | - tfn = do_subst(tfn, True, True); | |
899 | - screentracef = fopen(tfn, "a"); | |
900 | - if (screentracef == (FILE *)NULL) { | |
901 | - popup_an_errno(errno, tfn); | |
902 | - XtFree(tfn); | |
903 | - return; | |
904 | - } | |
905 | - (void) fcntl(fileno(screentracef), F_SETFD, 1); | |
906 | - XtFree(tfn); | |
907 | - | |
908 | - // Save the current image, once. | |
909 | - do_screentrace(); | |
910 | - | |
911 | - // Close the file, we're done. | |
912 | - (void) fclose(screentracef); | |
913 | - screentracef = (FILE *)NULL; | |
914 | - | |
915 | - if (w) | |
916 | - XtPopdown(screentrace_shell); | |
917 | -} | |
918 | -#endif */ | |
919 | - | |
920 | -/* | |
921 | -void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt) | |
922 | -{ | |
923 | - wtrace("Screen trace is %s\n",toggled(SCREEN_TRACE),"Enabled" : "Disabled"); | |
924 | - | |
925 | - char *tracefile_buf = NULL; | |
926 | - char *tracefile; | |
927 | - | |
928 | - if (lib3270_get_toggle(&h3270,SCREEN_TRACE)) { | |
929 | - if (appres.screentrace_file) | |
930 | - tracefile = appres.screentrace_file; | |
931 | - else { | |
932 | -#if defined(_WIN32) | |
933 | - tracefile_buf = xs_buffer("%sx3scr.%u.txt",PROGRAM_DATA, getpid()); | |
934 | -#else | |
935 | - if(appres.trace_dir) | |
936 | - tracefile_buf = xs_buffer("%s/x3scr.%u",appres.trace_dir, getpid()); | |
937 | - else | |
938 | - tracefile_buf = xs_buffer("%s/x3scr.%u",".", getpid()); | |
939 | -#endif | |
940 | - tracefile = tracefile_buf; | |
941 | - } | |
942 | - if (tt == TT_INITIAL || tt == TT_ACTION) { | |
943 | - (void) screentrace_cb(NewString(tracefile)); | |
944 | - if (tracefile_buf != NULL) | |
945 | - lib3270_free(tracefile_buf); | |
946 | - return; | |
947 | - } | |
948 | -#if defined(X3270_DISPLAY) | |
949 | - if (screentrace_shell == NULL) { | |
950 | - screentrace_shell = create_form_popup("screentrace", | |
951 | - screentrace_callback, onescreen_callback, | |
952 | - FORM_NO_WHITE); | |
953 | - XtVaSetValues(XtNameToWidget(screentrace_shell, | |
954 | - ObjDialog), | |
955 | - XtNvalue, tracefile, | |
956 | - NULL); | |
957 | - } | |
958 | - appres.toggle[SCREEN_TRACE].value = False; | |
959 | - appres.toggle[SCREEN_TRACE].changed = True; | |
960 | - popup_popup(screentrace_shell, XtGrabExclusive); | |
961 | 343 | #endif |
962 | - } else { | |
963 | - if (ctlr_any_data() && !trace_skipping) | |
964 | - do_screentrace(); | |
965 | - (void) fclose(screentracef); | |
966 | - } | |
967 | - | |
968 | - if (tracefile_buf != NULL) | |
969 | - lib3270_free(tracefile_buf); | |
970 | -} | |
971 | -*/ | |
972 | - | |
973 | -#endif /*]*/ | ... | ... |
src/lib3270/trace_dsc.h
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | void trace_ds_nb(const char *fmt, ...) printflike(1, 2); |
49 | 49 | void trace_dsn(const char *fmt, ...) printflike(1, 2); |
50 | 50 | void trace_event(const char *fmt, ...) printflike(1, 2); |
51 | - void trace_screen(void); | |
51 | + void trace_screen(H3270 *session); | |
52 | 52 | // void trace_rollover_check(void); |
53 | 53 | |
54 | 54 | #elif defined(__GNUC__) | ... | ... |
ui/99debug.xml
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | <menu name='View' > |
39 | 39 | <menu name='TraceOptions' label='Trace' > |
40 | 40 | <menuitem action='toggle' id='dstrace' label='DS Trace' /> |
41 | - <!-- menuitem action='toggle' id='screentrace' label='Screen Trace' / --> | |
41 | + <menuitem action='toggle' id='screentrace' label='Screen Trace' /> | |
42 | 42 | <menuitem action='toggle' id='eventtrace' label='Event Trace' /> |
43 | 43 | </menu> |
44 | 44 | </menu> | ... | ... |