Commit 54b2a73cfefec5ecc4bdad2cae88177c58ee8ab9
1 parent
1ae1823a
Exists in
master
and in
3 other branches
Removing warning on non-ssl code
Fixing multi-thread issues Removing unused code
Showing
3 changed files
with
11 additions
and
384 deletions
Show diff stats
src/lib3270/iocalls.c
... | ... | @@ -48,7 +48,6 @@ |
48 | 48 | #include <fcntl.h> |
49 | 49 | #endif |
50 | 50 | |
51 | - | |
52 | 51 | #define MILLION 1000000L |
53 | 52 | // |
54 | 53 | //#if defined(_WIN32) |
... | ... | @@ -444,6 +443,9 @@ LIB3270_EXPORT int lib3270_register_io_controller(const LIB3270_IO_CONTROLLER *c |
444 | 443 | if(cbk->ring_bell) |
445 | 444 | ring_bell = cbk->ring_bell; |
446 | 445 | |
446 | + if(cbk->run_task) | |
447 | + run_task = cbk->run_task; | |
448 | + | |
447 | 449 | return 0; |
448 | 450 | |
449 | 451 | } | ... | ... |
src/lib3270/properties.c
... | ... | @@ -292,6 +292,8 @@ |
292 | 292 | return lib3270_get_revision(); |
293 | 293 | } |
294 | 294 | |
295 | + #pragma GCC diagnostic push | |
296 | + #pragma GCC diagnostic ignored "-Wunused-parameter" | |
295 | 297 | const char * lib3270_get_crl_url(H3270 *hSession) |
296 | 298 | { |
297 | 299 | #ifdef SSL_ENABLE_CRL_CHECK |
... | ... | @@ -309,7 +311,10 @@ |
309 | 311 | return ""; |
310 | 312 | #endif |
311 | 313 | } |
314 | + #pragma GCC diagnostic pop | |
312 | 315 | |
316 | + #pragma GCC diagnostic push | |
317 | + #pragma GCC diagnostic ignored "-Wunused-parameter" | |
313 | 318 | int lib3270_set_crl_url(H3270 *hSession, const char *crl) |
314 | 319 | { |
315 | 320 | |
... | ... | @@ -337,6 +342,7 @@ |
337 | 342 | #endif // SSL_ENABLE_CRL_CHECK |
338 | 343 | |
339 | 344 | } |
345 | + #pragma GCC diagnostic pop | |
340 | 346 | |
341 | 347 | LIB3270_EXPORT const LIB3270_STRING_PROPERTY * lib3270_get_string_properties_list(void) |
342 | 348 | { | ... | ... |
src/lib3270/telnet.c
... | ... | @@ -361,387 +361,6 @@ void popup_a_sockerr(H3270 *hSession, char *fmt, ...) |
361 | 361 | |
362 | 362 | } |
363 | 363 | |
364 | -/* | |
365 | -#pragma pack(1) | |
366 | -struct connect_parm | |
367 | -{ | |
368 | - unsigned short sz; | |
369 | - int sockfd; | |
370 | - const struct sockaddr * addr; | |
371 | - socklen_t addrlen; | |
372 | - int err; | |
373 | -}; | |
374 | -#pragma pack() | |
375 | -*/ | |
376 | - | |
377 | -/* | |
378 | -static int do_connect_sock(H3270 *h, struct connect_parm *p) | |
379 | -{ | |
380 | -#ifdef WIN32 | |
381 | - | |
382 | - if(connect(p->sockfd, p->addr, p->addrlen) == -1) | |
383 | - p->err = socket_errno(); | |
384 | - else | |
385 | - p->err = 0; | |
386 | - | |
387 | -#else | |
388 | - | |
389 | - // Linux, use 120 seconds timeout | |
390 | - fcntl(p->sockfd, F_SETFL,fcntl(p->sockfd,F_GETFL,0)|O_NONBLOCK); | |
391 | - | |
392 | - errno = 0; | |
393 | - if(connect(p->sockfd, p->addr, p->addrlen)) | |
394 | - { | |
395 | - if( errno != EINPROGRESS ) | |
396 | - { | |
397 | - p->err = errno; | |
398 | - lib3270_write_log(h,"lib3270","Error %s on connect",strerror(errno)); | |
399 | - } | |
400 | - else | |
401 | - { | |
402 | - // Connection in progress, wait | |
403 | - fd_set wr; | |
404 | - struct timeval tm; | |
405 | - int err; | |
406 | - socklen_t len = sizeof(err); | |
407 | - | |
408 | - FD_ZERO(&wr); | |
409 | - FD_SET(p->sockfd, &wr); | |
410 | - memset(&tm,0,sizeof(tm)); | |
411 | - | |
412 | - tm.tv_sec = 120; // 2 minutes timeout | |
413 | - | |
414 | - switch(select(p->sockfd+1, NULL, &wr, NULL, &tm)) | |
415 | - { | |
416 | - case 0: | |
417 | - lib3270_write_log(h,"lib3270","Connect timeout"); | |
418 | - p->err = ETIMEDOUT; | |
419 | - break; | |
420 | - | |
421 | - case -1: | |
422 | - lib3270_write_log(h,"lib3270","Select error \"%s while connecting",strerror(errno)); | |
423 | - p->err = errno; | |
424 | - break; | |
425 | - | |
426 | - default: | |
427 | - | |
428 | - // Se o socket nao esta disponivel para gravacao o connect falhou | |
429 | - if(!FD_ISSET(p->sockfd,&wr)) | |
430 | - { | |
431 | - lib3270_write_log(h,"lib3270","Unexpected connection failure, the socket wasn't ready to write"); | |
432 | - p->err = ENOTCONN; | |
433 | - } | |
434 | - else if(getsockopt(p->sockfd, SOL_SOCKET, SO_ERROR, &err, &len) < 0) | |
435 | - { | |
436 | - lib3270_write_log(h,"lib3270","Connect error. Error \"%s\" when getting socket state",strerror(errno)); | |
437 | - p->err = ENOTCONN; | |
438 | - } | |
439 | - else if(err) | |
440 | - { | |
441 | - lib3270_write_log(h,"lib3270","Connection error \"%s\"",strerror(err)); | |
442 | - p->err = err; | |
443 | - } | |
444 | - else | |
445 | - { | |
446 | - lib3270_write_log(h,"lib3270","Connected to host"); | |
447 | - p->err = 0; | |
448 | - } | |
449 | - } | |
450 | - } | |
451 | - } | |
452 | - | |
453 | - fcntl(p->sockfd, F_SETFL,fcntl(p->sockfd,F_GETFL,0)&(~O_NONBLOCK)); | |
454 | -#endif // WIN32 | |
455 | - | |
456 | - return 0; | |
457 | -} | |
458 | -*/ | |
459 | - | |
460 | -/* | |
461 | -static int connect_sock(H3270 *hSession, int sockfd, const struct sockaddr *addr, socklen_t addrlen) | |
462 | -{ | |
463 | - struct connect_parm p = { sizeof(struct connect_parm), sockfd, addr, addrlen, -1 }; | |
464 | - | |
465 | - trace("%s: Connect begin sock=%d",__FUNCTION__,p.sockfd); | |
466 | - lib3270_call_thread((int (*)(H3270 *, void *)) do_connect_sock,hSession,&p); | |
467 | - trace("%s: Connect ends, rc=%d",__FUNCTION__,p.err); | |
468 | - | |
469 | - return p.err; | |
470 | -} | |
471 | -*/ | |
472 | - | |
473 | -/** | |
474 | - * Establish a telnet socket to the given host passed as an argument. | |
475 | - * | |
476 | - * Called only once and is responsible for setting up the telnet | |
477 | - * variables. | |
478 | - * | |
479 | - * @param session Handle to the session descriptor. | |
480 | - * | |
481 | - * @return 0 if ok, non zero if failed | |
482 | - */ /* | |
483 | -int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Boolean *resolving, Boolean *pending) | |
484 | -{ | |
485 | -// struct servent * sp; | |
486 | -// struct hostent * hp; | |
487 | - | |
488 | -#if defined(X3270_ANSI) | |
489 | - static int t_valid = 0; | |
490 | -#endif // X3270_ANSI | |
491 | - | |
492 | - char passthru_haddr[8]; | |
493 | - int passthru_len = 0; | |
494 | - unsigned short passthru_port = 0; | |
495 | - int on = 1; | |
496 | - int optval; | |
497 | - char errmsg[1024]; | |
498 | - int rc; | |
499 | -#if defined(OMTU) | |
500 | - int mtu = OMTU; | |
501 | -#endif | |
502 | - | |
503 | -#define close_fail { (void) SOCK_CLOSE(session->sock); session->sock = -1; return -1; } | |
504 | - | |
505 | - set_ssl_state(session,LIB3270_SSL_UNSECURE); | |
506 | - | |
507 | -#if defined(_WIN32) | |
508 | - sockstart(session); | |
509 | -#endif | |
510 | - | |
511 | -// if (session->netrbuf == (unsigned char *)NULL) | |
512 | -// session->netrbuf = (unsigned char *)lib3270_malloc(BUFSZ); | |
513 | - | |
514 | -#if defined(X3270_ANSI) | |
515 | - if (!t_valid) | |
516 | - { | |
517 | - vintr = parse_ctlchar("^C"); | |
518 | - vquit = parse_ctlchar("^\\"); | |
519 | - verase = parse_ctlchar("^H"); | |
520 | - vkill = parse_ctlchar("^U"); | |
521 | - veof = parse_ctlchar("^D"); | |
522 | - vwerase = parse_ctlchar("^W"); | |
523 | - vrprnt = parse_ctlchar("^R"); | |
524 | - vlnext = parse_ctlchar("^V"); | |
525 | - | |
526 | - t_valid = 1; | |
527 | - } | |
528 | -#endif | |
529 | - | |
530 | - *resolving = False; | |
531 | - *pending = False; | |
532 | - | |
533 | -// Replace(session->hostname, NewString(host)); | |
534 | - | |
535 | - // get the passthru host and port number | |
536 | - if (session->passthru_host) | |
537 | - { | |
538 | -#if defined(HAVE_GETADDRINFO) | |
539 | - | |
540 | - popup_an_error(session,"%s",_( "Unsupported passthru host session" ) ); | |
541 | - | |
542 | -#else | |
543 | - struct hostent * hp = NULL; | |
544 | - struct servent * sp = NULL; | |
545 | - const char * hn = CN; | |
546 | - | |
547 | - hn = getenv("INTERNET_HOST"); | |
548 | - | |
549 | - if (hn == CN) | |
550 | - hn = "internet-gateway"; | |
551 | - | |
552 | - hp = gethostbyname(hn); | |
553 | - if (hp == (struct hostent *) 0) | |
554 | - { | |
555 | - popup_an_error(session,_( "Unknown passthru host: %s" ), hn); | |
556 | - return -1; | |
557 | - } | |
558 | - memmove(passthru_haddr, hp->h_addr, hp->h_length); | |
559 | - passthru_len = hp->h_length; | |
560 | - | |
561 | - sp = getservbyname("telnet-passthru","tcp"); | |
562 | - if (sp != (struct servent *)NULL) | |
563 | - passthru_port = sp->s_port; | |
564 | - else | |
565 | - passthru_port = htons(3514); | |
566 | - | |
567 | -#endif // HAVE_GETADDRINFO | |
568 | - } | |
569 | - else if(session->proxy != CN && !session->proxy_type) | |
570 | - { | |
571 | - session->proxy_type = proxy_setup(session, &session->proxy_host, &session->proxy_portname); | |
572 | - | |
573 | - if (session->proxy_type > 0) | |
574 | - { | |
575 | - unsigned long lport; | |
576 | - char *ptr; | |
577 | - struct servent *sp; | |
578 | - | |
579 | - lport = strtoul(portname, &ptr, 0); | |
580 | - if (ptr == portname || *ptr != '\0' || lport == 0L || lport & ~0xffff) | |
581 | - { | |
582 | - if (!(sp = getservbyname(portname, "tcp"))) | |
583 | - { | |
584 | - popup_an_error(session, _( "Unknown port number or service: %s" ), portname); | |
585 | - return -1; | |
586 | - } | |
587 | - session->current_port = ntohs(sp->s_port); | |
588 | - } | |
589 | - else | |
590 | - { | |
591 | - session->current_port = (unsigned short)lport; | |
592 | - } | |
593 | - } | |
594 | - | |
595 | - if (session->proxy_type < 0) | |
596 | - return -1; | |
597 | - } | |
598 | - | |
599 | - // fill in the socket address of the given host | |
600 | - (void) memset((char *) &haddr, 0, sizeof(haddr)); | |
601 | - if (session->passthru_host) | |
602 | - { | |
603 | - haddr.sin.sin_family = AF_INET; | |
604 | - (void) memmove(&haddr.sin.sin_addr, passthru_haddr,passthru_len); | |
605 | - haddr.sin.sin_port = passthru_port; | |
606 | - ha_len = sizeof(struct sockaddr_in); | |
607 | - } | |
608 | - else if (session->proxy_type > 0) | |
609 | - { | |
610 | - if (resolve_host_and_port(session,session->proxy_host, session->proxy_portname,&session->proxy_port, &haddr.sa, &ha_len, errmsg,sizeof(errmsg)) < 0) | |
611 | - { | |
612 | - popup_an_error(session,"%s",errmsg); | |
613 | - return -1; | |
614 | - } | |
615 | - } | |
616 | - else | |
617 | - { | |
618 | - if (resolve_host_and_port(session,host, portname,&session->current_port, &haddr.sa, &ha_len,errmsg, sizeof(errmsg)) < 0) | |
619 | - { | |
620 | - popup_an_error(session,"%s",errmsg); | |
621 | - return -1; | |
622 | - } | |
623 | - } | |
624 | - | |
625 | - // create the socket | |
626 | - if((session->sock = socket(haddr.sa.sa_family, SOCK_STREAM, 0)) == -1) | |
627 | - { | |
628 | - popup_a_sockerr(session, N_( "socket" ) ); | |
629 | - return -1; | |
630 | - } | |
631 | - | |
632 | - // set options for inline out-of-band data and keepalives | |
633 | - if (setsockopt(session->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&on,sizeof(on)) < 0) | |
634 | - { | |
635 | - popup_a_sockerr(session, N_( "setsockopt(%s)" ), "SO_OOBINLINE"); | |
636 | - close_fail; | |
637 | - } | |
638 | - | |
639 | -#if defined(OMTU) | |
640 | - if (setsockopt(session->sock, SOL_SOCKET, SO_SNDBUF, (char *)&mtu,sizeof(mtu)) < 0) | |
641 | - { | |
642 | - popup_a_sockerr(session, N_( "setsockopt(%s)" ), "SO_SNDBUF"); | |
643 | - close_fail; | |
644 | - } | |
645 | -#endif | |
646 | - | |
647 | - // set the socket to be non-delaying during connect | |
648 | - if(non_blocking(session,False) < 0) | |
649 | - close_fail; | |
650 | - | |
651 | -#if !defined(_WIN32) | |
652 | - // don't share the socket with our children | |
653 | - (void) fcntl(session->sock, F_SETFD, 1); | |
654 | -#endif | |
655 | - | |
656 | - // init ssl | |
657 | -#if defined(HAVE_LIBSSL) | |
658 | - if (session->ssl_host) | |
659 | - ssl_init(session); | |
660 | -#endif | |
661 | - | |
662 | - // connect | |
663 | - status_connecting(session,1); | |
664 | - rc = connect_sock(session, session->sock, &haddr.sa,ha_len); | |
665 | - | |
666 | - if(!rc) | |
667 | - { | |
668 | - trace_dsn(session,"Connected.\n"); | |
669 | - | |
670 | - optval = lib3270_get_toggle(session,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; | |
671 | - | |
672 | - if (setsockopt(session->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) | |
673 | - { | |
674 | - popup_a_sockerr(session, N_( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" )); | |
675 | - close_fail; | |
676 | - } | |
677 | - else | |
678 | - { | |
679 | - trace_dsn(session,"Network keep-alive is %s\n",optval ? "enabled" : "disabled" ); | |
680 | - } | |
681 | - | |
682 | - if(net_connected(session)) | |
683 | - return -1; | |
684 | - | |
685 | - } | |
686 | - else | |
687 | - { | |
688 | - char *msg = xs_buffer( _( "Can't connect to %s" ), session->host.current); | |
689 | - | |
690 | - lib3270_popup_dialog( session, | |
691 | - LIB3270_NOTIFY_ERROR, | |
692 | - _( "Network error" ), | |
693 | - msg, | |
694 | - "%s",strerror(rc) ); | |
695 | - | |
696 | - lib3270_free(msg); | |
697 | - close_fail; | |
698 | - | |
699 | - } | |
700 | - | |
701 | - snprintf(session->full_model_name,LIB3270_FULL_MODEL_NAME_LENGTH,"IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num); | |
702 | - | |
703 | - | |
704 | - // all done | |
705 | -#if defined(_WIN32) | |
706 | - if(session->sockEvent == NULL) | |
707 | - { | |
708 | - char ename[256]; | |
709 | - | |
710 | - snprintf(ename, 255, "%s-%d", PACKAGE_NAME, getpid()); | |
711 | - | |
712 | - session->sockEvent = CreateEvent(NULL, TRUE, FALSE, ename); | |
713 | - if(session->sockEvent == NULL) | |
714 | - { | |
715 | - lib3270_popup_dialog( session, | |
716 | - LIB3270_NOTIFY_CRITICAL, | |
717 | - N_( "Network startup error" ), | |
718 | - N_( "Cannot create socket handle" ), | |
719 | - "%s", lib3270_win32_strerror(GetLastError()) ); | |
720 | - _exit(1); | |
721 | - } | |
722 | - } | |
723 | - | |
724 | - if (WSAEventSelect(session->sock, session->sockEvent, FD_READ | FD_CONNECT | FD_CLOSE) != 0) | |
725 | - { | |
726 | - lib3270_popup_dialog( session, | |
727 | - LIB3270_NOTIFY_CRITICAL, | |
728 | - N_( "Network startup error" ), | |
729 | - N_( "WSAEventSelect failed" ), | |
730 | - "%s", lib3270_win32_strerror(GetLastError()) ); | |
731 | - _exit(1); | |
732 | - } | |
733 | - | |
734 | -// trace("Socket: %d Event: %ld",session->sock,(unsigned long) session->sockEvent); | |
735 | - | |
736 | -#endif // WIN32 | |
737 | - | |
738 | - non_blocking(session,1); | |
739 | - | |
740 | - return 0; | |
741 | -} | |
742 | -#undef close_fail | |
743 | -*/ | |
744 | - | |
745 | 364 | /* Set up the LU list. */ |
746 | 365 | static void setup_lus(H3270 *hSession) |
747 | 366 | { |
... | ... | @@ -884,7 +503,7 @@ LIB3270_EXPORT void lib3270_setup_session(H3270 *hSession) |
884 | 503 | } |
885 | 504 | |
886 | 505 | /** |
887 | - * Connection_complete. | |
506 | + * @brief Connection_complete. | |
888 | 507 | * |
889 | 508 | * The connection appears to be complete (output is possible or input |
890 | 509 | * appeared ready but recv() returned EWOULDBLOCK). Complete the |
... | ... | @@ -989,7 +608,7 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned |
989 | 608 | } |
990 | 609 | |
991 | 610 | /** |
992 | - * net_input. | |
611 | + * @brief Called by the toolkit whenever there is input available on the socket. | |
993 | 612 | * |
994 | 613 | * Called by the toolkit whenever there is input available on the |
995 | 614 | * socket. Reads the data, processes the special telnet commands | ... | ... |