Commit 01edcda07888b72a5072e4c67b8109525c0bcb10

Authored by perry.werneck@gmail.com
1 parent 7a18fcce

Removendo campos sem uso, incluindo suporte a auto-reconnect, iniciando reinclus…

…ao de movimentação da seleção por mouse
api.h
... ... @@ -379,7 +379,7 @@
379 379  
380 380 /* Get connection info */
381 381 #define get_connected_lu(h) lib3270_get_luname(h)
382   - #define get_current_host(h) lib3270_get_host(h)
  382 +// #define get_current_host(h) lib3270_get_host(h)
383 383  
384 384 LOCAL_EXTERN SCRIPT_STATE status_script(SCRIPT_STATE state);
385 385  
... ...
globals.h
... ... @@ -212,9 +212,11 @@ LIB3270_INTERNAL char *hostname;
212 212  
213 213 #endif /*]*/
214 214  
215   -#if defined(LOCAL_PROCESS) /*[*/
  215 +/*
  216 +#if defined(LOCAL_PROCESS)
216 217 LIB3270_INTERNAL Boolean local_process;
217   -#endif /*]*/
  218 +#endif
  219 +*/
218 220  
219 221 // LIB3270_INTERNAL int maxCOLS;
220 222 // LIB3270_INTERNAL int maxROWS;
... ...
host.c
... ... @@ -194,8 +194,9 @@ hostfile_lookup(const char *name, char **hostname, char **loginstring)
194 194 }
195 195 */
196 196  
197   -#if defined(LOCAL_PROCESS) /*[*/
198   -/* Recognize and translate "-e" options. */
  197 +/*
  198 +#if defined(LOCAL_PROCESS)
  199 +// Recognize and translate "-e" options.
199 200 static const char *
200 201 parse_localprocess(const char *s)
201 202 {
... ... @@ -216,7 +217,8 @@ parse_localprocess(const char *s)
216 217 }
217 218 return CN;
218 219 }
219   -#endif /*]*/
  220 +#endif
  221 +*/
220 222  
221 223 /*
222 224 * Strip qualifiers from a hostname.
... ... @@ -480,16 +482,18 @@ static int do_connect(H3270 *hSession, const char *n)
480 482 Boolean resolving;
481 483 Boolean pending;
482 484 static Boolean ansi_host;
483   - const char *localprocess_cmd = NULL;
  485 +// const char *localprocess_cmd = NULL;
484 486 Boolean has_colons = False;
485 487  
486   - if (CONNECTED || hSession->auto_reconnect_inprogress)
487   - return 0;
  488 + if (lib3270_connected(hSession) || hSession->auto_reconnect_inprogress)
  489 + return EBUSY;
488 490  
489 491 /* Skip leading blanks. */
490 492 while (*n == ' ')
491 493 n++;
492   - if (!*n) {
  494 +
  495 + if (!*n)
  496 + {
493 497 popup_an_error(hSession,_( "Invalid (empty) hostname" ));
494 498 return -1;
495 499 }
... ... @@ -503,19 +507,16 @@ static int do_connect(H3270 *hSession, const char *n)
503 507 *s-- = '\0';
504 508  
505 509 /* Remember this hostname, as the last hostname we connected to. */
506   - Replace(hSession->reconnect_host, NewString(nb));
  510 + lib3270_set_host(hSession,nb);
507 511  
508   -// #if defined(X3270_DISPLAY)
509   -// /* Remember this hostname in the recent connection list and file. */
510   -// save_recent(nb);
511   -// #endif
512   -
513   -#if defined(LOCAL_PROCESS) /*[*/
  512 +/*
  513 +#if defined(LOCAL_PROCESS)
514 514 if ((localprocess_cmd = parse_localprocess(nb)) != CN) {
515 515 chost = localprocess_cmd;
516 516 port = appres.port;
517 517 } else
518   -#endif /*]*/
  518 +#endif
  519 +*/
519 520 {
520 521 Boolean needed;
521 522  
... ... @@ -541,12 +542,12 @@ static int do_connect(H3270 *hSession, const char *n)
541 542 * full_current_host is the entire string, for use in reconnecting
542 543 */
543 544 if (n != hSession->full_current_host)
544   - {
545   - Replace(hSession->full_current_host, NewString(n));
546   - }
  545 + lib3270_set_host(hSession,n);
547 546  
548 547 Replace(hSession->current_host, CN);
549 548  
  549 +/*
  550 +
550 551 if (localprocess_cmd != CN) {
551 552 if (hSession->full_current_host[strlen(OptLocalProcess)] != '\0')
552 553 hSession->current_host = NewString(hSession->full_current_host + strlen(OptLocalProcess) + 1);
... ... @@ -555,6 +556,7 @@ static int do_connect(H3270 *hSession, const char *n)
555 556 } else {
556 557 hSession->current_host = s;
557 558 }
  559 +*/
558 560  
559 561 has_colons = (strchr(chost, ':') != NULL);
560 562  
... ... @@ -569,7 +571,7 @@ static int do_connect(H3270 *hSession, const char *n)
569 571  
570 572 /* Attempt contact. */
571 573 hSession->ever_3270 = False;
572   - hSession->net_sock = net_connect(hSession, chost, port, localprocess_cmd != CN, &resolving,&pending);
  574 + hSession->net_sock = net_connect(hSession, chost, port, 0, &resolving,&pending);
573 575  
574 576 if (hSession->net_sock < 0 && !resolving)
575 577 {
... ... @@ -612,6 +614,16 @@ static int do_connect(H3270 *hSession, const char *n)
612 614 return 0;
613 615 }
614 616  
  617 +/**
  618 + * Connect to selected host.
  619 + *
  620 + * @param h Session handle.
  621 + * @param n Hostname (null to reconnect to the last one;
  622 + * @param wait Wait for connection ok before return.
  623 + *
  624 + * @return 0 if the connection was ok, non zero on error.
  625 + *
  626 + */
615 627 int lib3270_connect(H3270 *h, const char *n, int wait)
616 628 {
617 629 int rc;
... ... @@ -627,7 +639,11 @@ int lib3270_connect(H3270 *h, const char *n, int wait)
627 639 return EBUSY;
628 640  
629 641 if(!n)
630   - return ENOENT;
  642 + {
  643 + n = h->full_current_host;
  644 + if(!n)
  645 + return EINVAL;
  646 + }
631 647  
632 648 rc = do_connect(h,n);
633 649 if(rc)
... ... @@ -654,7 +670,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait)
654 670 */
655 671 static void try_reconnect(H3270 *session)
656 672 {
657   - WriteLog("3270","Starting auto-reconnect (Host: %s)",session->reconnect_host ? session->reconnect_host : "-");
  673 + WriteLog("3270","Starting auto-reconnect (Host: %s)",session->full_current_host ? session->full_current_host : "-");
658 674 session->auto_reconnect_inprogress = False;
659 675 lib3270_reconnect(session,0);
660 676 }
... ... @@ -758,6 +774,29 @@ void lib3270_st_changed(H3270 *h, int tx, int mode)
758 774 }
759 775 }
760 776  
  777 +LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n)
  778 +{
  779 + CHECK_SESSION_HANDLE(h);
  780 +
  781 + Trace("%s: %p",__FUNCTION__,n);
  782 +
  783 + if(!n)
  784 + return NULL;
  785 +
  786 + if(h->full_current_host)
  787 + free(h->full_current_host);
  788 +
  789 + h->full_current_host = strdup(n);
  790 +
  791 + return h->full_current_host;
  792 +}
  793 +
  794 +LIB3270_EXPORT const char * lib3270_get_host(H3270 *h)
  795 +{
  796 + CHECK_SESSION_HANDLE(h);
  797 + return h->full_current_host;
  798 +}
  799 +
