Commit 311e84700a55c057695759eca810188fcd3c9624

Authored by perry.werneck@gmail.com
1 parent 70142987

Limpando código, mais ajustes para multi-sessao

@@ -1666,7 +1666,7 @@ ansi_scroll(void) @@ -1666,7 +1666,7 @@ ansi_scroll(void)
1666 { 1666 {
1667 // if (!h3270.is_altbuffer) 1667 // if (!h3270.is_altbuffer)
1668 // scroll_save(1, False); 1668 // scroll_save(1, False);
1669 - ctlr_scroll(); 1669 + ctlr_scroll(&h3270);
1670 return; 1670 return;
1671 } 1671 }
1672 1672
@@ -89,7 +89,7 @@ Boolean dbcs = False; @@ -89,7 +89,7 @@ Boolean dbcs = False;
89 89
90 /* Statics */ 90 /* Statics */
91 // static struct ea *aea_buf; /* alternate 3270 extended attribute buffer */ 91 // static struct ea *aea_buf; /* alternate 3270 extended attribute buffer */
92 -static unsigned char *zero_buf; // empty buffer, for area clears 92 +// static unsigned char *zero_buf; // empty buffer, for area clears
93 static void set_formatted(H3270 *session); 93 static void set_formatted(H3270 *session);
94 static void ctlr_blanks(H3270 *session); 94 static void ctlr_blanks(H3270 *session);
95 // static Boolean trace_primed = False; 95 // static Boolean trace_primed = False;
@@ -105,7 +105,7 @@ static void ctlr_connect(H3270 *session, int ignored, void *dunno); @@ -105,7 +105,7 @@ static void ctlr_connect(H3270 *session, int ignored, void *dunno);
105 // static int sscp_start; 105 // static int sscp_start;
106 static void ticking_stop(H3270 *session); 106 static void ticking_stop(H3270 *session);
107 static void ctlr_add_ic(int baddr, unsigned char ic); 107 static void ctlr_add_ic(int baddr, unsigned char ic);
108 -static void changed(H3270 *session, int bstart, int bend); 108 +// static void changed(H3270 *session, int bstart, int bend);
109 109
110 /* 110 /*
111 * code_table is used to translate buffer addresses and attributes to the 3270 111 * code_table is used to translate buffer addresses and attributes to the 3270
@@ -177,7 +177,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask) @@ -177,7 +177,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask)
177 177
178 session->text = lib3270_calloc(sizeof(struct lib3270_text),sz,session->text); 178 session->text = lib3270_calloc(sizeof(struct lib3270_text),sz,session->text);
179 179
180 - Replace(zero_buf, (unsigned char *)Calloc(sizeof(struct ea),sz)); 180 + Replace(session->zero_buf, (unsigned char *)Calloc(sizeof(struct ea),sz));
181 181
182 session->cursor_addr = 0; 182 session->cursor_addr = 0;
183 session->buffer_addr = 0; 183 session->buffer_addr = 0;
@@ -2543,7 +2543,7 @@ ctlr_bcopy(int baddr_from, int baddr_to, int count, int move_ea) @@ -2543,7 +2543,7 @@ ctlr_bcopy(int baddr_from, int baddr_to, int count, int move_ea)
2543 */ 2543 */
2544 void ctlr_aclear(int baddr, int count, int clear_ea) 2544 void ctlr_aclear(int baddr, int count, int clear_ea)
2545 { 2545 {
2546 - if (memcmp((char *) &h3270.ea_buf[baddr], (char *) zero_buf, 2546 + if (memcmp((char *) &h3270.ea_buf[baddr], (char *) h3270.zero_buf,
2547 count * sizeof(struct ea))) { 2547 count * sizeof(struct ea))) {
2548 (void) memset((char *) &h3270.ea_buf[baddr], 0, 2548 (void) memset((char *) &h3270.ea_buf[baddr], 0,
2549 count * sizeof(struct ea)); 2549 count * sizeof(struct ea));
@@ -2558,9 +2558,9 @@ void ctlr_aclear(int baddr, int count, int clear_ea) @@ -2558,9 +2558,9 @@ void ctlr_aclear(int baddr, int count, int clear_ea)
2558 * This could be accomplished with ctlr_bcopy() and ctlr_aclear(), but this 2558 * This could be accomplished with ctlr_bcopy() and ctlr_aclear(), but this
2559 * operation is common enough to warrant a separate path. 2559 * operation is common enough to warrant a separate path.
2560 */ 2560 */
2561 -void ctlr_scroll(void) 2561 +void ctlr_scroll(H3270 *hSession)
2562 { 2562 {
2563 - int qty = (h3270.rows - 1) * h3270.cols; 2563 + int qty = (hSession->rows - 1) * hSession->cols;
2564 2564
2565 /* Make sure nothing is selected. (later this can be fixed) */ 2565 /* Make sure nothing is selected. (later this can be fixed) */
2566 // unselect(0, ROWS*COLS); 2566 // unselect(0, ROWS*COLS);
@@ -2568,12 +2568,12 @@ void ctlr_scroll(void) @@ -2568,12 +2568,12 @@ void ctlr_scroll(void)
2568 /* Synchronize pending changes prior to this. */ 2568 /* Synchronize pending changes prior to this. */
2569 2569
2570 /* Move ea_buf. */ 2570 /* Move ea_buf. */
2571 - (void) memmove(&h3270.ea_buf[0], &h3270.ea_buf[h3270.cols],qty * sizeof(struct ea)); 2571 + (void) memmove(&hSession->ea_buf[0], &hSession->ea_buf[h3270.cols],qty * sizeof(struct ea));
2572 2572
2573 /* Clear the last line. */ 2573 /* Clear the last line. */
2574 - (void) memset((char *) &h3270.ea_buf[qty], 0, h3270.cols * sizeof(struct ea)); 2574 + (void) memset((char *) &hSession->ea_buf[qty], 0, hSession->cols * sizeof(struct ea));
2575 2575
2576 - h3270.display(&h3270); 2576 + hSession->display(hSession);
2577 2577
2578 } 2578 }
2579 #endif /*]*/ 2579 #endif /*]*/
@@ -2581,8 +2581,9 @@ void ctlr_scroll(void) @@ -2581,8 +2581,9 @@ void ctlr_scroll(void)
2581 /* 2581 /*
2582 * Note that a particular region of the screen has changed. 2582 * Note that a particular region of the screen has changed.
2583 */ 2583 */
2584 -void changed(H3270 *session, int bstart, int bend)  
2585 -{ 2584 +
  2585 +// void changed(H3270 *session, int bstart, int bend)
  2586 +// {
2586 /* 2587 /*
2587 if(session->first_changed < 0) 2588 if(session->first_changed < 0)
2588 { 2589 {
@@ -2596,7 +2597,7 @@ void changed(H3270 *session, int bstart, int bend) @@ -2596,7 +2597,7 @@ void changed(H3270 *session, int bstart, int bend)
2596 if(bend > session->last_changed) 2597 if(bend > session->last_changed)
2597 session->last_changed = bend; 2598 session->last_changed = bend;
2598 */ 2599 */
2599 -} 2600 +// }
2600 2601
2601 /* 2602 /*
2602 * Swap the regular and alternate screen buffers 2603 * Swap the regular and alternate screen buffers
@@ -41,7 +41,7 @@ LIB3270_INTERNAL void ctlr_init(H3270 *session, unsigned cmask); @@ -41,7 +41,7 @@ LIB3270_INTERNAL void ctlr_init(H3270 *session, unsigned cmask);
41 LIB3270_INTERNAL void ctlr_read_buffer(unsigned char aid_byte); 41 LIB3270_INTERNAL void ctlr_read_buffer(unsigned char aid_byte);
42 LIB3270_INTERNAL void ctlr_read_modified(unsigned char aid_byte, Boolean all); 42 LIB3270_INTERNAL void ctlr_read_modified(unsigned char aid_byte, Boolean all);
43 LIB3270_INTERNAL void ctlr_reinit(H3270 *session, unsigned cmask); 43 LIB3270_INTERNAL void ctlr_reinit(H3270 *session, unsigned cmask);
44 -LIB3270_INTERNAL void ctlr_scroll(void); 44 +LIB3270_INTERNAL void ctlr_scroll(H3270 *hSession);
45 LIB3270_INTERNAL void ctlr_shrink(void); 45 LIB3270_INTERNAL void ctlr_shrink(void);
46 LIB3270_INTERNAL void ctlr_snap_buffer(void); 46 LIB3270_INTERNAL void ctlr_snap_buffer(void);
47 LIB3270_INTERNAL Boolean ctlr_snap_modes(void); 47 LIB3270_INTERNAL Boolean ctlr_snap_modes(void);
@@ -36,7 +36,10 @@ @@ -36,7 +36,10 @@
36 #include "globals.h" 36 #include "globals.h"
37 37
38 #include <errno.h> 38 #include <errno.h>
39 -#include <malloc.h> 39 +
  40 +#ifdef HAVE_MALLOC_H
  41 + #include <malloc.h>
  42 +#endif // HAVE_MALLOC_H
40 43
41 //#include "appres.h" 44 //#include "appres.h"
42 #include "actionsc.h" 45 #include "actionsc.h"
@@ -36,7 +36,6 @@ @@ -36,7 +36,6 @@
36 */ 36 */
37 37
38 #include <errno.h> 38 #include <errno.h>
39 -// #include <malloc.h>  
40 39
41 #include "globals.h" 40 #include "globals.h"
42 41
@@ -55,7 +55,6 @@ @@ -55,7 +55,6 @@
55 #include "utilc.h" 55 #include "utilc.h"
56 56
57 #include <errno.h> 57 #include <errno.h>
58 -// #include <malloc.h>  
59 58
60 // extern unsigned char aid; 59 // extern unsigned char aid;
61 60
@@ -52,7 +52,6 @@ @@ -52,7 +52,6 @@
52 #include "xioc.h" 52 #include "xioc.h"
53 53
54 #include <errno.h> 54 #include <errno.h>
55 -// #include <malloc.h>  
56 55
57 #define RECONNECT_MS 2000 /* 2 sec before reconnecting to host */ 56 #define RECONNECT_MS 2000 /* 2 sec before reconnecting to host */
58 #define RECONNECT_ERR_MS 5000 /* 5 sec before reconnecting to host */ 57 #define RECONNECT_ERR_MS 5000 /* 5 sec before reconnecting to host */
@@ -45,7 +45,6 @@ @@ -45,7 +45,6 @@
45 #endif 45 #endif
46 46
47 #include <fcntl.h> 47 #include <fcntl.h>
48 -// #include <malloc.h>  
49 48
50 #include "3270ds.h" 49 #include "3270ds.h"
51 //#include "appres.h" 50 //#include "appres.h"
@@ -107,7 +106,7 @@ @@ -107,7 +106,7 @@
107 int faddr; 106 int faddr;
108 unsigned char fa; 107 unsigned char fa;
109 108
110 - if(lib3270_get_toggle(&h3270,LIB3270_TOGGLE_MARGINED_PASTE)) 109 + if(lib3270_get_toggle(session,LIB3270_TOGGLE_MARGINED_PASTE))
111 { 110 {
112 baddr = session->cursor_addr; 111 baddr = session->cursor_addr;
113 while(BA_TO_COL(baddr) < lmargin) 112 while(BA_TO_COL(baddr) < lmargin)
@@ -56,7 +56,6 @@ @@ -56,7 +56,6 @@
56 56
57 #else 57 #else
58 58
59 -// #include <malloc.h>  
60 #include <sys/socket.h> 59 #include <sys/socket.h>
61 #include <sys/ioctl.h> 60 #include <sys/ioctl.h>
62 #include <netinet/in.h> 61 #include <netinet/in.h>
@@ -29,7 +29,6 @@ @@ -29,7 +29,6 @@
29 29
30 #include "globals.h" 30 #include "globals.h"
31 // #include "appres.h" 31 // #include "appres.h"
32 -// #include <malloc.h>  
33 #include <lib3270.h> 32 #include <lib3270.h>
34 #include <lib3270/session.h> 33 #include <lib3270/session.h>
35 #include <lib3270/selection.h> 34 #include <lib3270/selection.h>