Commit ab92de7881cd12954c88d348cf58a493ee0fe3a1
1 parent
d714f42e
Exists in
master
Mais ajustes para multi-sessao, retirando warnings durante a compilação da lib e…
…m modo stand-alone, corrigindo compilação em linux
Showing
10 changed files
with
219 additions
and
105 deletions
Show diff stats
src/lib/Makefile.in
... | ... | @@ -123,9 +123,9 @@ version.c: ./mkversion.sh |
123 | 123 | @chmod +x ./mkversion.sh |
124 | 124 | @./mkversion.sh |
125 | 125 | |
126 | -fallbacks.c: $(BINDIR)/mkfb.exe X3270.xad | |
126 | +fallbacks.c: $(BINDIR)/mkfb@EXEEXT@ X3270.xad | |
127 | 127 | @mkdir -p $(TMPDIR) |
128 | - @$(BINDIR)/mkfb.exe -c X3270.xad falbacks.c | |
128 | + @$(BINDIR)/mkfb@EXEEXT@ -c X3270.xad falbacks.c | |
129 | 129 | |
130 | 130 | $(OBJDIR)/fallbacks@OBJEXT@: fallbacks.c |
131 | 131 | @echo $@ ... | ... | ... |
src/lib/ansi.c
... | ... | @@ -714,7 +714,7 @@ ansi_erase_in_display(int nn, int ig2 unused) |
714 | 714 | ctlr_aclear(0, h3270.cursor_addr + 1, 1); |
715 | 715 | break; |
716 | 716 | case 2: /* all (without moving cursor) */ |
717 | - if (cursor_addr == 0 && !h3270.is_altbuffer) | |
717 | + if (h3270.cursor_addr == 0 && !h3270.is_altbuffer) | |
718 | 718 | scroll_save(h3270.rows, True); |
719 | 719 | ctlr_aclear(0, h3270.rows * h3270.cols, 1); |
720 | 720 | break; | ... | ... |
src/lib/charset.c
... | ... | @@ -211,13 +211,18 @@ charset_init(char *csname) |
211 | 211 | charset_defaults(); |
212 | 212 | set_cgcsgids(CN); |
213 | 213 | set_charset_name(CN); |
214 | -#if defined(_WIN32) || defined(LIB3270)/*[*/ | |
215 | 214 | set_display_charset("iso8859-1"); |
216 | -#elif defined(X3270_DISPLAY) || (defined(C3270) && !defined(_WIN32)) /*[*/ | |
215 | + | |
216 | +/* | |
217 | +#if defined(_WIN32) || defined(LIB3270) | |
218 | + set_display_charset("iso8859-1"); | |
219 | +#elif defined(X3270_DISPLAY) || (defined(C3270) && !defined(_WIN32)) | |
217 | 220 | (void) screen_new_display_charsets(default_display_charset,"us"); |
218 | -#else /*][*/ | |
221 | +#else | |
219 | 222 | utf8_set_display_charsets(default_display_charset, "us"); |
220 | -#endif /*]*/ | |
223 | +#endif | |
224 | +*/ | |
225 | + | |
221 | 226 | return CS_OKAY; |
222 | 227 | } |
223 | 228 | ... | ... |
src/lib/ctlr.h
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | */ |
19 | 19 | |
20 | 20 | LIB3270_INTERNAL int buffer_addr; /**< buffer address */ |
21 | -LIB3270_INTERNAL int cursor_addr; /**< cursor address */ | |
21 | +// LIB3270_INTERNAL int cursor_addr; /**< cursor address */ | |
22 | 22 | LIB3270_INTERNAL struct ea *ea_buf; /**< 3270 device buffer */ |
23 | 23 | //LIB3270_INTERNAL Boolean formatted; /**< contains at least one field? */ |
24 | 24 | //LIB3270_INTERNAL Boolean is_altbuffer; /**< in alternate-buffer mode? */ | ... | ... |
src/lib/host.c
... | ... | @@ -579,8 +579,8 @@ static int do_connect(H3270 *hSession, const char *n) |
579 | 579 | Replace(hSession->current_host, CN); |
580 | 580 | |
581 | 581 | if (localprocess_cmd != CN) { |
582 | - if (full_current_host[strlen(OptLocalProcess)] != '\0') | |
583 | - hSession->current_host = NewString(full_current_host + strlen(OptLocalProcess) + 1); | |
582 | + if (hSession->full_current_host[strlen(OptLocalProcess)] != '\0') | |
583 | + hSession->current_host = NewString(hSession->full_current_host + strlen(OptLocalProcess) + 1); | |
584 | 584 | else |
585 | 585 | hSession->current_host = NewString("default shell"); |
586 | 586 | } else { | ... | ... |
src/lib/kybd.c
... | ... | @@ -1771,13 +1771,13 @@ LIB3270_ACTION( delete ) |
1771 | 1771 | if (!do_delete()) |
1772 | 1772 | return 0; |
1773 | 1773 | if (reverse) { |
1774 | - int baddr = cursor_addr; | |
1774 | + int baddr = hSession->cursor_addr; | |
1775 | 1775 | |
1776 | 1776 | DEC_BA(baddr); |
1777 | 1777 | if (!ea_buf[baddr].fa) |
1778 | 1778 | cursor_move(baddr); |
1779 | 1779 | } |
1780 | - screen_disp(&h3270); | |
1780 | + screen_disp(hSession); | |
1781 | 1781 | return 0; |
1782 | 1782 | } |
1783 | 1783 | |
... | ... | @@ -1848,9 +1848,9 @@ do_erase(void) |
1848 | 1848 | * This ensures that if this is the end of a DBCS subfield, we will |
1849 | 1849 | * land on the SI, instead of on the character following. |
1850 | 1850 | */ |
1851 | - d = ctlr_dbcs_state(cursor_addr); | |
1851 | + d = ctlr_dbcs_state(h3270.cursor_addr); | |
1852 | 1852 | if (IS_RIGHT(d)) { |
1853 | - baddr = cursor_addr; | |
1853 | + baddr = h3270.cursor_addr; | |
1854 | 1854 | DEC_BA(baddr); |
1855 | 1855 | cursor_move(baddr); |
1856 | 1856 | } |
... | ... | @@ -2596,11 +2596,11 @@ LIB3270_ACTION( eraseeol ) |
2596 | 2596 | d = ctlr_lookleft_state(cursor_addr, &why); |
2597 | 2597 | if (IS_DBCS(d) && why == DBCS_SUBFIELD) { |
2598 | 2598 | if (d == DBCS_RIGHT) { |
2599 | - baddr = cursor_addr; | |
2599 | + baddr = h3270.cursor_addr; | |
2600 | 2600 | DEC_BA(baddr); |
2601 | 2601 | ea_buf[baddr].cc = EBC_si; |
2602 | 2602 | } else |
2603 | - ea_buf[cursor_addr].cc = EBC_si; | |
2603 | + ea_buf[h3270.cursor_addr].cc = EBC_si; | |
2604 | 2604 | } |
2605 | 2605 | (void) ctlr_dbcs_postprocess(); |
2606 | 2606 | screen_disp(&h3270); |
... | ... | @@ -2628,18 +2628,18 @@ LIB3270_ACTION( eraseeof ) |
2628 | 2628 | if (IN_ANSI) |
2629 | 2629 | return 0; |
2630 | 2630 | #endif /*]*/ |
2631 | - baddr = h3270.cursor_addr; | |
2632 | - fa = get_field_attribute(&h3270,baddr); | |
2631 | + baddr = hSession->cursor_addr; | |
2632 | + fa = get_field_attribute(hSession,baddr); | |
2633 | 2633 | if (FA_IS_PROTECTED(fa) || ea_buf[baddr].fa) { |
2634 | 2634 | operator_error(KL_OERR_PROTECTED); |
2635 | 2635 | return -1; |
2636 | 2636 | } |
2637 | - if (h3270.formatted) { /* erase to next field attribute */ | |
2637 | + if (hSession->formatted) { /* erase to next field attribute */ | |
2638 | 2638 | do { |
2639 | 2639 | ctlr_add(baddr, EBC_null, 0); |
2640 | 2640 | INC_BA(baddr); |
2641 | 2641 | } while (!ea_buf[baddr].fa); |
2642 | - mdt_set(h3270.cursor_addr); | |
2642 | + mdt_set(hSession->cursor_addr); | |
2643 | 2643 | } else { /* erase to end of screen */ |
2644 | 2644 | do { |
2645 | 2645 | ctlr_add(baddr, EBC_null, 0); |
... | ... | @@ -2651,14 +2651,14 @@ LIB3270_ACTION( eraseeof ) |
2651 | 2651 | d = ctlr_lookleft_state(cursor_addr, &why); |
2652 | 2652 | if (IS_DBCS(d) && why == DBCS_SUBFIELD) { |
2653 | 2653 | if (d == DBCS_RIGHT) { |
2654 | - baddr = cursor_addr; | |
2654 | + baddr = hSession->cursor_addr; | |
2655 | 2655 | DEC_BA(baddr); |
2656 | 2656 | ea_buf[baddr].cc = EBC_si; |
2657 | 2657 | } else |
2658 | - ea_buf[cursor_addr].cc = EBC_si; | |
2658 | + ea_buf[hSession->cursor_addr].cc = EBC_si; | |
2659 | 2659 | } |
2660 | 2660 | (void) ctlr_dbcs_postprocess(); |
2661 | - screen_disp(&h3270); | |
2661 | + screen_disp(hSession); | |
2662 | 2662 | return 0; |
2663 | 2663 | } |
2664 | 2664 | |
... | ... | @@ -2677,7 +2677,7 @@ LIB3270_ACTION( eraseinput ) |
2677 | 2677 | if (IN_ANSI) |
2678 | 2678 | return 0; |
2679 | 2679 | #endif /*]*/ |
2680 | - if (h3270.formatted) { | |
2680 | + if (hSession->formatted) { | |
2681 | 2681 | /* find first field attribute */ |
2682 | 2682 | baddr = 0; |
2683 | 2683 | do { |
... | ... | @@ -2710,10 +2710,10 @@ LIB3270_ACTION( eraseinput ) |
2710 | 2710 | if (!f) |
2711 | 2711 | cursor_move(0); |
2712 | 2712 | } else { |
2713 | - ctlr_clear(&h3270,True); | |
2713 | + ctlr_clear(hSession,True); | |
2714 | 2714 | cursor_move(0); |
2715 | 2715 | } |
2716 | - screen_disp(&h3270); | |
2716 | + screen_disp(hSession); | |
2717 | 2717 | return 0; |
2718 | 2718 | } |
2719 | 2719 | |
... | ... | @@ -2743,11 +2743,11 @@ LIB3270_ACTION( deleteword ) |
2743 | 2743 | return 0; |
2744 | 2744 | } |
2745 | 2745 | #endif /*]*/ |
2746 | - if (!h3270.formatted) | |
2746 | + if (!hSession->formatted) | |
2747 | 2747 | return 0; |
2748 | 2748 | |
2749 | - baddr = h3270.cursor_addr; | |
2750 | - fa = get_field_attribute(&h3270,baddr); | |
2749 | + baddr = hSession->cursor_addr; | |
2750 | + fa = get_field_attribute(hSession,baddr); | |
2751 | 2751 | |
2752 | 2752 | /* Make sure we're on a modifiable field. */ |
2753 | 2753 | if (FA_IS_PROTECTED(fa) || ea_buf[baddr].fa) { |
... | ... | @@ -2757,7 +2757,7 @@ LIB3270_ACTION( deleteword ) |
2757 | 2757 | |
2758 | 2758 | /* Backspace over any spaces to the left of the cursor. */ |
2759 | 2759 | for (;;) { |
2760 | - baddr = h3270.cursor_addr; | |
2760 | + baddr = hSession->cursor_addr; | |
2761 | 2761 | DEC_BA(baddr); |
2762 | 2762 | if (ea_buf[baddr].fa) |
2763 | 2763 | return 0; |
... | ... | @@ -2770,7 +2770,7 @@ LIB3270_ACTION( deleteword ) |
2770 | 2770 | |
2771 | 2771 | /* Backspace until the character to the left of the cursor is blank. */ |
2772 | 2772 | for (;;) { |
2773 | - baddr = h3270.cursor_addr; | |
2773 | + baddr = hSession->cursor_addr; | |
2774 | 2774 | DEC_BA(baddr); |
2775 | 2775 | if (ea_buf[baddr].fa) |
2776 | 2776 | return 0; |
... | ... | @@ -2780,7 +2780,7 @@ LIB3270_ACTION( deleteword ) |
2780 | 2780 | else |
2781 | 2781 | do_erase(); |
2782 | 2782 | } |
2783 | - screen_disp(&h3270); | |
2783 | + screen_disp(hSession); | |
2784 | 2784 | return 0; |
2785 | 2785 | } |
2786 | 2786 | |
... | ... | @@ -2810,11 +2810,11 @@ LIB3270_ACTION( deletefield ) |
2810 | 2810 | return 0; |
2811 | 2811 | } |
2812 | 2812 | #endif /*]*/ |
2813 | - if (!h3270.formatted) | |
2813 | + if (!hSession->formatted) | |
2814 | 2814 | return 0; |
2815 | 2815 | |
2816 | - baddr = h3270.cursor_addr; | |
2817 | - fa = get_field_attribute(&h3270,baddr); | |
2816 | + baddr = hSession->cursor_addr; | |
2817 | + fa = get_field_attribute(hSession,baddr); | |
2818 | 2818 | if (FA_IS_PROTECTED(fa) || ea_buf[baddr].fa) { |
2819 | 2819 | operator_error(KL_OERR_PROTECTED); |
2820 | 2820 | return -1; |
... | ... | @@ -2822,13 +2822,13 @@ LIB3270_ACTION( deletefield ) |
2822 | 2822 | while (!ea_buf[baddr].fa) |
2823 | 2823 | DEC_BA(baddr); |
2824 | 2824 | INC_BA(baddr); |
2825 | - mdt_set(h3270.cursor_addr); | |
2825 | + mdt_set(hSession->cursor_addr); | |
2826 | 2826 | cursor_move(baddr); |
2827 | 2827 | while (!ea_buf[baddr].fa) { |
2828 | 2828 | ctlr_add(baddr, EBC_null, 0); |
2829 | 2829 | INC_BA(baddr); |
2830 | 2830 | } |
2831 | - screen_disp(&h3270); | |
2831 | + screen_disp(hSession); | |
2832 | 2832 | return 0; |
2833 | 2833 | } |
2834 | 2834 | |
... | ... | @@ -2914,10 +2914,10 @@ LIB3270_ACTION( fieldend ) |
2914 | 2914 | if (IN_ANSI) |
2915 | 2915 | return 0; |
2916 | 2916 | #endif /*]*/ |
2917 | - if (!h3270.formatted) | |
2917 | + if (!hSession->formatted) | |
2918 | 2918 | return 0; |
2919 | - baddr = h3270.cursor_addr; | |
2920 | - faddr = find_field_attribute(&h3270,baddr); | |
2919 | + baddr = hSession->cursor_addr; | |
2920 | + faddr = find_field_attribute(hSession,baddr); | |
2921 | 2921 | fa = ea_buf[faddr].fa; |
2922 | 2922 | if (faddr == baddr || FA_IS_PROTECTED(fa)) |
2923 | 2923 | return 0; |
... | ... | @@ -3375,12 +3375,12 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3375 | 3375 | if (pasting && IN_3270) { |
3376 | 3376 | |
3377 | 3377 | /* Check for cursor wrap to top of screen. */ |
3378 | - if (h3270.cursor_addr < orig_addr) | |
3378 | + if (session->cursor_addr < orig_addr) | |
3379 | 3379 | return len-1; /* wrapped */ |
3380 | 3380 | |
3381 | 3381 | /* Jump cursor over left margin. */ |
3382 | 3382 | if (toggled(MARGINED_PASTE) && |
3383 | - BA_TO_COL(h3270.cursor_addr) < orig_col) { | |
3383 | + BA_TO_COL(session->cursor_addr) < orig_col) { | |
3384 | 3384 | if (!remargin(orig_col)) |
3385 | 3385 | return len-1; |
3386 | 3386 | skipped = True; |
... | ... | @@ -3393,7 +3393,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3393 | 3393 | case BASE: |
3394 | 3394 | switch (c) { |
3395 | 3395 | case '\b': |
3396 | - lib3270_cursor_left(&h3270); | |
3396 | + lib3270_cursor_left(session); | |
3397 | 3397 | skipped = False; |
3398 | 3398 | break; |
3399 | 3399 | case '\f': |
... | ... | @@ -3401,7 +3401,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3401 | 3401 | key_ACharacter((unsigned char) ' ', |
3402 | 3402 | KT_STD, ia, &skipped); |
3403 | 3403 | } else { |
3404 | - lib3270_clear(&h3270); | |
3404 | + lib3270_clear(session); | |
3405 | 3405 | skipped = False; |
3406 | 3406 | if (IN_3270) |
3407 | 3407 | return len-1; |
... | ... | @@ -3410,11 +3410,11 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3410 | 3410 | case '\n': |
3411 | 3411 | if (pasting) { |
3412 | 3412 | if (!skipped) |
3413 | - lib3270_cursor_newline(&h3270); | |
3413 | + lib3270_cursor_newline(session); | |
3414 | 3414 | // action_internal(Newline_action,ia, CN, CN); |
3415 | 3415 | skipped = False; |
3416 | 3416 | } else { |
3417 | - lib3270_enter(&h3270); | |
3417 | + lib3270_enter(session); | |
3418 | 3418 | skipped = False; |
3419 | 3419 | if (IN_3270) |
3420 | 3420 | return len-1; |
... | ... | @@ -3423,7 +3423,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3423 | 3423 | case '\r': /* ignored */ |
3424 | 3424 | break; |
3425 | 3425 | case '\t': |
3426 | - lib3270_tab(&h3270); | |
3426 | + lib3270_tab(session); | |
3427 | 3427 | skipped = False; |
3428 | 3428 | break; |
3429 | 3429 | case '\\': /* backslashes are NOT special when |
... | ... | @@ -3489,13 +3489,13 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3489 | 3489 | state = BASE; |
3490 | 3490 | break; |
3491 | 3491 | case 'b': |
3492 | - lib3270_cursor_left(&h3270); | |
3492 | + lib3270_cursor_left(session); | |
3493 | 3493 | // action_internal(Left_action, ia, CN, CN); |
3494 | 3494 | skipped = False; |
3495 | 3495 | state = BASE; |
3496 | 3496 | break; |
3497 | 3497 | case 'f': |
3498 | - lib3270_clear(&h3270); | |
3498 | + lib3270_clear(session); | |
3499 | 3499 | skipped = False; |
3500 | 3500 | state = BASE; |
3501 | 3501 | if (IN_3270) |
... | ... | @@ -3503,7 +3503,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3503 | 3503 | else |
3504 | 3504 | break; |
3505 | 3505 | case 'n': |
3506 | - lib3270_enter(&h3270); | |
3506 | + lib3270_enter(session); | |
3507 | 3507 | skipped = False; |
3508 | 3508 | state = BASE; |
3509 | 3509 | if (IN_3270) |
... | ... | @@ -3515,25 +3515,24 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3515 | 3515 | break; |
3516 | 3516 | |
3517 | 3517 | case 'r': |
3518 | - lib3270_cursor_newline(&h3270); | |
3518 | + lib3270_cursor_newline(session); | |
3519 | 3519 | // action_internal(Newline_action, ia, CN, CN); |
3520 | 3520 | skipped = False; |
3521 | 3521 | state = BASE; |
3522 | 3522 | break; |
3523 | 3523 | |
3524 | 3524 | case 't': |
3525 | - lib3270_tab(&h3270); | |
3525 | + lib3270_tab(session); | |
3526 | 3526 | skipped = False; |
3527 | 3527 | state = BASE; |
3528 | 3528 | break; |
3529 | 3529 | case 'T': |
3530 | - lib3270_tab(&h3270); | |
3530 | + lib3270_tab(session); | |
3531 | 3531 | skipped = False; |
3532 | 3532 | state = BASE; |
3533 | 3533 | break; |
3534 | 3534 | case 'v': |
3535 | - popup_an_error("%s: Vertical tab not supported", | |
3536 | - action_name(String_action)); | |
3535 | + popup_an_error("%s: Vertical tab not supported",action_name(String_action)); | |
3537 | 3536 | // cancel_if_idle_command(); |
3538 | 3537 | state = BASE; |
3539 | 3538 | break; |
... | ... | @@ -3541,8 +3540,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3541 | 3540 | state = BACKX; |
3542 | 3541 | break; |
3543 | 3542 | case '\\': |
3544 | - key_ACharacter((unsigned char) c, KT_STD, ia, | |
3545 | - &skipped); | |
3543 | + key_ACharacter((unsigned char) c, KT_STD, ia,&skipped); | |
3546 | 3544 | state = BASE; |
3547 | 3545 | break; |
3548 | 3546 | case '0': |
... | ... | @@ -3679,7 +3677,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3679 | 3677 | switch (state) { |
3680 | 3678 | case BASE: |
3681 | 3679 | if (toggled(MARGINED_PASTE) && |
3682 | - BA_TO_COL(h3270.cursor_addr) < orig_col) { | |
3680 | + BA_TO_COL(session->cursor_addr) < orig_col) { | |
3683 | 3681 | (void) remargin(orig_col); |
3684 | 3682 | } |
3685 | 3683 | break; |
... | ... | @@ -3688,7 +3686,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3688 | 3686 | key_ACharacter((unsigned char) literal, KT_STD, ia, &skipped); |
3689 | 3687 | state = BASE; |
3690 | 3688 | if (toggled(MARGINED_PASTE) && |
3691 | - BA_TO_COL(h3270.cursor_addr) < orig_col) { | |
3689 | + BA_TO_COL(session->cursor_addr) < orig_col) { | |
3692 | 3690 | (void) remargin(orig_col); |
3693 | 3691 | } |
3694 | 3692 | break; |
... | ... | @@ -3711,7 +3709,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p |
3711 | 3709 | break; |
3712 | 3710 | } |
3713 | 3711 | |
3714 | - screen_disp(&h3270); | |
3712 | + screen_disp(session); | |
3715 | 3713 | return len; |
3716 | 3714 | } |
3717 | 3715 | ... | ... |
src/lib/mkfb.c
1 | -/* | |
1 | +/* | |
2 | 2 | * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 |
3 | 3 | * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a |
4 | 4 | * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. |
5 | - * | |
5 | + * | |
6 | 6 | * Copyright (C) <2008> <Banco do Brasil S.A.> |
7 | - * | |
7 | + * | |
8 | 8 | * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob |
9 | 9 | * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela |
10 | 10 | * Free Software Foundation. |
11 | - * | |
11 | + * | |
12 | 12 | * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER |
13 | 13 | * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO |
14 | 14 | * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para |
15 | 15 | * obter mais detalhes. |
16 | - * | |
16 | + * | |
17 | 17 | * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este |
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 | 21 | * Este programa está nomeado como mkfb.c e possui 577 linhas de código. |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | 27 | * licinio@bb.com.br (Licínio Luis Branco) |
... | ... | @@ -538,7 +538,7 @@ main(int argc, char *argv[]) |
538 | 538 | fprintf(o, "\t(String)NULL\n};\n\n"); |
539 | 539 | |
540 | 540 | /* Emit some test code. */ |
541 | - fprintf(o, "%s", "#if defined(DEBUG) /*[*/\n\ | |
541 | + fprintf(o, "%s", "#if defined(DUMP) /*[*/\n\ | |
542 | 542 | #include <stdio.h>\n\ |
543 | 543 | int\n\ |
544 | 544 | main(int argc, char *argv[])\n\ | ... | ... |
src/lib/util.c
... | ... | @@ -36,9 +36,23 @@ |
36 | 36 | */ |
37 | 37 | |
38 | 38 | #include "globals.h" |
39 | -#if !defined(_WIN32) /*[*/ | |
40 | -#include <pwd.h> | |
41 | -#endif /*]*/ | |
39 | + | |
40 | +#if defined(_WIN32) | |
41 | + | |
42 | + #include <windows.h> | |
43 | + #include "winversc.h" | |
44 | + | |
45 | + #include <winsock2.h> | |
46 | + #include <ws2tcpip.h> | |
47 | + #include <stdio.h> | |
48 | + #include <errno.h> | |
49 | + | |
50 | + #include "w3miscc.h" | |
51 | + | |
52 | +#else | |
53 | + #include <pwd.h> | |
54 | +#endif // _WIN32 | |
55 | + | |
42 | 56 | #include <stdarg.h> |
43 | 57 | #include "resources.h" |
44 | 58 | |
... | ... | @@ -47,6 +61,99 @@ |
47 | 61 | |
48 | 62 | #define my_isspace(c) isspace((unsigned char)c) |
49 | 63 | |
64 | + | |
65 | +#if defined(_WIN32) | |
66 | + | |
67 | +int is_nt = 1; | |
68 | +int has_ipv6 = 1; | |
69 | + | |
70 | +int get_version_info(void) | |
71 | +{ | |
72 | + OSVERSIONINFO info; | |
73 | + | |
74 | + // Figure out what version of Windows this is. | |
75 | + memset(&info, '\0', sizeof(info)); | |
76 | + info.dwOSVersionInfoSize = sizeof(info); | |
77 | + if(GetVersionEx(&info) == 0) | |
78 | + { | |
79 | + WriteLog("lib3270","%s","Can't get Windows version"); | |
80 | + return -1; | |
81 | + } | |
82 | + | |
83 | + // Yes, people still run Win98. | |
84 | + if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) | |
85 | + is_nt = 0; | |
86 | + | |
87 | + // Win2K and earlier is IPv4-only. WinXP and later can have IPv6. | |
88 | + if (!is_nt || info.dwMajorVersion < 5 || (info.dwMajorVersion == 5 && info.dwMinorVersion < 1)) | |
89 | + { | |
90 | + has_ipv6 = 0; | |
91 | + } | |
92 | + | |
93 | + return 0; | |
94 | +} | |
95 | + | |
96 | +// Convert a network address to a string. | |
97 | +const char * inet_ntop(int af, const void *src, char *dst, socklen_t cnt) | |
98 | +{ | |
99 | + union { | |
100 | + struct sockaddr sa; | |
101 | + struct sockaddr_in sin; | |
102 | + struct sockaddr_in6 sin6; | |
103 | + } sa; | |
104 | + DWORD ssz; | |
105 | + DWORD sz = cnt; | |
106 | + | |
107 | + memset(&sa, '\0', sizeof(sa)); | |
108 | + | |
109 | + switch (af) { | |
110 | + case AF_INET: | |
111 | + sa.sin = *(struct sockaddr_in *)src; // struct copy | |
112 | + ssz = sizeof(struct sockaddr_in); | |
113 | + break; | |
114 | + case AF_INET6: | |
115 | + sa.sin6 = *(struct sockaddr_in6 *)src; // struct copy | |
116 | + ssz = sizeof(struct sockaddr_in6); | |
117 | + break; | |
118 | + default: | |
119 | + if (cnt > 0) | |
120 | + dst[0] = '\0'; | |
121 | + return NULL; | |
122 | + } | |
123 | + | |
124 | + sa.sa.sa_family = af; | |
125 | + | |
126 | + if (WSAAddressToString(&sa.sa, ssz, NULL, dst, &sz) != 0) { | |
127 | + if (cnt > 0) | |
128 | + dst[0] = '\0'; | |
129 | + return NULL; | |
130 | + } | |
131 | + | |
132 | + return dst; | |
133 | +} | |
134 | + | |
135 | +// Decode a Win32 error number. | |
136 | +const char * win32_strerror(int e) | |
137 | +{ | |
138 | + static char buffer[4096]; | |
139 | + | |
140 | + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, | |
141 | + NULL, | |
142 | + e, | |
143 | + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | |
144 | + buffer, | |
145 | + sizeof(buffer), | |
146 | + NULL) == 0) { | |
147 | + | |
148 | + sprintf(buffer, "Windows error %d", e); | |
149 | + } | |
150 | + | |
151 | + return buffer; | |
152 | +} | |
153 | + | |
154 | + | |
155 | +#endif // _WIN32 | |
156 | + | |
50 | 157 | /* |
51 | 158 | * Cheesy internal version of sprintf that allocates its own memory. |
52 | 159 | */ | ... | ... |
src/lib/w3misc.c
1 | -/* | |
1 | +/* | |
2 | 2 | * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 |
3 | 3 | * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a |
4 | 4 | * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. |
5 | - * | |
5 | + * | |
6 | 6 | * Copyright (C) <2008> <Banco do Brasil S.A.> |
7 | - * | |
7 | + * | |
8 | 8 | * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob |
9 | 9 | * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela |
10 | 10 | * Free Software Foundation. |
11 | - * | |
11 | + * | |
12 | 12 | * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER |
13 | 13 | * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO |
14 | 14 | * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para |
15 | 15 | * obter mais detalhes. |
16 | - * | |
16 | + * | |
17 | 17 | * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este |
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 | 21 | * Este programa está nomeado como w3misc.c e possui 110 linhas de código. |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | 27 | * licinio@bb.com.br (Licínio Luis Branco) |
... | ... | @@ -36,11 +36,12 @@ |
36 | 36 | * Miscellaneous Win32 functions. |
37 | 37 | */ |
38 | 38 | |
39 | +/* | |
39 | 40 | #include "globals.h" |
40 | 41 | |
41 | -#if !defined(_WIN32) /*[*/ | |
42 | +#if !defined(_WIN32) | |
42 | 43 | #error This module is only for Win32. |
43 | -#endif /*]*/ | |
44 | +#endif | |
44 | 45 | |
45 | 46 | #include <winsock2.h> |
46 | 47 | #include <ws2tcpip.h> |
... | ... | @@ -49,9 +50,8 @@ |
49 | 50 | |
50 | 51 | #include "w3miscc.h" |
51 | 52 | |
52 | -/* Convert a network address to a string. */ | |
53 | -const char * | |
54 | -inet_ntop(int af, const void *src, char *dst, socklen_t cnt) | |
53 | +// Convert a network address to a string. | |
54 | +const char * inet_ntop(int af, const void *src, char *dst, socklen_t cnt) | |
55 | 55 | { |
56 | 56 | union { |
57 | 57 | struct sockaddr sa; |
... | ... | @@ -65,11 +65,11 @@ inet_ntop(int af, const void *src, char *dst, socklen_t cnt) |
65 | 65 | |
66 | 66 | switch (af) { |
67 | 67 | case AF_INET: |
68 | - sa.sin = *(struct sockaddr_in *)src; /* struct copy */ | |
68 | + sa.sin = *(struct sockaddr_in *)src; // struct copy | |
69 | 69 | ssz = sizeof(struct sockaddr_in); |
70 | 70 | break; |
71 | 71 | case AF_INET6: |
72 | - sa.sin6 = *(struct sockaddr_in6 *)src; /* struct copy */ | |
72 | + sa.sin6 = *(struct sockaddr_in6 *)src; // struct copy | |
73 | 73 | ssz = sizeof(struct sockaddr_in6); |
74 | 74 | break; |
75 | 75 | default: |
... | ... | @@ -89,9 +89,8 @@ inet_ntop(int af, const void *src, char *dst, socklen_t cnt) |
89 | 89 | return dst; |
90 | 90 | } |
91 | 91 | |
92 | -/* Decode a Win32 error number. */ | |
93 | -const char * | |
94 | -win32_strerror(int e) | |
92 | +// Decode a Win32 error number. | |
93 | +const char * win32_strerror(int e) | |
95 | 94 | { |
96 | 95 | static char buffer[4096]; |
97 | 96 | |
... | ... | @@ -102,9 +101,11 @@ win32_strerror(int e) |
102 | 101 | buffer, |
103 | 102 | sizeof(buffer), |
104 | 103 | NULL) == 0) { |
105 | - | |
104 | + | |
106 | 105 | sprintf(buffer, "Windows error %d", e); |
107 | 106 | } |
108 | 107 | |
109 | 108 | return buffer; |
110 | 109 | } |
110 | + | |
111 | +*/ | ... | ... |
src/lib/winvers.c
1 | -/* | |
1 | +/* | |
2 | 2 | * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 |
3 | 3 | * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a |
4 | 4 | * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. |
5 | - * | |
5 | + * | |
6 | 6 | * Copyright (C) <2008> <Banco do Brasil S.A.> |
7 | - * | |
7 | + * | |
8 | 8 | * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob |
9 | 9 | * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela |
10 | 10 | * Free Software Foundation. |
11 | - * | |
11 | + * | |
12 | 12 | * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER |
13 | 13 | * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO |
14 | 14 | * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para |
15 | 15 | * obter mais detalhes. |
16 | - * | |
16 | + * | |
17 | 17 | * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este |
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 | 21 | * Este programa está nomeado como winvers.c e possui 73 linhas de código. |
22 | - * | |
23 | - * Contatos: | |
24 | - * | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | 27 | * licinio@bb.com.br (Licínio Luis Branco) |
... | ... | @@ -37,6 +37,7 @@ |
37 | 37 | * OS version query |
38 | 38 | */ |
39 | 39 | |
40 | +/* | |
40 | 41 | #include <windows.h> |
41 | 42 | #include <stdio.h> |
42 | 43 | |
... | ... | @@ -51,7 +52,7 @@ get_version_info(void) |
51 | 52 | { |
52 | 53 | OSVERSIONINFO info; |
53 | 54 | |
54 | - /* Figure out what version of Windows this is. */ | |
55 | + // Figure out what version of Windows this is. | |
55 | 56 | memset(&info, '\0', sizeof(info)); |
56 | 57 | info.dwOSVersionInfoSize = sizeof(info); |
57 | 58 | if (GetVersionEx(&info) == 0) { |
... | ... | @@ -59,11 +60,11 @@ get_version_info(void) |
59 | 60 | return -1; |
60 | 61 | } |
61 | 62 | |
62 | - /* Yes, people still run Win98. */ | |
63 | + // Yes, people still run Win98. | |
63 | 64 | if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) |
64 | 65 | is_nt = 0; |
65 | 66 | |
66 | - /* Win2K and earlier is IPv4-only. WinXP and later can have IPv6. */ | |
67 | + // Win2K and earlier is IPv4-only. WinXP and later can have IPv6. | |
67 | 68 | if (!is_nt || |
68 | 69 | info.dwMajorVersion < 5 || |
69 | 70 | (info.dwMajorVersion == 5 && info.dwMinorVersion < 1)) { |
... | ... | @@ -72,3 +73,5 @@ get_version_info(void) |
72 | 73 | |
73 | 74 | return 0; |
74 | 75 | } |
76 | + | |
77 | +*/ | ... | ... |