761 800 LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait)
762 801 {
763 802 int rc;
... ... @@ -767,13 +806,13 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait)
767 806 if (CONNECTED || HALF_CONNECTED)
768 807 return EBUSY;
769 808  
770   - if (h->current_host == CN)
771   - return ENOENT;
  809 + if (h->full_current_host == CN)
  810 + return EINVAL;
772 811  
773 812 if (h->auto_reconnect_inprogress)
774 813 return EBUSY;
775 814  
776   - rc = lib3270_connect(h,h->reconnect_host,wait);
  815 + rc = lib3270_connect(h,h->full_current_host,wait);
777 816  
778 817 if(rc)
779 818 {
... ... @@ -790,8 +829,3 @@ LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h)
790 829 return h->connected_lu;
791 830 }
792 831  
793   -LIB3270_EXPORT const char * lib3270_get_host(H3270 *h)
794   -{
795   - CHECK_SESSION_HANDLE(h);
796   - return h->current_host;
797   -}
... ...
selection.c
... ... @@ -71,6 +71,20 @@ static void update_selected_rectangle(H3270 *session)
71 71 p[1].row = (end/session->cols);
72 72 p[1].col = (end%session->cols);
73 73  
  74 + if(p[0].row > p[1].row)
  75 + {
  76 + int swp = p[0].row;
  77 + p[0].row = p[1].row;
  78 + p[1].row = swp;
  79 + }
  80 +
  81 + if(p[0].col > p[1].col)
  82 + {
  83 + int swp = p[0].col;
  84 + p[0].col = p[1].col;
  85 + p[1].col = swp;
  86 + }
  87 +
