Commit 499a94cac2c5cf2e3698dca5538f880bfd318a8a

Authored by perry.werneck@gmail.com
1 parent 114af134

Ajustes para multi-sessão

ft.c
... ... @@ -379,7 +379,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state);
379 379 return errno = EINVAL;
380 380 }
381 381  
382   - trace_event("Sending FT request:\n%s\n",buffer);
  382 + lib3270_trace_event(hSession,"Sending FT request:\n%s\n",buffer);
383 383  
384 384 lib3270_emulate_input(ft->host, buffer, strlen(buffer), False);
385 385  
... ...
ft_cut.c
... ... @@ -18,7 +18,7 @@
18 18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19 19 * St, Fifth Floor, Boston, MA 02110-1301 USA
20 20 *
21   - * Este programa está nomeado como ft_cut.c e possui 591 linhas de código.
  21 + * Este programa está nomeado como ft_cut.c e possui - linhas de código.
22 22 *
23 23 * Contatos:
24 24 *
... ... @@ -26,12 +26,12 @@
26 26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27 27 * licinio@bb.com.br (Licínio Luis Branco)
28 28 * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda)
30 29 *
31 30 */
32 31  
33   -/*
34   - * ft_cut.c
  32 +/**
  33 + * @file ft_cut.c
  34 + *
35 35 * File transfer, data movement logic, CUT version
36 36 */
37 37  
... ... @@ -54,7 +54,7 @@
54 54 #include "trace_dsc.h"
55 55 #include "utilc.h"
56 56  
57   -static Boolean cut_xfer_in_progress = False;
  57 +// static Boolean cut_xfer_in_progress = 0;
58 58  
59 59 /* Data stream conversion tables. */
60 60  
... ... @@ -63,10 +63,10 @@ static Boolean cut_xfer_in_progress = False;
63 63 #define OTHER_2 2 /* "OTHER 2" quadrant (includes NULL) */
64 64 #define XLATE_NULL 0xc1 /* translation of NULL */
65 65  
66   -static char alphas[NE + 1] =
67   -" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%&_()<+,-./:>?";
  66 +static const char alphas[NE + 1] = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%&_()<+,-./:>?";
68 67  
69   -static struct {
  68 +static const struct
  69 +{
70 70 unsigned char selector;
71 71 unsigned char xlate[NE];
72 72 } conv[NQ] = {
... ... @@ -107,8 +107,7 @@ static struct {
107 107 0xbe,0xbf,0x9a,0x9b, 0x00 }
108 108 }
109 109 };
110   -static char table6[] =
111   - "abcdefghijklmnopqrstuvwxyz&-.,:+ABCDEFGHIJKLMNOPQRSTUVWXYZ012345";
  110 +static const char table6[] = "abcdefghijklmnopqrstuvwxyz&-.,:+ABCDEFGHIJKLMNOPQRSTUVWXYZ012345";
112 111  
113 112 static int quadrant = -1;
114 113 static unsigned long expanded_length;
... ... @@ -317,7 +316,7 @@ static void cut_control_code(H3270 *hSession)
317 316 {
318 317 case SC_HOST_ACK:
319 318 trace_ds(hSession,"HOST_ACK\n");
320   - cut_xfer_in_progress = True;
  319 + hSession->cut_xfer_in_progress = 1;
321 320 expanded_length = 0;
322 321 quadrant = -1;
323 322 xlate_buffered = 0;
... ... @@ -328,14 +327,14 @@ static void cut_control_code(H3270 *hSession)
328 327 case SC_XFER_COMPLETE:
329 328 trace_ds(hSession,"XFER_COMPLETE\n");
330 329 cut_ack(hSession);
331   - cut_xfer_in_progress = False;
  330 + hSession->cut_xfer_in_progress = 0;
332 331 ft_complete(NULL,N_( "Complete" ) );
333 332 break;
334 333  
335 334 case SC_ABORT_FILE:
336 335 case SC_ABORT_XMIT:
337 336 trace_ds(hSession,"ABORT\n");
338   - cut_xfer_in_progress = False;
  337 + hSession->cut_xfer_in_progress = 0;
339 338 cut_ack(hSession);
340 339  
341 340 if (lib3270_get_ft_state(hSession) == FT_ABORT_SENT && saved_errmsg != CN)
... ...
globals.h
... ... @@ -252,18 +252,6 @@ LIB3270_INTERNAL const char * build_rpq_revision;
252 252 /* Connection state */
253 253 // LIB3270_INTERNAL enum ft_state ft_state;
254 254  
255   -/*
256   -LIB3270_INTERNAL enum cstate cstate;
257   -#define PCONNECTED ((int)h3270.cstate >= (int)RESOLVING)
258   -#define HALF_CONNECTED (h3270.cstate == RESOLVING || h3270.cstate == PENDING)
259   -#define CONNECTED ((int)h3270.cstate >= (int)CONNECTED_INITIAL)
260   -#define IN_NEITHER (h3270.cstate == CONNECTED_INITIAL)
261   -#define IN_ANSI (h3270.cstate == CONNECTED_ANSI || h3270.cstate == CONNECTED_NVT)
262   -#define IN_3270 (h3270.cstate == CONNECTED_3270 || h3270.cstate == CONNECTED_TN3270E || h3270.cstate == CONNECTED_SSCP)
263   -#define IN_SSCP (h3270.cstate == CONNECTED_SSCP)
264   -#define IN_TN3270E (h3270.cstate == CONNECTED_TN3270E)
265   -#define IN_E (h3270.cstate >= CONNECTED_INITIAL_E)
266   -*/
267 255  
268 256 /* keyboard modifer bitmap */
269 257 #define ShiftKeyDown 0x01
... ...
kybd.c
... ... @@ -257,7 +257,7 @@ static int enq_chk(H3270 *hSession)
257 257 }
258 258 session->ta_tail = ta;
259 259  
260   - trace_event(" Key-aid queued (kybdlock 0x%x)\n", session->kybdlock);
  260 + lib3270_trace_event(session," Key-aid queued (kybdlock 0x%x)\n", session->kybdlock);
