Commit 731b0d340a1e5c50f31a6da0d7fd2d92cf8ea81b
1 parent
d4cfc6af
Exists in
master
and in
3 other branches
Melhorando o processo de conexao ao host
Showing
7 changed files
with
112 additions
and
81 deletions
Show diff stats
connect.c
@@ -67,9 +67,45 @@ | @@ -67,9 +67,45 @@ | ||
67 | 67 | ||
68 | static void net_connected(H3270 *hSession) | 68 | static void net_connected(H3270 *hSession) |
69 | { | 69 | { |
70 | + int err; | ||
71 | + socklen_t len = sizeof(err); | ||
72 | + | ||
73 | + trace("%s",__FUNCTION__); | ||
70 | RemoveSource(hSession->ns_write_id); | 74 | RemoveSource(hSession->ns_write_id); |
71 | hSession->ns_write_id = NULL; | 75 | hSession->ns_write_id = NULL; |
72 | 76 | ||
77 | + if(getsockopt(hSession->sock, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0) | ||
78 | + { | ||
79 | + lib3270_disconnect(hSession); | ||
80 | + lib3270_popup_dialog( hSession, | ||
81 | + LIB3270_NOTIFY_ERROR, | ||
82 | + _( "Network error" ), | ||
83 | + _( "Unable to get connection state." ), | ||
84 | +#ifdef _WIN32 | ||
85 | + _( "Winsock Error %d"), WSAGetLastError() | ||
86 | +#else | ||
87 | + _( "%s" ), strerror(errno) | ||
88 | +#endif // _WIN32 | ||
89 | + ); | ||
90 | + return; | ||
91 | + } | ||
92 | + else if(err) | ||
93 | + { | ||
94 | + lib3270_disconnect(hSession); | ||
95 | + lib3270_popup_dialog( hSession, | ||
96 | + LIB3270_NOTIFY_ERROR, | ||
97 | + _( "Network error" ), | ||
98 | + _( "Unable to connect to server." ), | ||
99 | +#ifdef _WIN32 | ||
100 | + _( "%s"), lib3270_win32_strerror(err) | ||
101 | +#else | ||
102 | + _( "%s" ), strerror(err) | ||
103 | +#endif // _WIN32 | ||
104 | + ); | ||
105 | + return; | ||
106 | + } | ||
107 | + | ||
108 | + | ||
73 | #ifdef _WIN32 | 109 | #ifdef _WIN32 |
74 | hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception); | 110 | hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception); |
75 | hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input); | 111 | hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input); |
@@ -114,7 +150,7 @@ static void net_connected(H3270 *hSession) | @@ -114,7 +150,7 @@ static void net_connected(H3270 *hSession) | ||
114 | LIB3270_NOTIFY_CRITICAL, | 150 | LIB3270_NOTIFY_CRITICAL, |
115 | N_( "Network startup error" ), | 151 | N_( "Network startup error" ), |
116 | N_( "WSAStartup failed" ), | 152 | N_( "WSAStartup failed" ), |
117 | - "%s", win32_strerror(GetLastError()) ); | 153 | + "%s", lib3270_win32_strerror(GetLastError()) ); |
118 | 154 | ||
119 | _exit(1); | 155 | _exit(1); |
120 | } | 156 | } |
@@ -223,50 +259,51 @@ static void net_connected(H3270 *hSession) | @@ -223,50 +259,51 @@ static void net_connected(H3270 *hSession) | ||
223 | if(hSession->sock < 0) | 259 | if(hSession->sock < 0) |
224 | continue; | 260 | continue; |
225 | 261 | ||
262 | + trace("sock=%d",hSession->sock); | ||
263 | + | ||
226 | #ifdef WIN32 | 264 | #ifdef WIN32 |
227 | - u_long block; | ||
228 | - u_int len = sizeof(int); | ||
229 | 265 | ||
230 | - if(session->sockEvent == NULL) | 266 | + if(hSession->sockEvent == NULL) |
231 | { | 267 | { |
232 | char ename[256]; | 268 | char ename[256]; |
233 | 269 | ||
234 | snprintf(ename, 255, "%s-%d", PACKAGE_NAME, getpid()); | 270 | snprintf(ename, 255, "%s-%d", PACKAGE_NAME, getpid()); |
235 | 271 | ||
236 | - session->sockEvent = CreateEvent(NULL, TRUE, FALSE, ename); | ||
237 | - if(session->sockEvent == NULL) | 272 | + hSession->sockEvent = CreateEvent(NULL, TRUE, FALSE, ename); |
273 | + if(hSession->sockEvent == NULL) | ||
238 | { | 274 | { |
239 | - lib3270_popup_dialog( session, | 275 | + lib3270_popup_dialog( hSession, |
240 | LIB3270_NOTIFY_CRITICAL, | 276 | LIB3270_NOTIFY_CRITICAL, |
241 | N_( "Network startup error" ), | 277 | N_( "Network startup error" ), |
242 | N_( "Cannot create socket handle" ), | 278 | N_( "Cannot create socket handle" ), |
243 | - "%s", win32_strerror(GetLastError()) ); | 279 | + "%s", lib3270_win32_strerror(GetLastError()) ); |
244 | _exit(1); | 280 | _exit(1); |
245 | } | 281 | } |
246 | } | 282 | } |
247 | 283 | ||
248 | - if (WSAEventSelect(session->sock, session->sockEvent, FD_READ | FD_CONNECT | FD_CLOSE) != 0) | 284 | + if (WSAEventSelect(hSession->sock, hSession->sockEvent, FD_READ | FD_CONNECT | FD_CLOSE) != 0) |
249 | { | 285 | { |
250 | - lib3270_popup_dialog( session, | 286 | + lib3270_popup_dialog( hSession, |
251 | LIB3270_NOTIFY_CRITICAL, | 287 | LIB3270_NOTIFY_CRITICAL, |
252 | N_( "Network startup error" ), | 288 | N_( "Network startup error" ), |
253 | N_( "WSAEventSelect failed" ), | 289 | N_( "WSAEventSelect failed" ), |
254 | - "%s", win32_strerror(GetLastError()) ); | 290 | + "%s", lib3270_win32_strerror(GetLastError()) ); |
255 | _exit(1); | 291 | _exit(1); |
256 | } | 292 | } |
257 | 293 | ||
258 | 294 | ||
259 | 295 | ||
260 | WSASetLastError(0); | 296 | WSASetLastError(0); |
261 | - block = 0; | 297 | + u_long iMode=1; |
298 | + trace("sock=%d",hSession->sock); | ||
262 | 299 | ||
263 | - if(ioctlsocket(hSession->sock,FIONBIO,&block)) | 300 | + if(ioctlsocket(hSession->sock,FIONBIO,&iMode)) |
264 | { | 301 | { |
265 | lib3270_popup_dialog( hSession, | 302 | lib3270_popup_dialog( hSession, |
266 | LIB3270_NOTIFY_ERROR, | 303 | LIB3270_NOTIFY_ERROR, |
267 | _( "Connection error" ), | 304 | _( "Connection error" ), |
268 | _( "ioctlsocket(FIONBIO) failed." ), | 305 | _( "ioctlsocket(FIONBIO) failed." ), |
269 | - "%s", win32_strerror(GetLastError())); | 306 | + "%s", lib3270_win32_strerror(GetLastError())); |
270 | 307 | ||
271 | SOCK_CLOSE(hSession); | 308 | SOCK_CLOSE(hSession); |
272 | } | 309 | } |
@@ -279,7 +316,7 @@ static void net_connected(H3270 *hSession) | @@ -279,7 +316,7 @@ static void net_connected(H3270 *hSession) | ||
279 | LIB3270_NOTIFY_ERROR, | 316 | LIB3270_NOTIFY_ERROR, |
280 | _( "Connection error" ), | 317 | _( "Connection error" ), |
281 | _( "Can't connect to host." ), | 318 | _( "Can't connect to host." ), |
282 | - "%s", win32_strerror(GetLastError())); | 319 | + "%s", lib3270_win32_strerror(GetLastError())); |
283 | SOCK_CLOSE(hSession); | 320 | SOCK_CLOSE(hSession); |
284 | } | 321 | } |
285 | } | 322 | } |
@@ -342,11 +379,13 @@ static void net_connected(H3270 *hSession) | @@ -342,11 +379,13 @@ static void net_connected(H3270 *hSession) | ||
342 | lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True); | 379 | lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True); |
343 | 380 | ||
344 | #ifdef _WIN32 | 381 | #ifdef _WIN32 |
382 | + trace("Sockevent=%08lx callback=%p",hSession->sockEvent,net_connected); | ||
345 | hSession->ns_write_id = AddOutput(hSession->sockEvent, hSession, net_connected); | 383 | hSession->ns_write_id = AddOutput(hSession->sockEvent, hSession, net_connected); |
346 | #else | 384 | #else |
347 | hSession->ns_write_id = AddOutput(hSession->sock, hSession, net_connected); | 385 | hSession->ns_write_id = AddOutput(hSession->sock, hSession, net_connected); |
348 | #endif // WIN32 | 386 | #endif // WIN32 |
349 | 387 | ||
388 | + trace("%s: Connection in progress",__FUNCTION__); | ||
350 | return 0; | 389 | return 0; |
351 | 390 | ||
352 | } | 391 | } |
iocalls.c
@@ -269,8 +269,6 @@ static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *s | @@ -269,8 +269,6 @@ static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *s | ||
269 | { | 269 | { |
270 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); | 270 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); |
271 | 271 | ||
272 | - trace("%s session=%p proc=%p handle=%p",__FUNCTION__,session,fn,ip); | ||
273 | - | ||
274 | ip->source = source; | 272 | ip->source = source; |
275 | ip->condition = InputReadMask; | 273 | ip->condition = InputReadMask; |
276 | ip->proc = fn; | 274 | ip->proc = fn; |
@@ -290,8 +288,6 @@ static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 * | @@ -290,8 +288,6 @@ static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 * | ||
290 | { | 288 | { |
291 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); | 289 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); |
292 | 290 | ||
293 | - trace("%s session=%p proc=%p handle=%p",__FUNCTION__,session,fn,ip); | ||
294 | - | ||
295 | ip->source = source; | 291 | ip->source = source; |
296 | ip->condition = InputWriteMask; | 292 | ip->condition = InputWriteMask; |
297 | ip->proc = fn; | 293 | ip->proc = fn; |
@@ -314,8 +310,6 @@ static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 * | @@ -314,8 +310,6 @@ static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 * | ||
314 | { | 310 | { |
315 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); | 311 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); |
316 | 312 | ||
317 | - trace("%s session=%p proc=%p",__FUNCTION__,session,fn); | ||
318 | - | ||
319 | ip->source = source; | 313 | ip->source = source; |
320 | ip->condition = InputExceptMask; | 314 | ip->condition = InputExceptMask; |
321 | ip->proc = fn; | 315 | ip->proc = fn; |
@@ -324,7 +318,7 @@ static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 * | @@ -324,7 +318,7 @@ static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 * | ||
324 | inputs = ip; | 318 | inputs = ip; |
325 | inputs_changed = True; | 319 | inputs_changed = True; |
326 | 320 | ||
327 | - trace("%s: fd=%d callback=%p handle=%p",__FUNCTION__,source,fn,ip); | 321 | + trace("%s session=%p proc=%p handle=%p",__FUNCTION__,ip->session,ip->proc,ip); |
328 | 322 | ||
329 | return ip; | 323 | return ip; |
330 | } | 324 | } |
@@ -335,8 +329,6 @@ static void internal_remove_source(void *id) | @@ -335,8 +329,6 @@ static void internal_remove_source(void *id) | ||
335 | input_t *ip; | 329 | input_t *ip; |
336 | input_t *prev = (input_t *)NULL; | 330 | input_t *prev = (input_t *)NULL; |
337 | 331 | ||
338 | - trace("%s: fhandle=%p",__FUNCTION__,(input_t *) id); | ||
339 | - | ||
340 | for (ip = inputs; ip != (input_t *)NULL; ip = ip->next) | 332 | for (ip = inputs; ip != (input_t *)NULL; ip = ip->next) |
341 | { | 333 | { |
342 | if (ip == (input_t *)id) | 334 | if (ip == (input_t *)id) |
@@ -347,7 +339,7 @@ static void internal_remove_source(void *id) | @@ -347,7 +339,7 @@ static void internal_remove_source(void *id) | ||
347 | 339 | ||
348 | if (ip == (input_t *)NULL) | 340 | if (ip == (input_t *)NULL) |
349 | { | 341 | { |
350 | - lib3270_write_log(NULL,"lib3270","Double removal on %s: Input %p wasnt found in the list",__FUNCTION__,id); | 342 | + lib3270_write_log(NULL,"lib3270","Invalid call to (%s): Input %p wasnt found in the list",__FUNCTION__,id); |
351 | return; | 343 | return; |
352 | } | 344 | } |
353 | 345 | ||
@@ -367,7 +359,6 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | @@ -367,7 +359,6 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | ||
367 | HANDLE ha[MAX_HA]; | 359 | HANDLE ha[MAX_HA]; |
368 | DWORD events; | 360 | DWORD events; |
369 | DWORD tmo; | 361 | DWORD tmo; |
370 | - DWORD ret; | ||
371 | unsigned long long now; | 362 | unsigned long long now; |
372 | int i; | 363 | int i; |
373 | #else | 364 | #else |
@@ -376,7 +367,7 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | @@ -376,7 +367,7 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | ||
376 | struct timeval now, twait, *tp; | 367 | struct timeval now, twait, *tp; |
377 | int events; | 368 | int events; |
378 | #endif | 369 | #endif |
379 | - input_t *ip, *ip_next; | 370 | + input_t *ip; |
380 | struct timeout *t; | 371 | struct timeout *t; |
381 | int processed_any = 0; | 372 | int processed_any = 0; |
382 | 373 | ||
@@ -512,30 +503,41 @@ retry: | @@ -512,30 +503,41 @@ retry: | ||
512 | tmo = 1; | 503 | tmo = 1; |
513 | } | 504 | } |
514 | 505 | ||
515 | - ret = WaitForMultipleObjects(nha, ha, FALSE, tmo); | ||
516 | - if (ret == WAIT_FAILED) | 506 | + if(events) |
517 | { | 507 | { |
518 | - lib3270_popup_dialog( hSession, | ||
519 | - LIB3270_NOTIFY_ERROR, | ||
520 | - _( "Network error" ), | ||
521 | - _( "WaitForMultipleObjects() failed when processing for events." ), | ||
522 | - "Windows error %d", | ||
523 | - GetLastError()); | ||
524 | - } | ||
525 | - | ||
526 | - inputs_changed = False; | 508 | + DWORD ret = WaitForMultipleObjects(events, ha, FALSE, tmo); |
527 | 509 | ||
528 | - for (i = 0, ip = inputs; ip != (input_t *)NULL; ip = ip_next, i++) | ||
529 | - { | ||
530 | - if(ret == WAIT_OBJECT_0 + i) | 510 | + if (ret == WAIT_FAILED) |
531 | { | 511 | { |
532 | - (*ip->proc)(ip->session); | ||
533 | - processed_any = True; | ||
534 | - if (inputs_changed) | ||
535 | - goto retry; | 512 | + lib3270_popup_dialog( hSession, |
513 | + LIB3270_NOTIFY_ERROR, | ||
514 | + _( "Network error" ), | ||
515 | + _( "WaitForMultipleObjects() failed when processing for events." ), | ||
516 | + "%s", | ||
517 | + lib3270_win32_strerror(GetLastError())); | ||
518 | + lib3270_disconnect(hSession); | ||
536 | } | 519 | } |
520 | + else | ||
521 | + { | ||
522 | + inputs_changed = False; | ||
537 | 523 | ||
524 | + for (i = 0, ip = inputs; ip != (input_t *)NULL; ip = ip->next, i++) | ||
525 | + { | ||
526 | + if(ret == WAIT_OBJECT_0 + i) | ||
527 | + { | ||
528 | + (*ip->proc)(ip->session); | ||
529 | + processed_any = True; | ||
530 | + if (inputs_changed) | ||
531 | + goto retry; | ||
532 | + } | ||
533 | + } | ||
534 | + } | ||
535 | + } | ||
536 | + else if(block) | ||
537 | + { | ||
538 | + Sleep(100); | ||
538 | } | 539 | } |
540 | + | ||
539 | #else | 541 | #else |
540 | 542 | ||
541 | FD_ZERO(&rfds); | 543 | FD_ZERO(&rfds); |
@@ -606,10 +608,8 @@ retry: | @@ -606,10 +608,8 @@ retry: | ||
606 | } | 608 | } |
607 | else | 609 | else |
608 | { | 610 | { |
609 | - for (ip = inputs; ip != (input_t *) NULL; ip = ip_next) | 611 | + for (ip = inputs; ip != (input_t *) NULL; ip = ip->next) |
610 | { | 612 | { |
611 | - ip_next = ip->next; | ||
612 | - | ||
613 | if (((unsigned long)ip->condition & InputReadMask) && FD_ISSET(ip->source, &rfds)) | 613 | if (((unsigned long)ip->condition & InputReadMask) && FD_ISSET(ip->source, &rfds)) |
614 | { | 614 | { |
615 | (*ip->proc)(ip->session); | 615 | (*ip->proc)(ip->session); |
kybd.c
@@ -399,7 +399,7 @@ void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits) | @@ -399,7 +399,7 @@ void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits) | ||
399 | { | 399 | { |
400 | unsigned int n = hSession->kybdlock & ~( (unsigned int) bits); | 400 | unsigned int n = hSession->kybdlock & ~( (unsigned int) bits); |
401 | 401 | ||
402 | - trace("%s: kybdlock=%d",__FUNCTION__,n); | 402 | +// trace("%s: kybdlock=%d",__FUNCTION__,n); |
403 | 403 | ||
404 | if (n != hSession->kybdlock) | 404 | if (n != hSession->kybdlock) |
405 | { | 405 | { |
lib3270.cbp
@@ -15,9 +15,6 @@ | @@ -15,9 +15,6 @@ | ||
15 | <Add option="-g" /> | 15 | <Add option="-g" /> |
16 | <Add option="-DDEBUG=1" /> | 16 | <Add option="-DDEBUG=1" /> |
17 | </Compiler> | 17 | </Compiler> |
18 | - <Linker> | ||
19 | - <Add library="pthread" /> | ||
20 | - </Linker> | ||
21 | </Target> | 18 | </Target> |
22 | <Target title="Release"> | 19 | <Target title="Release"> |
23 | <Option output=".bin/Release/3270" prefix_auto="1" extension_auto="1" /> | 20 | <Option output=".bin/Release/3270" prefix_auto="1" extension_auto="1" /> |
@@ -50,16 +47,17 @@ | @@ -50,16 +47,17 @@ | ||
50 | <Add option="-Wredundant-decls" /> | 47 | <Add option="-Wredundant-decls" /> |
51 | <Add option="-Wunreachable-code" /> | 48 | <Add option="-Wunreachable-code" /> |
52 | <Add option="-Wmissing-declarations" /> | 49 | <Add option="-Wmissing-declarations" /> |
53 | - <Add option="-Wall" /> | ||
54 | <Add option="-pthread" /> | 50 | <Add option="-pthread" /> |
51 | + <Add option="-Wno-redundant-decls" /> | ||
55 | <Add option="-DLIB3270=1" /> | 52 | <Add option="-DLIB3270=1" /> |
56 | <Add directory="../include" /> | 53 | <Add directory="../include" /> |
57 | <Add directory="../include/lib3270" /> | 54 | <Add directory="../include/lib3270" /> |
58 | </Compiler> | 55 | </Compiler> |
59 | <Linker> | 56 | <Linker> |
60 | - <Add option="-pthread" /> | ||
61 | - <Add option="-lssl" /> | ||
62 | - <Add option="-lcrypto" /> | 57 | + <Add library="intl" /> |
58 | + <Add library="ws2_32" /> | ||
59 | + <Add library="ssl" /> | ||
60 | + <Add library="crypto" /> | ||
63 | </Linker> | 61 | </Linker> |
64 | <Unit filename="../include/lib3270.h" /> | 62 | <Unit filename="../include/lib3270.h" /> |
65 | <Unit filename="../include/lib3270/action_table.h" /> | 63 | <Unit filename="../include/lib3270/action_table.h" /> |
telnet.c
@@ -315,7 +315,7 @@ void sockstart(H3270 *session) | @@ -315,7 +315,7 @@ void sockstart(H3270 *session) | ||
315 | LIB3270_NOTIFY_CRITICAL, | 315 | LIB3270_NOTIFY_CRITICAL, |
316 | N_( "Network startup error" ), | 316 | N_( "Network startup error" ), |
317 | N_( "WSAStartup failed" ), | 317 | N_( "WSAStartup failed" ), |
318 | - "%s", win32_strerror(GetLastError()) ); | 318 | + "%s", lib3270_win32_strerror(GetLastError()) ); |
319 | 319 | ||
320 | _exit(1); | 320 | _exit(1); |
321 | } | 321 | } |
@@ -344,7 +344,7 @@ socklen_t ha_len = sizeof(haddr); | @@ -344,7 +344,7 @@ socklen_t ha_len = sizeof(haddr); | ||
344 | void popup_a_sockerr(H3270 *hSession, char *fmt, ...) | 344 | void popup_a_sockerr(H3270 *hSession, char *fmt, ...) |
345 | { | 345 | { |
346 | #if defined(_WIN32) | 346 | #if defined(_WIN32) |
347 | - const char *msg = win32_strerror(socket_errno()); | 347 | + const char *msg = lib3270_win32_strerror(socket_errno()); |
348 | #else | 348 | #else |
349 | const char *msg = strerror(errno); | 349 | const char *msg = strerror(errno); |
350 | #endif // WIN32 | 350 | #endif // WIN32 |
@@ -719,7 +719,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo | @@ -719,7 +719,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo | ||
719 | LIB3270_NOTIFY_CRITICAL, | 719 | LIB3270_NOTIFY_CRITICAL, |
720 | N_( "Network startup error" ), | 720 | N_( "Network startup error" ), |
721 | N_( "Cannot create socket handle" ), | 721 | N_( "Cannot create socket handle" ), |
722 | - "%s", win32_strerror(GetLastError()) ); | 722 | + "%s", lib3270_win32_strerror(GetLastError()) ); |
723 | _exit(1); | 723 | _exit(1); |
724 | } | 724 | } |
725 | } | 725 | } |
@@ -730,7 +730,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo | @@ -730,7 +730,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo | ||
730 | LIB3270_NOTIFY_CRITICAL, | 730 | LIB3270_NOTIFY_CRITICAL, |
731 | N_( "Network startup error" ), | 731 | N_( "Network startup error" ), |
732 | N_( "WSAEventSelect failed" ), | 732 | N_( "WSAEventSelect failed" ), |
733 | - "%s", win32_strerror(GetLastError()) ); | 733 | + "%s", lib3270_win32_strerror(GetLastError()) ); |
734 | _exit(1); | 734 | _exit(1); |
735 | } | 735 | } |
736 | 736 | ||
@@ -1069,7 +1069,7 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned | @@ -1069,7 +1069,7 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned | ||
1069 | { | 1069 | { |
1070 | register const unsigned char * cp; | 1070 | register const unsigned char * cp; |
1071 | 1071 | ||
1072 | - trace("%s: nr=%d",__FUNCTION__,(int) nr); | 1072 | +// trace("%s: nr=%d",__FUNCTION__,(int) nr); |
1073 | 1073 | ||
1074 | trace_netdata(hSession, '<', netrbuf, nr); | 1074 | trace_netdata(hSession, '<', netrbuf, nr); |
1075 | 1075 | ||
@@ -3284,7 +3284,7 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret) | @@ -3284,7 +3284,7 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret) | ||
3284 | #if defined(_WIN32) | 3284 | #if defined(_WIN32) |
3285 | else if (GetLastError() != 0) | 3285 | else if (GetLastError() != 0) |
3286 | { | 3286 | { |
3287 | - strncpy(err_buf,win32_strerror(GetLastError()),1023); | 3287 | + strncpy(err_buf,lib3270_win32_strerror(GetLastError()),1023); |
3288 | } | 3288 | } |
3289 | #else | 3289 | #else |
3290 | else if (errno != 0) | 3290 | else if (errno != 0) |
testprogram.c
1 | 1 | ||
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | -#include <pthread.h> | 4 | +// #include <pthread.h> |
5 | 5 | ||
6 | #include "globals.h" | 6 | #include "globals.h" |
7 | #include <lib3270/macros.h> | 7 | #include <lib3270/macros.h> |
8 | 8 | ||
9 | #define MAX_ARGS 10 | 9 | #define MAX_ARGS 10 |
10 | 10 | ||
11 | -#include <pthread.h> | ||
12 | - | ||
13 | static H3270 *session = NULL; | 11 | static H3270 *session = NULL; |
14 | 12 | ||
15 | static void * mainloop(void *dunno) | 13 | static void * mainloop(void *dunno) |
@@ -25,18 +23,22 @@ int main(int numpar, char *param[]) | @@ -25,18 +23,22 @@ int main(int numpar, char *param[]) | ||
25 | { | 23 | { |
26 | H3270 * h; | 24 | H3270 * h; |
27 | char line[4096]; | 25 | char line[4096]; |
28 | - pthread_t thread; | 26 | +// pthread_t thread; |
29 | 27 | ||
30 | lib3270_initialize(); | 28 | lib3270_initialize(); |
31 | 29 | ||
32 | session = h = lib3270_session_new(""); | 30 | session = h = lib3270_session_new(""); |
33 | printf("3270 session %p created\n]",h); | 31 | printf("3270 session %p created\n]",h); |
34 | 32 | ||
35 | - pthread_create(&thread, NULL, mainloop, NULL); | ||
36 | - pthread_detach(thread); | 33 | +// pthread_create(&thread, NULL, mainloop, NULL); |
34 | +// pthread_detach(thread); | ||
35 | + | ||
36 | + lib3270_connect_host(h, "fandezhi.efglobe.com", "telnet"); | ||
37 | +// lib3270_connect_host(h, "127.0.0.1", "9090"); | ||
37 | 38 | ||
38 | - lib3270_connect_host(h, "127.0.0.1", "80"); | 39 | + mainloop(0); |
39 | 40 | ||
41 | +/* | ||
40 | while(fgets(line,4095,stdin)) | 42 | while(fgets(line,4095,stdin)) |
41 | { | 43 | { |
42 | // const LIB3270_MACRO_LIST *cmd = get_3270_calls(); | 44 | // const LIB3270_MACRO_LIST *cmd = get_3270_calls(); |
@@ -85,6 +87,7 @@ int main(int numpar, char *param[]) | @@ -85,6 +87,7 @@ int main(int numpar, char *param[]) | ||
85 | 87 | ||
86 | printf("Ending 3270 session %p\n",h); | 88 | printf("Ending 3270 session %p\n",h); |
87 | lib3270_session_free(h); | 89 | lib3270_session_free(h); |
90 | +*/ | ||
88 | 91 | ||
89 | return 0; | 92 | return 0; |
90 | } | 93 | } |
util.c
@@ -146,25 +146,16 @@ const char * inet_ntop(int af, const void *src, char *dst, socklen_t cnt) | @@ -146,25 +146,16 @@ const char * inet_ntop(int af, const void *src, char *dst, socklen_t cnt) | ||
146 | } | 146 | } |
147 | 147 | ||
148 | // Decode a Win32 error number. | 148 | // Decode a Win32 error number. |
149 | -const char * win32_strerror(int e) | 149 | +LIB3270_EXPORT const char * lib3270_win32_strerror(int e) |
150 | { | 150 | { |
151 | static char buffer[4096]; | 151 | static char buffer[4096]; |
152 | 152 | ||
153 | - if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, | ||
154 | - NULL, | ||
155 | - e, | ||
156 | - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||
157 | - buffer, | ||
158 | - sizeof(buffer), | ||
159 | - NULL) == 0) { | ||
160 | - | ||
161 | - sprintf(buffer, "Windows error %d", e); | ||
162 | - } | 153 | + if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,e,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),buffer,sizeof(buffer),NULL) == 0) |
154 | + snprintf(buffer, 4095, "Windows error %d", e); | ||
163 | 155 | ||
164 | return buffer; | 156 | return buffer; |
165 | } | 157 | } |
166 | 158 | ||
167 | - | ||
168 | #endif // _WIN32 | 159 | #endif // _WIN32 |
169 | 160 | ||
170 | /* | 161 | /* |