Commit 353fee04940716bed5342f0a62b3bfb8b78fffa1
1 parent
a67b1c99
Exists in
master
and in
3 other branches
Iniciando remoção das chamadas a gethostbyname
Showing
5 changed files
with
233 additions
and
68 deletions
Show diff stats
connect.c
@@ -126,6 +126,9 @@ | @@ -126,6 +126,9 @@ | ||
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | + #error Implementar | ||
130 | + | ||
131 | + /* | ||
129 | if(sock > 0) | 132 | if(sock > 0) |
130 | { | 133 | { |
131 | // Connection in progress, wait until socket is available for write | 134 | // Connection in progress, wait until socket is available for write |
@@ -203,6 +206,7 @@ | @@ -203,6 +206,7 @@ | ||
203 | } | 206 | } |
204 | } | 207 | } |
205 | } | 208 | } |
209 | + */ | ||
206 | 210 | ||
207 | #else | 211 | #else |
208 | fcntl(sock, F_SETFL,fcntl(sock,F_GETFL,0)|O_NONBLOCK); | 212 | fcntl(sock, F_SETFL,fcntl(sock,F_GETFL,0)|O_NONBLOCK); |
@@ -223,6 +227,9 @@ | @@ -223,6 +227,9 @@ | ||
223 | } | 227 | } |
224 | } | 228 | } |
225 | 229 | ||
230 | + #error Implementar | ||
231 | + | ||
232 | +/* | ||
226 | if(sock > 0) | 233 | if(sock > 0) |
227 | { | 234 | { |
228 | // Connection in progress, wait until socket is available for write | 235 | // Connection in progress, wait until socket is available for write |
@@ -301,6 +308,7 @@ | @@ -301,6 +308,7 @@ | ||
301 | } | 308 | } |
302 | } | 309 | } |
303 | } | 310 | } |
311 | + */ | ||
304 | #endif // WIN32 | 312 | #endif // WIN32 |
305 | } | 313 | } |
306 | 314 | ||
@@ -308,7 +316,7 @@ | @@ -308,7 +316,7 @@ | ||
308 | 316 | ||
309 | status_changed(hSession,saved_status); | 317 | status_changed(hSession,saved_status); |
310 | 318 | ||
311 | - return sock; | 319 | + return 0; |
312 | 320 | ||
313 | } | 321 | } |
314 | 322 |
iocalls.c
@@ -48,20 +48,19 @@ | @@ -48,20 +48,19 @@ | ||
48 | /*---[ Standard calls ]-------------------------------------------------------------------------------------*/ | 48 | /*---[ Standard calls ]-------------------------------------------------------------------------------------*/ |
49 | 49 | ||
50 | static void internal_remove_timeout(void *timer); | 50 | static void internal_remove_timeout(void *timer); |
51 | +static void internal_remove_source(void *id); | ||
51 | static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | 52 | static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); |
52 | 53 | ||
53 | #ifdef WIN32 | 54 | #ifdef WIN32 |
54 | static void * internal_add_input(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | 55 | static void * internal_add_input(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); |
56 | + static void * internal_add_output(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | ||
55 | static void * internal_add_except(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | 57 | static void * internal_add_except(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); |
56 | #else | 58 | #else |
57 | static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *session)); | 59 | static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *session)); |
60 | + static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 *session)); | ||
58 | static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 *session)); | 61 | static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 *session)); |
59 | #endif // WIN32 | 62 | #endif // WIN32 |
60 | 63 | ||
61 | -static void internal_remove_input(void *id); | ||
62 | - | ||
63 | -// static int internal_process_events(int block); | ||
64 | - | ||
65 | static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm); | 64 | static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm); |
66 | static int internal_wait(H3270 *hSession, int seconds); | 65 | static int internal_wait(H3270 *hSession, int seconds); |
67 | 66 | ||
@@ -76,19 +75,25 @@ static void internal_ring_bell(H3270 *); | @@ -76,19 +75,25 @@ static void internal_ring_bell(H3270 *); | ||
76 | static void (*remove_timeout)(void *timer) | 75 | static void (*remove_timeout)(void *timer) |
77 | = internal_remove_timeout; | 76 | = internal_remove_timeout; |
78 | 77 | ||
79 | - static void (*remove_input)(void *id) | ||
80 | - = internal_remove_input; | 78 | + static void (*remove_source)(void *id) |
79 | + = internal_remove_source; | ||
81 | 80 | ||
82 | #ifdef WIN32 | 81 | #ifdef WIN32 |
83 | static void * (*add_input)(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | 82 | static void * (*add_input)(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) |
84 | = internal_add_input; | 83 | = internal_add_input; |
85 | 84 | ||
85 | + static void * (*add_output)(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
86 | + = internal_add_output; | ||
87 | + | ||
86 | static void * (*add_except)(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | 88 | static void * (*add_except)(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) |
87 | = internal_add_except; | 89 | = internal_add_except; |
88 | #else | 90 | #else |
89 | static void * (*add_input)(int source, H3270 *session, void (*fn)(H3270 *session)) | 91 | static void * (*add_input)(int source, H3270 *session, void (*fn)(H3270 *session)) |
90 | = internal_add_input; | 92 | = internal_add_input; |
91 | 93 | ||
94 | + static void * (*add_output)(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
95 | + = internal_add_output; | ||
96 | + | ||
92 | static void * (*add_except)(int source, H3270 *session, void (*fn)(H3270 *session)) | 97 | static void * (*add_except)(int source, H3270 *session, void (*fn)(H3270 *session)) |
93 | = internal_add_except; | 98 | = internal_add_except; |
94 | #endif // WIN32 | 99 | #endif // WIN32 |
@@ -266,19 +271,39 @@ static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *s | @@ -266,19 +271,39 @@ static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *s | ||
266 | 271 | ||
267 | trace("%s session=%p proc=%p",__FUNCTION__,session,fn); | 272 | trace("%s session=%p proc=%p",__FUNCTION__,session,fn); |
268 | 273 | ||
269 | - ip->source = source; | ||
270 | - ip->condition = InputReadMask; | ||
271 | - ip->proc = fn; | ||
272 | - ip->session = session; | ||
273 | - ip->next = inputs; | ||
274 | - inputs = ip; | ||
275 | - inputs_changed = True; | 274 | + ip->source = source; |
275 | + ip->condition = InputReadMask; | ||
276 | + ip->proc = fn; | ||
277 | + ip->session = session; | ||
278 | + ip->next = inputs; | ||
279 | + inputs = ip; | ||
280 | + inputs_changed = True; | ||
276 | 281 | ||
277 | -// trace("%s: fd=%d callback=%p handle=%p",__FUNCTION__,source,fn,ip); | 282 | + return ip; |
283 | +} | ||
284 | + | ||
285 | +#ifdef WIN32 | ||
286 | +static void * internal_add_output(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
287 | +#else | ||
288 | +static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
289 | +#endif // WIN32 | ||
290 | +{ | ||
291 | + input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); | ||
292 | + | ||
293 | + trace("%s session=%p proc=%p",__FUNCTION__,session,fn); | ||
294 | + | ||
295 | + ip->source = source; | ||
296 | + ip->condition = InputWriteMask; | ||
297 | + ip->proc = fn; | ||
298 | + ip->session = session; | ||
299 | + ip->next = inputs; | ||
300 | + inputs = ip; | ||
301 | + inputs_changed = True; | ||
278 | 302 | ||
279 | return ip; | 303 | return ip; |
280 | } | 304 | } |
281 | 305 | ||
306 | + | ||
282 | #if defined(_WIN32) | 307 | #if defined(_WIN32) |
283 | static void * internal_add_except(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | 308 | static void * internal_add_except(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) |
284 | { | 309 | { |
@@ -305,7 +330,7 @@ static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 * | @@ -305,7 +330,7 @@ static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 * | ||
305 | } | 330 | } |
306 | #endif // WIN32 | 331 | #endif // WIN32 |
307 | 332 | ||
308 | -static void internal_remove_input(void *id) | 333 | +static void internal_remove_source(void *id) |
309 | { | 334 | { |
310 | input_t *ip; | 335 | input_t *ip; |
311 | input_t *prev = (input_t *)NULL; | 336 | input_t *prev = (input_t *)NULL; |
@@ -337,7 +362,7 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | @@ -337,7 +362,7 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | ||
337 | { | 362 | { |
338 | #if defined(_WIN32) | 363 | #if defined(_WIN32) |
339 | HANDLE ha[MAX_HA]; | 364 | HANDLE ha[MAX_HA]; |
340 | - DWORD nha; | 365 | + DWORD events; |
341 | DWORD tmo; | 366 | DWORD tmo; |
342 | DWORD ret; | 367 | DWORD ret; |
343 | unsigned long long now; | 368 | unsigned long long now; |
@@ -346,19 +371,21 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | @@ -346,19 +371,21 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | ||
346 | fd_set rfds, wfds, xfds; | 371 | fd_set rfds, wfds, xfds; |
347 | int ns; | 372 | int ns; |
348 | struct timeval now, twait, *tp; | 373 | struct timeval now, twait, *tp; |
374 | + int events; | ||
349 | #endif | 375 | #endif |
350 | input_t *ip, *ip_next; | 376 | input_t *ip, *ip_next; |
351 | struct timeout *t; | 377 | struct timeout *t; |
352 | - Boolean any_events; | ||
353 | int processed_any = 0; | 378 | int processed_any = 0; |
354 | 379 | ||
355 | - retry: | 380 | +retry: |
356 | 381 | ||
357 | // If we've processed any input, then don't block again. | 382 | // If we've processed any input, then don't block again. |
358 | - | ||
359 | if(processed_any) | 383 | if(processed_any) |
360 | block = 0; | 384 | block = 0; |
361 | - any_events = False; | 385 | + |
386 | + events = 0; | ||
387 | + | ||
388 | +/* | ||
362 | #if defined(_WIN32) | 389 | #if defined(_WIN32) |
363 | nha = 0; | 390 | nha = 0; |
364 | #else | 391 | #else |
@@ -378,12 +405,16 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | @@ -378,12 +405,16 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | ||
378 | #endif | 405 | #endif |
379 | any_events = True; | 406 | any_events = True; |
380 | } | 407 | } |
381 | -#if !defined(_WIN32) | ||
382 | if ((unsigned long)ip->condition & InputWriteMask) | 408 | if ((unsigned long)ip->condition & InputWriteMask) |
383 | { | 409 | { |
410 | +#if defined(_WIN32) | ||
411 | + ha[nha++] = ip->source; | ||
412 | +#else | ||
384 | FD_SET(ip->source, &wfds); | 413 | FD_SET(ip->source, &wfds); |
414 | +#endif | ||
385 | any_events = True; | 415 | any_events = True; |
386 | } | 416 | } |
417 | +#if !defined(_WIN32) | ||
387 | if ((unsigned long)ip->condition & InputExceptMask) | 418 | if ((unsigned long)ip->condition & InputExceptMask) |
388 | { | 419 | { |
389 | FD_SET(ip->source, &xfds); | 420 | FD_SET(ip->source, &xfds); |
@@ -394,7 +425,8 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | @@ -394,7 +425,8 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | ||
394 | 425 | ||
395 | if (block) | 426 | if (block) |
396 | { | 427 | { |
397 | - if (timeouts != TN) { | 428 | + if (timeouts != TN) |
429 | + { | ||
398 | #if defined(_WIN32) | 430 | #if defined(_WIN32) |
399 | ms_ts(&now); | 431 | ms_ts(&now); |
400 | if (now > timeouts->ts) | 432 | if (now > timeouts->ts) |
@@ -414,7 +446,9 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | @@ -414,7 +446,9 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | ||
414 | tp = &twait; | 446 | tp = &twait; |
415 | #endif | 447 | #endif |
416 | any_events = True; | 448 | any_events = True; |
417 | - } else { | 449 | + } |
450 | + else | ||
451 | + { | ||
418 | // Block for 1 second (at maximal) | 452 | // Block for 1 second (at maximal) |
419 | #if defined(_WIN32) | 453 | #if defined(_WIN32) |
420 | tmo = 1; | 454 | tmo = 1; |
@@ -437,63 +471,170 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | @@ -437,63 +471,170 @@ static int internal_event_dispatcher(H3270 *hSession, int block) | ||
437 | 471 | ||
438 | if (!any_events) | 472 | if (!any_events) |
439 | return processed_any; | 473 | return processed_any; |
474 | +*/ | ||
440 | 475 | ||
441 | #if defined(_WIN32) | 476 | #if defined(_WIN32) |
442 | - ret = WaitForMultipleObjects(nha, ha, FALSE, tmo); | ||
443 | - if (ret == WAIT_FAILED) | 477 | + |
478 | + for (ip = inputs; ip != (input_t *)NULL; ip = ip->next) | ||
444 | { | 479 | { |
445 | -#else | ||
446 | - ns = select(FD_SETSIZE, &rfds, &wfds, &xfds, tp); | ||
447 | - if (ns < 0) | 480 | + if ((unsigned long)ip->condition & InputReadMask) |
481 | + ha[events++] = ip->source; | ||
482 | + if ((unsigned long)ip->condition & InputWriteMask) | ||
483 | + ha[events++] = ip->source; | ||
484 | + } | ||
485 | + | ||
486 | + if (block) | ||
448 | { | 487 | { |
449 | - if (errno != EINTR) | ||
450 | - lib3270_popup_an_errno(hSession,errno,"%s",_( "select() failed when dispatching events")); | ||
451 | -#endif | 488 | + if (timeouts != TN) |
489 | + { | ||
490 | + ms_ts(&now); | ||
491 | + if (now > timeouts->ts) | ||
492 | + tmo = 0; | ||
493 | + else | ||
494 | + tmo = timeouts->ts - now; | ||
495 | + } | ||
496 | + else | ||
497 | + { | ||
498 | + // Block for 1 second (at maximal) | ||
499 | + tmo = 1; | ||
500 | + } | ||
501 | + } | ||
502 | + else if (!events) | ||
503 | + { | ||
504 | + // No block & no events, return | ||
452 | return processed_any; | 505 | return processed_any; |
453 | } | 506 | } |
507 | + else | ||
508 | + { | ||
509 | + tmo = 1; | ||
510 | + } | ||
511 | + | ||
512 | + ret = WaitForMultipleObjects(nha, ha, FALSE, tmo); | ||
513 | + if (ret == WAIT_FAILED) | ||
514 | + { | ||
515 | + lib3270_popup_dialog( hSession, | ||
516 | + LIB3270_NOTIFY_ERROR, | ||
517 | + _( "Network error" ), | ||
518 | + _( "WaitForMultipleObjects() failed when processing for events." ), | ||
519 | + "Windows error %d", | ||
520 | + GetLastError()); | ||
521 | + } | ||
454 | 522 | ||
455 | inputs_changed = False; | 523 | inputs_changed = False; |
456 | 524 | ||
457 | -#if defined(_WIN32) | ||
458 | for (i = 0, ip = inputs; ip != (input_t *)NULL; ip = ip_next, i++) | 525 | for (i = 0, ip = inputs; ip != (input_t *)NULL; ip = ip_next, i++) |
459 | { | 526 | { |
460 | -#else | ||
461 | - for (ip = inputs; ip != (input_t *) NULL; ip = ip_next) | ||
462 | - { | ||
463 | -#endif | ||
464 | - ip_next = ip->next; | ||
465 | - if (((unsigned long)ip->condition & InputReadMask) && | ||
466 | -#if defined(_WIN32) | ||
467 | - ret == WAIT_OBJECT_0 + i) | ||
468 | - { | ||
469 | -#else | ||
470 | - FD_ISSET(ip->source, &rfds)) | 527 | + if(ret == WAIT_OBJECT_0 + i) |
471 | { | 528 | { |
472 | -#endif | ||
473 | (*ip->proc)(ip->session); | 529 | (*ip->proc)(ip->session); |
474 | processed_any = True; | 530 | processed_any = True; |
475 | if (inputs_changed) | 531 | if (inputs_changed) |
476 | goto retry; | 532 | goto retry; |
477 | } | 533 | } |
478 | 534 | ||
479 | -#if !defined(_WIN32) | ||
480 | - if (((unsigned long)ip->condition & InputWriteMask) && FD_ISSET(ip->source, &wfds)) | 535 | + } |
536 | +#else | ||
537 | + | ||
538 | + FD_ZERO(&rfds); | ||
539 | + FD_ZERO(&wfds); | ||
540 | + FD_ZERO(&xfds); | ||
541 | + | ||
542 | + for (ip = inputs; ip != (input_t *)NULL; ip = ip->next) | ||
543 | + { | ||
544 | + if ((unsigned long)ip->condition & InputReadMask) | ||
481 | { | 545 | { |
482 | - (*ip->proc)(ip->session); | ||
483 | - processed_any = True; | ||
484 | - if (inputs_changed) | ||
485 | - goto retry; | 546 | + FD_SET(ip->source, &rfds); |
547 | + events++; | ||
486 | } | 548 | } |
487 | - if (((unsigned long)ip->condition & InputExceptMask) && FD_ISSET(ip->source, &xfds)) | 549 | + |
550 | + if ((unsigned long)ip->condition & InputWriteMask) | ||
488 | { | 551 | { |
489 | - (*ip->proc)(ip->session); | ||
490 | - processed_any = True; | ||
491 | - if (inputs_changed) | ||
492 | - goto retry; | 552 | + FD_SET(ip->source, &wfds); |
553 | + events++; | ||
554 | + } | ||
555 | + | ||
556 | + if ((unsigned long)ip->condition & InputExceptMask) | ||
557 | + { | ||
558 | + FD_SET(ip->source, &xfds); | ||
559 | + events++; | ||
493 | } | 560 | } |
494 | -#endif | ||
495 | } | 561 | } |
496 | 562 | ||
563 | + if (block) | ||
564 | + { | ||
565 | + if (timeouts != TN) | ||
566 | + { | ||
567 | + (void) gettimeofday(&now, (void *)NULL); | ||
568 | + twait.tv_sec = timeouts->tv.tv_sec - now.tv_sec; | ||
569 | + twait.tv_usec = timeouts->tv.tv_usec - now.tv_usec; | ||
570 | + if (twait.tv_usec < 0L) { | ||
571 | + twait.tv_sec--; | ||
572 | + twait.tv_usec += MILLION; | ||
573 | + } | ||
574 | + if (twait.tv_sec < 0L) | ||
575 | + twait.tv_sec = twait.tv_usec = 0L; | ||
576 | + tp = &twait; | ||
577 | + } | ||
578 | + else | ||
579 | + { | ||
580 | + twait.tv_sec = 1; | ||
581 | + twait.tv_usec = 0L; | ||
582 | + tp = &twait; | ||
583 | + } | ||
584 | + } | ||
585 | + else | ||
586 | + { | ||
587 | + twait.tv_sec = twait.tv_usec = 0L; | ||
588 | + tp = &twait; | ||
589 | + | ||
590 | + if(!events) | ||
591 | + return processed_any; | ||
592 | + } | ||
593 | + | ||
594 | + ns = select(FD_SETSIZE, &rfds, &wfds, &xfds, tp); | ||
595 | + if (ns < 0 && errno != EINTR) | ||
596 | + { | ||
597 | + lib3270_popup_dialog( hSession, | ||
598 | + LIB3270_NOTIFY_ERROR, | ||
599 | + _( "Network error" ), | ||
600 | + _( "Select() failed when processing for events." ), | ||
601 | + "%s", | ||
602 | + strerror(errno)); | ||
603 | + } | ||
604 | + else | ||
605 | + { | ||
606 | + for (ip = inputs; ip != (input_t *) NULL; ip = ip_next) | ||
607 | + { | ||
608 | + ip_next = ip->next; | ||
609 | + | ||
610 | + if (((unsigned long)ip->condition & InputReadMask) && FD_ISSET(ip->source, &rfds)) | ||
611 | + { | ||
612 | + (*ip->proc)(ip->session); | ||
613 | + processed_any = True; | ||
614 | + if (inputs_changed) | ||
615 | + goto retry; | ||
616 | + } | ||
617 | + | ||
618 | + if (((unsigned long)ip->condition & InputWriteMask) && FD_ISSET(ip->source, &wfds)) | ||
619 | + { | ||
620 | + (*ip->proc)(ip->session); | ||
621 | + processed_any = True; | ||
622 | + if (inputs_changed) | ||
623 | + goto retry; | ||
624 | + } | ||
625 | + | ||
626 | + if (((unsigned long)ip->condition & InputExceptMask) && FD_ISSET(ip->source, &xfds)) | ||
627 | + { | ||
628 | + (*ip->proc)(ip->session); | ||
629 | + processed_any = True; | ||
630 | + if (inputs_changed) | ||
631 | + goto retry; | ||
632 | + } | ||
633 | + } | ||
634 | + } | ||
635 | + | ||
636 | +#endif | ||
637 | + | ||
497 | // See what's expired. | 638 | // See what's expired. |
498 | if (timeouts != TN) { | 639 | if (timeouts != TN) { |
499 | #if defined(_WIN32) | 640 | #if defined(_WIN32) |
@@ -580,6 +721,16 @@ void * AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | @@ -580,6 +721,16 @@ void * AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
580 | } | 721 | } |
581 | 722 | ||
582 | #ifdef WIN32 | 723 | #ifdef WIN32 |
724 | +void * AddOutput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
725 | +#else | ||
726 | +void * AddOutput(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
727 | +#endif // WIN32 | ||
728 | +{ | ||
729 | + CHECK_SESSION_HANDLE(session); | ||
730 | + return add_output(source,session,fn); | ||
731 | +} | ||
732 | + | ||
733 | +#ifdef WIN32 | ||
583 | void * AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | 734 | void * AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) |
584 | #else | 735 | #else |
585 | void * AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | 736 | void * AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) |
@@ -589,9 +740,9 @@ void * AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | @@ -589,9 +740,9 @@ void * AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
589 | return add_except(source,session,fn); | 740 | return add_except(source,session,fn); |
590 | } | 741 | } |
591 | 742 | ||
592 | -void RemoveInput(void * id) | 743 | +void RemoveSource(void * id) |
593 | { | 744 | { |
594 | - remove_input(id); | 745 | + remove_source(id); |
595 | } | 746 | } |
596 | 747 | ||
597 | void x_except_on(H3270 *h) | 748 | void x_except_on(H3270 *h) |
@@ -600,7 +751,7 @@ void x_except_on(H3270 *h) | @@ -600,7 +751,7 @@ void x_except_on(H3270 *h) | ||
600 | return; | 751 | return; |
601 | 752 | ||
602 | if(h->reading) | 753 | if(h->reading) |
603 | - RemoveInput(h->ns_read_id); | 754 | + RemoveSource(h->ns_read_id); |
604 | 755 | ||
605 | #ifdef WIN32 | 756 | #ifdef WIN32 |
606 | h->ns_exception_id = AddExcept(h->sockEvent, h, net_exception); | 757 | h->ns_exception_id = AddExcept(h->sockEvent, h, net_exception); |
@@ -621,13 +772,13 @@ void remove_input_calls(H3270 *session) | @@ -621,13 +772,13 @@ void remove_input_calls(H3270 *session) | ||
621 | { | 772 | { |
622 | if(session->ns_read_id) | 773 | if(session->ns_read_id) |
623 | { | 774 | { |
624 | - RemoveInput(session->ns_read_id); | 775 | + RemoveSource(session->ns_read_id); |
625 | session->ns_read_id = NULL; | 776 | session->ns_read_id = NULL; |
626 | session->reading = 0; | 777 | session->reading = 0; |
627 | } | 778 | } |
628 | if(session->ns_exception_id) | 779 | if(session->ns_exception_id) |
629 | { | 780 | { |
630 | - RemoveInput(session->ns_exception_id); | 781 | + RemoveSource(session->ns_exception_id); |
631 | session->ns_exception_id = NULL; | 782 | session->ns_exception_id = NULL; |
632 | session->excepting = 0; | 783 | session->excepting = 0; |
633 | } | 784 | } |
@@ -656,8 +807,11 @@ LIB3270_EXPORT int lib3270_register_handlers(const struct lib3270_callbacks *cbk | @@ -656,8 +807,11 @@ LIB3270_EXPORT int lib3270_register_handlers(const struct lib3270_callbacks *cbk | ||
656 | if(cbk->AddInput) | 807 | if(cbk->AddInput) |
657 | add_input = cbk->AddInput; | 808 | add_input = cbk->AddInput; |
658 | 809 | ||
659 | - if(cbk->RemoveInput) | ||
660 | - remove_input = cbk->RemoveInput; | 810 | + if(cbk->AddOutput) |
811 | + add_output = cbk->AddOutput; | ||
812 | + | ||
813 | + if(cbk->RemoveSource) | ||
814 | + remove_source = cbk->RemoveSource; | ||
661 | 815 | ||
662 | if(cbk->AddExcept) | 816 | if(cbk->AddExcept) |
663 | add_except = cbk->AddExcept; | 817 | add_except = cbk->AddExcept; |
sources.mak
@@ -34,6 +34,7 @@ TERMINAL_SOURCES = bounds.c ctlr.c util.c toggles.c screen.c selection.c kybd.c | @@ -34,6 +34,7 @@ TERMINAL_SOURCES = bounds.c ctlr.c util.c toggles.c screen.c selection.c kybd.c | ||
34 | 34 | ||
35 | # Network I/O Sources | 35 | # Network I/O Sources |
36 | NETWORK_SOURCES = iocalls.c proxy.c | 36 | NETWORK_SOURCES = iocalls.c proxy.c |
37 | +# connect.c | ||
37 | 38 | ||
38 | # Full library sources | 39 | # Full library sources |
39 | SOURCES = $(TERMINAL_SOURCES) $(NETWORK_SOURCES) ft.c ft_cut.c ft_dft.c glue.c resources.c \ | 40 | SOURCES = $(TERMINAL_SOURCES) $(NETWORK_SOURCES) ft.c ft_cut.c ft_dft.c glue.c resources.c \ |
telnet.c
@@ -2052,7 +2052,7 @@ void net_exception(H3270 *session) | @@ -2052,7 +2052,7 @@ void net_exception(H3270 *session) | ||
2052 | 2052 | ||
2053 | if(session->excepting) | 2053 | if(session->excepting) |
2054 | { | 2054 | { |
2055 | - RemoveInput(session->ns_exception_id); | 2055 | + RemoveSource(session->ns_exception_id); |
2056 | session->ns_exception_id = NULL; | 2056 | session->ns_exception_id = NULL; |
2057 | session->excepting = 0; | 2057 | session->excepting = 0; |
2058 | } | 2058 | } |
utilc.h
@@ -38,14 +38,16 @@ LIB3270_INTERNAL void xs_warning(const char *fmt, ...) printflike(1, 2); | @@ -38,14 +38,16 @@ LIB3270_INTERNAL void xs_warning(const char *fmt, ...) printflike(1, 2); | ||
38 | 38 | ||
39 | #ifdef WIN32 | 39 | #ifdef WIN32 |
40 | LIB3270_INTERNAL void * AddInput(HANDLE, H3270 *session, void (*fn)(H3270 *session)); | 40 | LIB3270_INTERNAL void * AddInput(HANDLE, H3270 *session, void (*fn)(H3270 *session)); |
41 | + LIB3270_INTERNAL void * AddOutput(HANDLE, H3270 *session, void (*fn)(H3270 *session)); | ||
41 | LIB3270_INTERNAL void * AddExcept(HANDLE, H3270 *session, void (*fn)(H3270 *session)); | 42 | LIB3270_INTERNAL void * AddExcept(HANDLE, H3270 *session, void (*fn)(H3270 *session)); |
42 | #else | 43 | #else |
43 | LIB3270_INTERNAL void * AddInput(int, H3270 *session, void (*fn)(H3270 *session)); | 44 | LIB3270_INTERNAL void * AddInput(int, H3270 *session, void (*fn)(H3270 *session)); |
45 | + LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *session)); | ||
44 | LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); | 46 | LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); |
45 | #endif // WIN32 | 47 | #endif // WIN32 |
46 | -LIB3270_INTERNAL void RemoveInput(void *); | ||
47 | -LIB3270_INTERNAL void * AddTimeOut(unsigned long msec, H3270 *session, void (*fn)(H3270 *session)); | ||
48 | -LIB3270_INTERNAL void RemoveTimeOut(void *cookie); | 48 | +LIB3270_INTERNAL void RemoveSource(void *); |
49 | +LIB3270_INTERNAL void * AddTimeOut(unsigned long msec, H3270 *session, void (*fn)(H3270 *session)); | ||
50 | +LIB3270_INTERNAL void RemoveTimeOut(void *cookie); | ||
49 | 51 | ||
50 | LIB3270_INTERNAL const char * KeysymToString(KeySym k); | 52 | LIB3270_INTERNAL const char * KeysymToString(KeySym k); |
51 | 53 |