261 261 }
262 262  
263 263 /*
... ... @@ -300,7 +300,7 @@ static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char
300 300 }
301 301 hSession->ta_tail = ta;
302 302  
303   - trace_event(" action queued (kybdlock 0x%x)\n", hSession->kybdlock);
  303 + lib3270_trace_event(hSession," action queued (kybdlock 0x%x)\n", hSession->kybdlock);
304 304 }
305 305  
306 306 /*
... ... @@ -374,7 +374,7 @@ static void kybdlock_set(H3270 *hSession, unsigned int bits)
374 374 {
375 375 /*
376 376 #if defined(KYBDLOCK_TRACE)
377   - trace_event(" %s: kybdlock |= 0x%04x, 0x%04x -> 0x%04x\n",
  377 + lib3270_trace_event(hSession," %s: kybdlock |= 0x%04x, 0x%04x -> 0x%04x\n",
378 378 cause, bits, kybdlock, n);
379 379 #endif
380 380 */
... ... @@ -399,7 +399,7 @@ void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits)
399 399 if (n != hSession->kybdlock)
400 400 {
401 401 #if defined(KYBDLOCK_TRACE)
402   - trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n", __FUNCTION__, bits, kybdlock, n);
  402 + lib3270_trace_event(hSession," %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n", __FUNCTION__, bits, kybdlock, n);
403 403 #endif
404 404 if ((hSession->kybdlock ^ n) & KL_DEFERRED_UNLOCK)
405 405 {
... ... @@ -734,7 +734,7 @@ static void key_Character_wrapper(H3270 *hSession, const char *param1, const cha
734 734 code &= ~PASTE_WFLAG;
735 735 }
736 736  
737   -// trace_event(" %s -> Key(%s\"%s\")\n",ia_name[(int) ia_cause],with_ge ? "GE " : "",ctl_see((int) ebc2asc[code]));
  737 +// lib3270_trace_event(hSession," %s -> Key(%s\"%s\")\n",ia_name[(int) ia_cause],with_ge ? "GE " : "",ctl_see((int) ebc2asc[code]));
738 738  
739 739 (void) key_Character(hSession, code, with_ge, pasting, NULL);
740 740 }
... ... @@ -1963,7 +1963,7 @@ LIB3270_ACTION( clear )
1963 1963 return 0;
1964 1964 }
1965 1965 #endif /*]*/
1966   - h3270.buffer_addr = 0;
  1966 + hSession->buffer_addr = 0;
