Commit 4a2bbf155688742e2155e7987c7bb5116673b5c7
1 parent
243e4662
Exists in
master
and in
3 other branches
Implementando novo mecanismo de conexao
Showing
4 changed files
with
26 additions
and
30 deletions
Show diff stats
| @@ -324,8 +324,8 @@ | @@ -324,8 +324,8 @@ | ||
| 324 | 324 | ||
| 325 | #include <lib3270/actions.h> | 325 | #include <lib3270/actions.h> |
| 326 | 326 | ||
| 327 | - #define host_connect(n,wait) lib3270_connect(NULL,n,wait) | ||
| 328 | - #define host_reconnect(w) lib3270_reconnect(NULL,w) | 327 | + // #define host_connect(n,wait) lib3270_connect(NULL,n,wait) |
| 328 | + // #define host_reconnect(w) lib3270_reconnect(NULL,w) | ||
| 329 | 329 | ||
| 330 | 330 | ||
| 331 | #ifdef __cplusplus | 331 | #ifdef __cplusplus |
connect.c
| @@ -201,7 +201,7 @@ static void net_connected(H3270 *hSession) | @@ -201,7 +201,7 @@ static void net_connected(H3270 *hSession) | ||
| 201 | sockstart(hSession); | 201 | sockstart(hSession); |
| 202 | #endif | 202 | #endif |
| 203 | 203 | ||
| 204 | - hSession->host.opt = opt; | 204 | + hSession->host.opt = opt & ~LIB3270_CONNECT_OPTION_WAIT; |
| 205 | Replace(hSession->host.current,strdup(hostname)); | 205 | Replace(hSession->host.current,strdup(hostname)); |
| 206 | 206 | ||
| 207 | Replace(hSession->host.full, | 207 | Replace(hSession->host.full, |
host.c
| @@ -457,17 +457,7 @@ static int do_connect(H3270 *hSession) | @@ -457,17 +457,7 @@ static int do_connect(H3270 *hSession) | ||
| 457 | return 0; | 457 | return 0; |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | -/** | ||
| 461 | - * Connect to selected host. | ||
| 462 | - * | ||
| 463 | - * @param h Session handle. | ||
| 464 | - * @param n Hostname (null to reconnect to the last one; | ||
| 465 | - * @param wait Wait for connection ok before return. | ||
| 466 | - * | ||
| 467 | - * @return 0 if the connection was ok, non zero on error. | ||
| 468 | - * | ||
| 469 | - */ | ||
| 470 | -int lib3270_connect(H3270 *hSession, const char *n, int wait) | 460 | +int lib3270_connect(H3270 *hSession, int wait) |
| 471 | { | 461 | { |
| 472 | int rc; | 462 | int rc; |
| 473 | 463 | ||
| @@ -475,18 +465,18 @@ int lib3270_connect(H3270 *hSession, const char *n, int wait) | @@ -475,18 +465,18 @@ int lib3270_connect(H3270 *hSession, const char *n, int wait) | ||
| 475 | 465 | ||
| 476 | lib3270_main_iterate(hSession,0); | 466 | lib3270_main_iterate(hSession,0); |
| 477 | 467 | ||
| 478 | - if(hSession->auto_reconnect_inprogress) | ||
| 479 | - return EAGAIN; | ||
| 480 | - | ||
| 481 | - if(PCONNECTED) | 468 | + if (CONNECTED || HALF_CONNECTED) |
| 482 | return EBUSY; | 469 | return EBUSY; |
| 483 | 470 | ||
| 484 | - if(n) | ||
| 485 | - lib3270_set_host(hSession,n); | ||
| 486 | - | ||
| 487 | if(!hSession->host.full) | 471 | if(!hSession->host.full) |
| 488 | return EINVAL; | 472 | return EINVAL; |
| 489 | 473 | ||
| 474 | + if (hSession->auto_reconnect_inprogress) | ||
| 475 | + return EBUSY; | ||
| 476 | + | ||
| 477 | + if(PCONNECTED) | ||
| 478 | + return EBUSY; | ||
| 479 | + | ||
| 490 | rc = do_connect(hSession); | 480 | rc = do_connect(hSession); |
| 491 | if(rc) | 481 | if(rc) |
| 492 | return rc; | 482 | return rc; |
| @@ -514,7 +504,7 @@ static void try_reconnect(H3270 *session) | @@ -514,7 +504,7 @@ static void try_reconnect(H3270 *session) | ||
| 514 | { | 504 | { |
| 515 | lib3270_write_log(session,"3270","Starting auto-reconnect (Host: %s)",session->host.full ? session->host.full : "-"); | 505 | lib3270_write_log(session,"3270","Starting auto-reconnect (Host: %s)",session->host.full ? session->host.full : "-"); |
| 516 | session->auto_reconnect_inprogress = 0; | 506 | session->auto_reconnect_inprogress = 0; |
| 517 | - lib3270_reconnect(session,0); | 507 | + lib3270_connect(session,0); |
| 518 | } | 508 | } |
| 519 | 509 | ||
| 520 | LIB3270_EXPORT int lib3270_disconnect(H3270 *h) | 510 | LIB3270_EXPORT int lib3270_disconnect(H3270 *h) |
| @@ -689,8 +679,6 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) | @@ -689,8 +679,6 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) | ||
| 689 | } | 679 | } |
| 690 | } | 680 | } |
| 691 | 681 | ||
| 692 | - trace("SRVC=[%s]",srvc); | ||
| 693 | - | ||
| 694 | if(!*hostname) | 682 | if(!*hostname) |
| 695 | return h->host.current; | 683 | return h->host.current; |
| 696 | 684 | ||
| @@ -709,18 +697,22 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) | @@ -709,18 +697,22 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) | ||
| 709 | query = ""; | 697 | query = ""; |
| 710 | } | 698 | } |
| 711 | 699 | ||
| 700 | + trace("SRVC=[%s]",srvc); | ||
| 701 | + | ||
| 712 | Replace(h->host.current,strdup(hostname)); | 702 | Replace(h->host.current,strdup(hostname)); |
| 713 | Replace(h->host.srvc,strdup(srvc)); | 703 | Replace(h->host.srvc,strdup(srvc)); |
| 714 | Replace(h->host.full, | 704 | Replace(h->host.full, |
| 715 | lib3270_strdup_printf( | 705 | lib3270_strdup_printf( |
| 716 | "%s%s:%s%s%s", | 706 | "%s%s:%s%s%s", |
| 717 | - h->host.opt&LIB3270_CONNECT_OPTION_SSL ? "tn3270s://" : "", | 707 | + h->host.opt&LIB3270_CONNECT_OPTION_SSL ? "tn3270s://" : "tn3270://", |
| 718 | hostname, | 708 | hostname, |
| 719 | srvc, | 709 | srvc, |
| 720 | *query ? "?" : "", | 710 | *query ? "?" : "", |
| 721 | query | 711 | query |
| 722 | )); | 712 | )); |
| 723 | 713 | ||
| 714 | + trace("hosturl=[%s]",h->host.full); | ||
| 715 | + | ||
| 724 | free(str); | 716 | free(str); |
| 725 | } | 717 | } |
| 726 | 718 | ||
| @@ -733,6 +725,7 @@ LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) | @@ -733,6 +725,7 @@ LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) | ||
| 733 | return h->host.current; | 725 | return h->host.current; |
| 734 | } | 726 | } |
| 735 | 727 | ||
| 728 | +/* | ||
| 736 | LIB3270_EXPORT int lib3270_reconnect(H3270 *hSession,int wait) | 729 | LIB3270_EXPORT int lib3270_reconnect(H3270 *hSession,int wait) |
| 737 | { | 730 | { |
| 738 | int rc; | 731 | int rc; |
| @@ -742,13 +735,13 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *hSession,int wait) | @@ -742,13 +735,13 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *hSession,int wait) | ||
| 742 | if (CONNECTED || HALF_CONNECTED) | 735 | if (CONNECTED || HALF_CONNECTED) |
| 743 | return EBUSY; | 736 | return EBUSY; |
| 744 | 737 | ||
| 745 | - if (hSession->host.full == CN) | 738 | + if (!hSession->host.full) |
| 746 | return EINVAL; | 739 | return EINVAL; |
| 747 | 740 | ||
| 748 | if (hSession->auto_reconnect_inprogress) | 741 | if (hSession->auto_reconnect_inprogress) |
| 749 | return EBUSY; | 742 | return EBUSY; |
| 750 | 743 | ||
| 751 | - rc = lib3270_connect(hSession,hSession->host.full,wait); | 744 | + rc = lib3270_connect(hSession,wait); |
| 752 | 745 | ||
| 753 | if(rc) | 746 | if(rc) |
| 754 | { | 747 | { |
| @@ -758,6 +751,7 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *hSession,int wait) | @@ -758,6 +751,7 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *hSession,int wait) | ||
| 758 | 751 | ||
| 759 | return 0; | 752 | return 0; |
| 760 | } | 753 | } |
| 754 | +*/ | ||
| 761 | 755 | ||
| 762 | LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h) | 756 | LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h) |
| 763 | { | 757 | { |
macros.c
| @@ -254,15 +254,17 @@ | @@ -254,15 +254,17 @@ | ||
| 254 | switch(argc) | 254 | switch(argc) |
| 255 | { | 255 | { |
| 256 | case 1: | 256 | case 1: |
| 257 | - rc = lib3270_reconnect(hSession,0); | 257 | + rc = lib3270_connect(hSession,0); |
| 258 | break; | 258 | break; |
| 259 | 259 | ||
| 260 | case 2: | 260 | case 2: |
| 261 | - rc = lib3270_connect(hSession,argv[1],0); | 261 | + lib3270_set_host(hSession,argv[1]); |
| 262 | + rc = lib3270_connect(hSession,0); | ||
| 262 | break; | 263 | break; |
| 263 | 264 | ||
| 264 | case 3: | 265 | case 3: |
| 265 | - rc = lib3270_connect(hSession,argv[1],atoi(argv[2])); | 266 | + lib3270_set_host(hSession,argv[1]); |
| 267 | + rc = lib3270_connect(hSession,atoi(argv[2])); | ||
| 266 | break; | 268 | break; |
| 267 | 269 | ||
| 268 | default: | 270 | default: |