Commit 76eb18493406faa5f4790fa2c3230e8f6615c7dd
1 parent
cb7afe0c
Exists in
master
and in
5 other branches
Movendo mais campos para a estrutura de sessão, acertando dependências no Makefile
Showing
5 changed files
with
48 additions
and
36 deletions
Show diff stats
src/include/lib3270/session.h
src/include/rules.mak.in
... | ... | @@ -38,7 +38,7 @@ LIB3270_CFLAGS ?= `pkg-config --cflags lib3270` |
38 | 38 | LIB3270_LIBS ?= `pkg-config --libs lib3270` |
39 | 39 | |
40 | 40 | DEBUG_CFLAGS=-DDEBUG=1 -g |
41 | -DEPENDS ?= *.h | |
41 | +DEPENDS ?= *.h ../include/*.h ../include/lib3270/*.h | |
42 | 42 | |
43 | 43 | #---[ Tools ]------------------------------------------------------------------ |
44 | 44 | ... | ... |
src/lib3270/Makefile.in
... | ... | @@ -37,7 +37,7 @@ LDFLAGS=@LDFLAGS@ |
37 | 37 | LIBS=@LIBS@ @LIBSSL_LIBS@ @INTL_LIBS@ @SOCKET_LIBS@ |
38 | 38 | |
39 | 39 | DEBUG_CFLAGS=-DDEBUG=1 -g |
40 | -DEPENDS ?= *.h ../include/*.h Makefile | |
40 | +DEPENDS ?= *.h ../include/*.h ../include/lib3270/*.h Makefile | |
41 | 41 | |
42 | 42 | #---[ Paths ]------------------------------------------------------------------ |
43 | 43 | ... | ... |
src/lib3270/session.c
... | ... | @@ -68,15 +68,17 @@ void lib3270_session_free(H3270 *h) |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Release memory |
71 | - lib3270_free(h->charset); | |
72 | - lib3270_free(h->paste_buffer); | |
73 | - h->charset = NULL; | |
74 | - h->paste_buffer = NULL; | |
71 | + #define release_pointer(x) lib3270_free(x); x = NULL; | |
72 | + | |
73 | + release_pointer(h->charset); | |
74 | + release_pointer(h->paste_buffer); | |
75 | + | |
76 | + release_pointer(h->ibuf); | |
77 | + h->ibuf_size = 0; | |
75 | 78 | |
76 | 79 | for(f=0;f<(sizeof(h->buffer)/sizeof(h->buffer[0]));f++) |
77 | 80 | { |
78 | - lib3270_free(h->buffer[f]); | |
79 | - h->buffer[f] = NULL; | |
81 | + release_pointer(h->buffer[f]); | |
80 | 82 | } |
81 | 83 | |
82 | 84 | } | ... | ... |
src/lib3270/telnet.c
... | ... | @@ -149,20 +149,23 @@ extern struct timeval ds_ts; |
149 | 149 | //#endif /*]*/ |
150 | 150 | |
151 | 151 | static unsigned char myopts[N_OPTS], hisopts[N_OPTS]; |
152 | - /* telnet option flags */ | |
153 | -static unsigned char *ibuf = (unsigned char *) NULL; | |
154 | - /* 3270 input buffer */ | |
152 | + | |
153 | +/* telnet option flags */ | |
154 | +// static unsigned char *ibuf = (unsigned char *) NULL; | |
155 | +// static int ibuf_size = 0; /* size of ibuf */ | |
156 | + | |
157 | +/* 3270 input buffer */ | |
155 | 158 | static unsigned char *ibptr; |
156 | -static int ibuf_size = 0; /* size of ibuf */ | |
157 | 159 | static unsigned char *obuf_base = (unsigned char *)NULL; |
158 | 160 | static int obuf_size = 0; |
159 | 161 | static unsigned char *netrbuf = (unsigned char *)NULL; |
160 | - /* network input buffer */ | |
162 | + | |
163 | +/* network input buffer */ | |
161 | 164 | static unsigned char *sbbuf = (unsigned char *)NULL; |
162 | - /* telnet sub-option buffer */ | |
165 | + | |
166 | +/* telnet sub-option buffer */ | |
163 | 167 | static unsigned char *sbptr; |
164 | 168 | static unsigned char telnet_state; |
165 | -// static int syncing; | |
166 | 169 | static char ttype_tmpval[13]; |
167 | 170 | |
168 | 171 | #if defined(X3270_TN3270E) /*[*/ |
... | ... | @@ -868,7 +871,7 @@ static void net_connected(H3270 *session) |
868 | 871 | need_tls_follows = False; |
869 | 872 | #endif /*]*/ |
870 | 873 | telnet_state = TNS_DATA; |
871 | - ibptr = ibuf; | |
874 | + ibptr = h3270.ibuf; | |
872 | 875 | |
873 | 876 | /* clear statistics and flags */ |
874 | 877 | (void) time(&ns_time); |
... | ... | @@ -1253,7 +1256,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
1253 | 1256 | } else |
1254 | 1257 | Warning(NULL, _( "EOR received when not in 3270 mode, ignored." )); |
1255 | 1258 | trace_dsn("RCVD EOR\n"); |
1256 | - ibptr = ibuf; | |
1259 | + ibptr = h3270.ibuf; | |
1257 | 1260 | telnet_state = TNS_DATA; |
1258 | 1261 | break; |
1259 | 1262 | case WILL: |
... | ... | @@ -1860,12 +1863,12 @@ process_bind(unsigned char *buf, int buflen) |
1860 | 1863 | static int |
1861 | 1864 | process_eor(void) |
1862 | 1865 | { |
1863 | - if (h3270.syncing || !(ibptr - ibuf)) | |
1866 | + if (h3270.syncing || !(ibptr - h3270.ibuf)) | |
1864 | 1867 | return(0); |
1865 | 1868 | |
1866 | 1869 | #if defined(X3270_TN3270E) /*[*/ |
1867 | 1870 | if (IN_E) { |
1868 | - tn3270e_header *h = (tn3270e_header *)ibuf; | |
1871 | + tn3270e_header *h = (tn3270e_header *) h3270.ibuf; | |
1869 | 1872 | unsigned char *s; |
1870 | 1873 | enum pds rv; |
1871 | 1874 | |
... | ... | @@ -1883,8 +1886,8 @@ process_eor(void) |
1883 | 1886 | tn3270e_submode = E_3270; |
1884 | 1887 | check_in3270(&h3270); |
1885 | 1888 | response_required = h->response_flag; |
1886 | - rv = process_ds(ibuf + EH_SIZE, | |
1887 | - (ibptr - ibuf) - EH_SIZE); | |
1889 | + rv = process_ds(h3270.ibuf + EH_SIZE, | |
1890 | + (ibptr - h3270.ibuf) - EH_SIZE); | |
1888 | 1891 | if (rv < 0 && |
1889 | 1892 | response_required != TN3270E_RSF_NO_RESPONSE) |
1890 | 1893 | tn3270e_nak(rv); |
... | ... | @@ -1896,7 +1899,7 @@ process_eor(void) |
1896 | 1899 | case TN3270E_DT_BIND_IMAGE: |
1897 | 1900 | if (!(e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) |
1898 | 1901 | return 0; |
1899 | - process_bind(ibuf + EH_SIZE, (ibptr - ibuf) - EH_SIZE); | |
1902 | + process_bind(h3270.ibuf + EH_SIZE, (ibptr - h3270.ibuf) - EH_SIZE); | |
1900 | 1903 | trace_dsn("< BIND PLU-name '%s'\n", plu_name); |
1901 | 1904 | tn3270e_bound = 1; |
1902 | 1905 | check_in3270(&h3270); |
... | ... | @@ -1913,7 +1916,7 @@ process_eor(void) |
1913 | 1916 | /* In tn3270e NVT mode */ |
1914 | 1917 | tn3270e_submode = E_NVT; |
1915 | 1918 | check_in3270(&h3270); |
1916 | - for (s = ibuf; s < ibptr; s++) { | |
1919 | + for (s = h3270.ibuf; s < ibptr; s++) { | |
1917 | 1920 | ansi_process(*s++); |
1918 | 1921 | } |
1919 | 1922 | return 0; |
... | ... | @@ -1922,8 +1925,8 @@ process_eor(void) |
1922 | 1925 | return 0; |
1923 | 1926 | tn3270e_submode = E_SSCP; |
1924 | 1927 | check_in3270(&h3270); |
1925 | - ctlr_write_sscp_lu(ibuf + EH_SIZE, | |
1926 | - (ibptr - ibuf) - EH_SIZE); | |
1928 | + ctlr_write_sscp_lu(h3270.ibuf + EH_SIZE, | |
1929 | + (ibptr - h3270.ibuf) - EH_SIZE); | |
1927 | 1930 | return 0; |
1928 | 1931 | default: |
1929 | 1932 | /* Should do something more extraordinary here. */ |
... | ... | @@ -1932,7 +1935,7 @@ process_eor(void) |
1932 | 1935 | } else |
1933 | 1936 | #endif /*]*/ |
1934 | 1937 | { |
1935 | - (void) process_ds(ibuf, ibptr - ibuf); | |
1938 | + (void) process_ds(h3270.ibuf, ibptr - h3270.ibuf); | |
1936 | 1939 | } |
1937 | 1940 | return 0; |
1938 | 1941 | } |
... | ... | @@ -2464,10 +2467,11 @@ check_in3270(H3270 *session) |
2464 | 2467 | #endif /*]*/ |
2465 | 2468 | |
2466 | 2469 | /* Allocate the initial 3270 input buffer. */ |
2467 | - if (new_cstate >= CONNECTED_INITIAL && !ibuf_size) { | |
2468 | - ibuf = (unsigned char *)lib3270_malloc(BUFSIZ); | |
2469 | - ibuf_size = BUFSIZ; | |
2470 | - ibptr = ibuf; | |
2470 | + if(new_cstate >= CONNECTED_INITIAL && !(h3270.ibuf_size && h3270.ibuf)) | |
2471 | + { | |
2472 | + h3270.ibuf = (unsigned char *) lib3270_malloc(BUFSIZ); | |
2473 | + h3270.ibuf_size = BUFSIZ; | |
2474 | + ibptr = h3270.ibuf; | |
2471 | 2475 | } |
2472 | 2476 | |
2473 | 2477 | #if defined(X3270_ANSI) /*[*/ |
... | ... | @@ -2498,10 +2502,11 @@ check_in3270(H3270 *session) |
2498 | 2502 | static void |
2499 | 2503 | store3270in(unsigned char c) |
2500 | 2504 | { |
2501 | - if (ibptr - ibuf >= ibuf_size) { | |
2502 | - ibuf_size += BUFSIZ; | |
2503 | - ibuf = (unsigned char *)Realloc((char *)ibuf, ibuf_size); | |
2504 | - ibptr = ibuf + ibuf_size - BUFSIZ; | |
2505 | + if (ibptr - h3270.ibuf >= h3270.ibuf_size) | |
2506 | + { | |
2507 | + h3270.ibuf_size += BUFSIZ; | |
2508 | + h3270.ibuf = (unsigned char *) lib3270_realloc((char *) h3270.ibuf, h3270.ibuf_size); | |
2509 | + ibptr = h3270.ibuf + h3270.ibuf_size - BUFSIZ; | |
2505 | 2510 | } |
2506 | 2511 | *ibptr++ = c; |
2507 | 2512 | } |
... | ... | @@ -2733,7 +2738,7 @@ static void |
2733 | 2738 | tn3270e_ack(void) |
2734 | 2739 | { |
2735 | 2740 | unsigned char rsp_buf[10]; |
2736 | - tn3270e_header *h_in = (tn3270e_header *)ibuf; | |
2741 | + tn3270e_header *h_in = (tn3270e_header *) h3270.ibuf; | |
2737 | 2742 | int rsp_len = 0; |
2738 | 2743 | |
2739 | 2744 | rsp_len = 0; |
... | ... | @@ -2760,7 +2765,7 @@ static void |
2760 | 2765 | tn3270e_nak(enum pds rv) |
2761 | 2766 | { |
2762 | 2767 | unsigned char rsp_buf[10]; |
2763 | - tn3270e_header *h_in = (tn3270e_header *)ibuf; | |
2768 | + tn3270e_header *h_in = (tn3270e_header *) h3270.ibuf; | |
2764 | 2769 | int rsp_len = 0; |
2765 | 2770 | char *neg = NULL; |
2766 | 2771 | ... | ... |