1967 1967 ctlr_clear(hSession,True);
1968 1968 cursor_move(hSession,0);
1969 1969 if (CONNECTED)
... ... @@ -2517,7 +2517,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int
2517 2517 */
2518 2518 if (hSession->kybdlock)
2519 2519 {
2520   - trace_event(" keyboard locked, string dropped\n");
  2520 + lib3270_trace_event(hSession," keyboard locked, string dropped\n");
2521 2521 return 0;
2522 2522 }
2523 2523  
... ... @@ -2621,7 +2621,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int
2621 2621 (void) key_WCharacter(ebc, &skipped);
2622 2622 break;
2623 2623 } else {
2624   - trace_event("Cannot convert U+%04x to "
  2624 + lib3270_trace_event(hSession,"Cannot convert U+%04x to "
2625 2625 "EBCDIC\n", c & 0xffff);
2626 2626 break;
2627 2627 }
... ...
rpq.c
... ... @@ -228,14 +228,14 @@ void do_qr_rpqnames(H3270 *hSession)
228 228 * adjust space remaining.
229 229 * obptr now points at "next available byte".
230 230 */
231   - x = h3270.obptr-p_term;
  231 + x = hSession->obptr-p_term;
232 232 if (x > TERM_PREFIX_SIZE) {
233 233 *p_term = x;
234 234 remaining -= x; /* This includes length and id fields,
235 235 correction below */
236 236 } else {
237 237 /* We didn't add an item after all, reset pointer. */
238   - h3270.obptr = p_term;
  238 + hSession->obptr = p_term;
239 239 }
240 240 /*
241 241 * When we calculated the length of the term, a few lines
... ...
screen.c
... ... @@ -83,7 +83,7 @@ static int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const
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);
85 85 // static void status_printer(H3270 *session, int on, void *dunno);
86   -static unsigned short color_from_fa(unsigned char fa);
  86 +static unsigned short color_from_fa(H3270 *hSession, unsigned char fa);
87 87  
88 88 /*--[ Implement ]------------------------------------------------------------------------------------*/
89 89  
... ... @@ -146,9 +146,9 @@ int screen_init(H3270 *session)
146 146 }
147 147  
148 148 /* Map a field attribute to its default colors. */
149   -static unsigned short color_from_fa(unsigned char fa)
  149 +static unsigned short color_from_fa(H3270 *hSession, unsigned char fa)
150 150 {
151   - if (h3270.m3279)
  151 + if (hSession->m3279)
152 152 return get_color_pair(DEFCOLOR_MAP(fa),0) | COLOR_ATTR_FIELD;
153 153  
154 154 // Green on black
... ... @@ -172,7 +172,7 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa)
172 172 !session->ea_buf[baddr].bg &&
173 173 !session->ea_buf[fa_addr].bg))
174 174 {
175   - a = color_from_fa(fa);
  175 + a = color_from_fa(session,fa);
176 176 }
177 177 else
178 178 {
... ... @@ -299,7 +299,7 @@ void screen_update(H3270 *session, int bstart, int bend)
299 299 int last = -1;
300 300  
301 301 fa = get_field_attribute(session,bstart);
302   - a = color_from_fa(fa);
  302 + a = color_from_fa(session,fa);
303 303 fa_addr = find_field_attribute(session,bstart); // may be -1, that's okay
304 304  
305 305 #ifdef WIN32
... ...
telnet.c
... ... @@ -26,7 +26,6 @@
26 26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27 27 * licinio@bb.com.br (Licínio Luis Branco)
28 28 * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda)
30 29 *
31 30 */
32 31  
... ... @@ -314,17 +313,8 @@ static const char *trsp_flag[2] = { &quot;POSITIVE-RESPONSE&quot;, &quot;NEGATIVE-RESPONSE&quot; };
314 313 #endif /*]*/
315 314 #endif /*]*/
316 315  
317   -// #if defined(C3270) && defined(C3270_80_132) /*[*/
318   -// #define XMIT_ROWS ((appres.altscreen != CN)? 24: maxROWS)
319   -// #define XMIT_COLS ((appres.altscreen != CN)? 80: maxCOLS)
320   -// #else /*][*/
321   -#define XMIT_ROWS h3270.maxROWS
322   -#define XMIT_COLS h3270.maxCOLS
323   -// #endif /*]*/
324   -
325   -// #if defined(HAVE_LIBSSL)
326   -// static SSL *ssl_con;
327   -// #endif
  316 +#define XMIT_ROWS hSession->maxROWS
  317 +#define XMIT_COLS hSession->maxCOLS