74 88 // First remove unselected areas
75 89 baddr = 0;
76 90 for(row=0;row < session->rows;row++)
... ... @@ -214,6 +228,35 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr)
214 228  
215 229 }
216 230  
  231 +LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int baddr)
  232 +{
  233 + int row,col;
  234 + unsigned char rc = 0;
  235 +
  236 + CHECK_SESSION_HANDLE(hSession);
  237 +
  238 + if(!(lib3270_connected(hSession) && (hSession->text[baddr].attr & LIB3270_ATTR_SELECTED)))
  239 + return rc;
  240 +
  241 + row = baddr / hSession->cols;
  242 + col = baddr % hSession->cols;
  243 + rc |= 0x01;
  244 +
  245 + if( (col == 0) || !(hSession->text[baddr-1].attr & LIB3270_ATTR_SELECTED) )
  246 + rc |= 0x02;
  247 +
  248 + if( (row == 0) || !(hSession->text[baddr-hSession->cols].attr & LIB3270_ATTR_SELECTED) )
  249 + rc |= 0x04;
  250 +
  251 + if( (col == hSession->cols) || !(hSession->text[baddr+1].attr & LIB3270_ATTR_SELECTED) )
  252 + rc |= 0x08;
  253 +
  254 + if( (row == hSession->rows) || !(hSession->text[baddr+hSession->cols].attr & LIB3270_ATTR_SELECTED) )
  255 + rc |= 0x10;
  256 +
  257 + return rc;
  258 +}
  259 +
217 260 LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr)
218 261 {
219 262 int pos, len;
... ... @@ -373,6 +416,8 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession)
373 416  
374 417 LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *end)
375 418 {
  419 + CHECK_SESSION_HANDLE(hSession);
  420 +
376 421 if(!hSession->selected || hSession->select.begin == hSession->select.end)
377 422 return -1;
378 423  
... ... @@ -390,6 +435,12 @@ LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *e
390 435 return 0;
391 436 }
392 437  
  438 +LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to)
  439 +{
  440 +
  441 +
  442 + return from;
  443 +}
393 444  
394 445 LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir)
395 446 {
... ...
telnet.c
... ... @@ -111,6 +111,7 @@ int ns_rsent;
111 111 unsigned char *obuf; /* 3270 output buffer */
112 112 unsigned char *obptr = (unsigned char *) NULL;
113 113 int linemode = 1;
  114 +
114 115 /*
115 116 #if defined(LOCAL_PROCESS)
116 117 Boolean local_process = False;
... ... @@ -1010,10 +1011,11 @@ void net_input(H3270 *session)
1010 1011  
1011 1012 ns_brcvd += nr;
1012 1013 for (cp = netrbuf; cp < (netrbuf + nr); cp++) {
1013   -#if defined(LOCAL_PROCESS) /*[*/
  1014 +/*
  1015 +#if defined(LOCAL_PROCESS)
1014 1016 if (local_process) {
1015   - /* More to do here, probably. */
1016   - if (IN_NEITHER) { /* now can assume ANSI mode */
  1017 + // More to do here, probably.
  1018 + if (IN_NEITHER) { // now can assume ANSI mode
1017 1019 host_in3270(CONNECTED_ANSI);
1018 1020 hisopts[TELOPT_ECHO] = 1;
1019 1021 check_linemode(False);
... ... @@ -1023,7 +1025,8 @@ void net_input(H3270 *session)
1023 1025 }
1024 1026 ansi_process((unsigned int) *cp);
1025 1027 } else {
1026   -#endif /*]*/
  1028 +#endif
  1029 +*/
1027 1030 if (telnet_fsm(*cp)) {
1028 1031 (void) ctlr_dbcs_postprocess();
1029 1032 host_disconnect(&h3270,True);
... ... @@ -1891,11 +1894,13 @@ process_eor(void)
1891 1894 */
1892 1895 void net_exception(H3270 *session)
1893 1896 {
1894   -#if defined(LOCAL_PROCESS) /*[*/
  1897 +/*
  1898 +#if defined(LOCAL_PROCESS)
1895 1899 if (local_process) {
1896 1900 trace_dsn("RCVD exception\n");
1897 1901 } else
1898   -#endif /*[*/
  1902 +#endif
  1903 +*/
1899 1904 {
1900 1905 trace_dsn("RCVD urgent data indication\n");
1901 1906 if (!syncing) {
... ... @@ -1953,11 +1958,14 @@ net_rawout(unsigned const char *buf, int len)
1953 1958 nw = SSL_write(ssl_con, (const char *) buf, n2w);
1954 1959 else
1955 1960 #endif /*]*/
1956   -#if defined(LOCAL_PROCESS) /*[*/
  1961 +
  1962 +/*
  1963 +#if defined(LOCAL_PROCESS)
1957 1964 if (local_process)
1958 1965 nw = write(sock, (const char *) buf, n2w);
1959 1966 else
1960   -#endif /*]*/
  1967 +#endif
  1968 +*/
1961 1969 nw = send(h3270.sock, (const char *) buf, n2w, 0);
1962 1970 if (nw < 0) {
1963 1971 #if defined(HAVE_LIBSSL) /*[*/
... ... @@ -2791,9 +2799,11 @@ void
2791 2799 net_sendc(char c)
2792 2800 {
2793 2801 if (c == '\r' && !linemode
2794   -#if defined(LOCAL_PROCESS) /*[*/
  2802 +/*
  2803 +#if defined(LOCAL_PROCESS)
2795 2804 && !local_process
2796   -#endif /*]*/
  2805 +#endif
  2806 +*/
2797 2807 ) {
2798 2808 /* CR must be quoted */
2799 2809 net_cookout("\r\0", 2);
... ...