328 318  
329 319 #if defined(HAVE_LIBSSL) /*[*/
330 320 // static Boolean need_tls_follows = False;
... ... @@ -338,10 +328,6 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret);
338 328 static void continue_tls(H3270 *hSession, unsigned char *sbbuf, int len);
339 329 #endif /*]*/
340 330  
341   -// #if !defined(_WIN32) /*[*/
342   -// static void output_possible(H3270 *session);
343   -// #endif /*]*/
344   -
345 331 #if defined(_WIN32) /*[*/
346 332 #define socket_errno() WSAGetLastError()
347 333 #define SE_EWOULDBLOCK WSAEWOULDBLOCK
... ... @@ -1838,25 +1824,6 @@ tn3270e_function_names(const unsigned char *buf, int len)
1838 1824 }
1839 1825 #endif /*]*/
1840 1826  
1841   -/* Expand the current TN3270E function codes into text. */ /*
1842   -const char *
1843   -tn3270e_current_opts(void)
1844   -{
1845   - int i;
1846   - static char text_buf[1024];
1847   - char *s = text_buf;
1848   -
1849   - if (!h3270.e_funcs || !IN_E)
1850   - return CN;
1851   - for (i = 0; i < 32; i++) {
1852   - if (h3270.e_funcs & E_OPT(i))
1853   - s += sprintf(s, "%s%s", (s == text_buf) ? "" : " ",
1854   - fnn(i));
1855   - }
1856   - return text_buf;
1857   -}
1858   -*/
1859   -
1860 1827 /* Transmit a TN3270E FUNCTIONS REQUEST or FUNCTIONS IS message. */
1861 1828 static void tn3270e_subneg_send(H3270 *hSession, unsigned char op, unsigned long funcs)
1862 1829 {
... ... @@ -3316,61 +3283,10 @@ int net_getsockname(const H3270 *session, void *buf, int *len)
3316 3283 return getsockname(session->sock, buf, (socklen_t *)(void *)len);
3317 3284 }
3318 3285  
3319   -/* Return a text version of the current proxy type, or NULL. */ /*
3320   -char *
3321   -net_proxy_type(void)
3322   -{
3323   - if(h3270.proxy_type > 0)
3324   - return proxy_type_name(h3270.proxy_type);
3325   - else
3326   - return NULL;
3327   -}
3328   -*/
3329   -
3330   -/* Return the current proxy host, or NULL. */ /*
3331   -char *
3332   -net_proxy_host(void)
3333   -{
3334   - if(h3270.proxy_type > 0)
3335   - return h3270.proxy_host;
3336   - else
3337   - return NULL;
3338   -}
3339   -*/
3340   -
3341   -/* Return the current proxy port, or NULL. */ /*
3342   -char *
3343   -net_proxy_port(void)
3344   -{
3345   - if (h3270.proxy_type > 0)
3346   - return h3270.proxy_portname;
3347   - else
3348   - return NULL;
3349   -}
3350   -*/
3351   -
3352 3286 LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session)
3353 3287 {
3354 3288 CHECK_SESSION_HANDLE(session);
3355 3289 return session->secure;
3356 3290 }
3357 3291  
3358   -/*
3359   -LIB3270_EXPORT int lib3270_get_ssl_state(H3270 *h)
3360   -{
3361   - CHECK_SESSION_HANDLE(h);
3362 3292  
3363   -#if defined(HAVE_LIBSSL)
3364   - return (h->secure_connection != 0);
3365   -#else
3366   - return 0;
3367   -#endif
3368   -}
3369   -*/
3370   -
3371   -/*
3372   -int Get3270Socket(void)
3373   -{
3374   - return h3270.sock;
3375   -}
3376   -*/
... ...
trace_ds.c
... ... @@ -214,21 +214,6 @@ void trace_ds_nb(H3270 *hSession, const char *fmt, ...)
214 214 lib3270_free(text);
215 215 }
216 216  
217   -/* Conditional event trace. */ /*
218   -void trace_event(const char *fmt, ...)
219   -{
220   - va_list args;
221   -
222   - if (!lib3270_get_toggle(&h3270,EVENT_TRACE))
223   - return;
224   -
225   - // print out message
226   - va_start(args, fmt);
227   - vwtrace(&h3270,fmt, args);
228   - va_end(args);
229   -}
230   -*/
231   -
232 217 /* Conditional data stream trace, without line splitting. */
233 218 void trace_dsn(H3270 *hSession, const char *fmt, ...)
234 219 {
... ...
trace_dsc.h
... ... @@ -47,25 +47,24 @@
47 47 void trace_ds(H3270 *hSession, const char *fmt, ...) printflike(2, 3);
48 48 void trace_ds_nb(H3270 *hSession, const char *fmt, ...) printflike(2, 3);
49 49 void trace_dsn(H3270 *hSession, const char *fmt, ...) printflike(2, 3);
50   -// void trace_event(const char *fmt, ...) printflike(1, 2);
51 50 void trace_screen(H3270 *session);
52 51 // void trace_rollover_check(void);
53 52  
54   - #define trace_event(...) lib3270_trace_event(&h3270,__VA_ARGS__)
  53 +// #define trace_event(...) lib3270_trace_event(&h3270,__VA_ARGS__)
55 54  
56 55 #elif defined(__GNUC__)
57 56  
58 57 #define trace_ds(session, format, args...)
59 58 #define trace_dsn(session, format, args...)
60 59 #define trace_ds_nb(session, format, args...)
61   - #define trace_event(session, format, args...)
  60 +// #define trace_event(session, format, args...)
62 61  
63 62 #else
64 63  
65 64 #define trace_ds 0 &&
66 65 #define trace_ds_nb 0 &&
67 66 #define trace_dsn 0 &&
68   - #define trace_event 0 &&
  67 +// #define trace_event 0 &&
69 68 #define rcba 0 &&
70 69  
71 70 #endif
... ...