Commit f90ede0531d9279421db6ea4e797fa846d895462

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

Movendo mais "statics" para a estrutura de sessao, simplificando chamadas

@@ -50,7 +50,7 @@ EXEEXT=@EXEEXT@ @@ -50,7 +50,7 @@ EXEEXT=@EXEEXT@
50 DBGLIB=-L../../$(BINDIR)/Debug/lib -l3270 50 DBGLIB=-L../../$(BINDIR)/Debug/lib -l3270
51 RLSLIB=-L../../$(BINDIR)/Release/lib -l3270 51 RLSLIB=-L../../$(BINDIR)/Release/lib -l3270
52 TMPDIR=$(PWD)/.tmp 52 TMPDIR=$(PWD)/.tmp
53 - 53 +GLOBAL_DEPS=$(PWD)/include/*.h $(PWD)/include/lib3270/*.h
54 #---[ Tools ]------------------------------------------------------------------ 54 #---[ Tools ]------------------------------------------------------------------
55 55
56 VALGRIND=@VALGRIND@ 56 VALGRIND=@VALGRIND@
src/gtk/Makefile.in
@@ -55,7 +55,7 @@ SOURCES=main.c mainwindow.c actions.c fonts.c \ @@ -55,7 +55,7 @@ SOURCES=main.c mainwindow.c actions.c fonts.c \
55 $(foreach SRC, $(COMMON_SRC), common/$(SRC)) \ 55 $(foreach SRC, $(COMMON_SRC), common/$(SRC)) \
56 $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) 56 $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC))
57 57
58 -DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h 58 +DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h $(GLOBAL_DEPS)
59 59
60 VALGRIND=@VALGRIND@ 60 VALGRIND=@VALGRIND@
61 61
src/include/lib3270.h
@@ -26,7 +26,6 @@ @@ -26,7 +26,6 @@
26 * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) 26 * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
27 * licinio@bb.com.br (Licínio Luis Branco) 27 * licinio@bb.com.br (Licínio Luis Branco)
28 * kraucer@bb.com.br (Kraucer Fernandes Mazuco) 28 * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29 - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda)  
30 * 29 *
31 */ 30 */
32 31
@@ -205,8 +204,6 @@ @@ -205,8 +204,6 @@
205 LIB3270_CONNECTED_TN3270E /**< connected in TN3270E mode, 3270 mode */ 204 LIB3270_CONNECTED_TN3270E /**< connected in TN3270E mode, 3270 mode */
206 } LIB3270_CSTATE; 205 } LIB3270_CSTATE;
207 206
208 -// #include <lib3270/api.h>  
209 -  
210 #ifdef __cplusplus 207 #ifdef __cplusplus
211 extern "C" { 208 extern "C" {
212 #endif 209 #endif
src/include/lib3270/action_table.h
@@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
69 DECLARE_LIB3270_ACTION( eraseeol ) 69 DECLARE_LIB3270_ACTION( eraseeol )
70 DECLARE_LIB3270_ACTION( erase ) 70 DECLARE_LIB3270_ACTION( erase )
71 DECLARE_LIB3270_ACTION( delete ) 71 DECLARE_LIB3270_ACTION( delete )
  72 + DECLARE_LIB3270_ACTION( dup )
72 73
73 DECLARE_LIB3270_ACTION( backspace ) 74 DECLARE_LIB3270_ACTION( backspace )
74 DECLARE_LIB3270_ACTION( previousword ) 75 DECLARE_LIB3270_ACTION( previousword )
src/include/lib3270/session.h
@@ -113,6 +113,7 @@ @@ -113,6 +113,7 @@
113 // Screen contents 113 // Screen contents
114 void * buffer[2]; /**< Internal buffers */ 114 void * buffer[2]; /**< Internal buffers */
115 struct ea * ea_buf; /**< 3270 device buffer. ea_buf[-1] is the dummy default field attribute */ 115 struct ea * ea_buf; /**< 3270 device buffer. ea_buf[-1] is the dummy default field attribute */
  116 + struct ea * aea_buf; /** alternate 3270 extended attribute buffer */
116 struct lib3270_text * text; /**< Converted 3270 chars */ 117 struct lib3270_text * text; /**< Converted 3270 chars */
117 118
118 // host.c 119 // host.c
@@ -159,6 +160,8 @@ @@ -159,6 +160,8 @@
159 160
160 void (*set_timer)(H3270 *session, unsigned char on); 161 void (*set_timer)(H3270 *session, unsigned char on);
161 void (*erase)(H3270 *session); 162 void (*erase)(H3270 *session);
  163 + void (*suspend)(H3270 *session);
  164 + void (*resume)(H3270 *session);
162 void (*cursor)(H3270 *session, LIB3270_CURSOR id); 165 void (*cursor)(H3270 *session, LIB3270_CURSOR id);
163 void (*set_selection)(H3270 *session, unsigned char on); 166 void (*set_selection)(H3270 *session, unsigned char on);
164 void (*ctlr_done)(H3270 *session); 167 void (*ctlr_done)(H3270 *session);
src/lib3270/api.h
@@ -306,45 +306,6 @@ @@ -306,45 +306,6 @@
306 306
307 #define CHAR_ATTR_UNCONVERTED CHAR_ATTR_CG 307 #define CHAR_ATTR_UNCONVERTED CHAR_ATTR_CG
308 308
309 -/*  
310 - struct lib3270_screen_callbacks  
311 - {  
312 - unsigned short sz;  
313 -  
314 - int (*init)(void);  
315 - int (*notify)(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg);  
316 - void (*model_changed)(H3270 *session, const char *name, int model, int rows, int cols);  
317 - int (*addch)(int row, int col, unsigned char c, unsigned short attr);  
318 - void (*charset)(char *dcs);  
319 - void (*title)(char *text);  
320 - void (*ring_bell)(void);  
321 - void (*redraw)(void);  
322 - void (*move_cursor)(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr);  
323 - int (*set_suspended)(int state);  
324 - void (*set_script)(SCRIPT_STATE state);  
325 - void (*reset)(int lock);  
326 - void (*status)(H3270 *session, LIB3270_STATUS id);  
327 - void (*cursor)(H3270 *session, LIB3270_CURSOR mode);  
328 - void (*lu)(H3270 *session, const char *lu);  
329 - void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on);  
330 -  
331 - void (*erase)(H3270 *session);  
332 - void (*display)(H3270 *session);  
333 - void (*set_viewsize)(H3270 *session, unsigned short rows, unsigned short cols);  
334 -  
335 -  
336 - void (*toggle_changed)(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason, const char *name);  
337 - void (*show_timer)(long seconds);  
338 -  
339 - // Console/Trace window  
340 - HCONSOLE (*console_new)(const char *title, const char *label);  
341 - void (*console_delete)(HCONSOLE hwnd);  
342 - int (*console_append)(HCONSOLE hwnd, const char *fmt, va_list args);  
343 - char * (*console_entry)(HCONSOLE hwnd);  
344 -  
345 - };  
346 -*/  
347 -  
348 struct lib3270_option 309 struct lib3270_option
349 { 310 {
350 const char *name; 311 const char *name;
@@ -392,7 +353,7 @@ @@ -392,7 +353,7 @@
392 353
393 354
394 LOCAL_EXTERN unsigned char get_field_attribute(H3270 *session, int baddr); 355 LOCAL_EXTERN unsigned char get_field_attribute(H3270 *session, int baddr);
395 - LOCAL_EXTERN int screen_read(char *dest, int baddr, int count); 356 +// LOCAL_EXTERN int screen_read(char *dest, int baddr, int count);
396 LOCAL_EXTERN void Input_String(const unsigned char *str); 357 LOCAL_EXTERN void Input_String(const unsigned char *str);
397 LOCAL_EXTERN void screen_size(int *rows, int *cols); 358 LOCAL_EXTERN void screen_size(int *rows, int *cols);
398 359
@@ -432,8 +393,8 @@ @@ -432,8 +393,8 @@
432 // LOCAL_EXTERN int ctlr_get_rows(void) __attribute__ ((deprecated)); 393 // LOCAL_EXTERN int ctlr_get_rows(void) __attribute__ ((deprecated));
433 394
434 /* Screen calls */ 395 /* Screen calls */
435 - LOCAL_EXTERN void screen_resume(H3270 *session);  
436 - LOCAL_EXTERN void screen_suspend(H3270 *session); 396 +// LOCAL_EXTERN void screen_resume(H3270 *session);
  397 +// LOCAL_EXTERN void screen_suspend(H3270 *session);
437 LOCAL_EXTERN void screen_disp(H3270 *session); 398 LOCAL_EXTERN void screen_disp(H3270 *session);
438 399
439 /* Cursor calls */ 400 /* Cursor calls */
src/lib3270/ctlr.c
@@ -90,7 +90,7 @@ unsigned char crm_attr[16]; @@ -90,7 +90,7 @@ unsigned char crm_attr[16];
90 Boolean dbcs = False; 90 Boolean dbcs = False;
91 91
92 /* Statics */ 92 /* Statics */
93 -static struct ea *aea_buf; /* alternate 3270 extended attribute buffer */ 93 +// static struct ea *aea_buf; /* alternate 3270 extended attribute buffer */
94 static unsigned char *zero_buf; // empty buffer, for area clears 94 static unsigned char *zero_buf; // empty buffer, for area clears
95 static void set_formatted(H3270 *session); 95 static void set_formatted(H3270 *session);
96 static void ctlr_blanks(void); 96 static void ctlr_blanks(void);
@@ -174,7 +174,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask) @@ -174,7 +174,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask)
174 session->ea_buf = tmp + 1; 174 session->ea_buf = tmp + 1;
175 175
176 session->buffer[1] = tmp = lib3270_calloc(sizeof(struct ea),sz+1,session->buffer[1]); 176 session->buffer[1] = tmp = lib3270_calloc(sizeof(struct ea),sz+1,session->buffer[1]);
177 - aea_buf = tmp + 1; 177 + session->aea_buf = tmp + 1;
178 178
179 session->text = lib3270_calloc(sizeof(struct lib3270_text),sz,session->text); 179 session->text = lib3270_calloc(sizeof(struct lib3270_text),sz,session->text);
180 180
@@ -1945,8 +1945,7 @@ ctlr_write_sscp_lu(unsigned char buf[], int buflen) @@ -1945,8 +1945,7 @@ ctlr_write_sscp_lu(unsigned char buf[], int buflen)
1945 /* Some hosts forget they're talking SSCP-LU. */ 1945 /* Some hosts forget they're talking SSCP-LU. */
1946 cp++; 1946 cp++;
1947 i++; 1947 i++;
1948 - trace_ds(" StartField%s %s [translated to space]\n",  
1949 - rcba(buffer_addr), see_attr(*cp)); 1948 + trace_ds(" StartField%s %s [translated to space]\n",rcba(buffer_addr), see_attr(*cp));
1950 ctlr_add(buffer_addr, EBC_space, default_cs); 1949 ctlr_add(buffer_addr, EBC_space, default_cs);
1951 ctlr_add_fg(buffer_addr, default_fg); 1950 ctlr_add_fg(buffer_addr, default_fg);
1952 ctlr_add_bg(buffer_addr, default_bg); 1951 ctlr_add_bg(buffer_addr, default_bg);
@@ -2619,20 +2618,20 @@ void changed(H3270 *session, int bstart, int bend) @@ -2619,20 +2618,20 @@ void changed(H3270 *session, int bstart, int bend)
2619 */ 2618 */
2620 void ctlr_altbuffer(H3270 *session, int alt) 2619 void ctlr_altbuffer(H3270 *session, int alt)
2621 { 2620 {
2622 - struct ea *etmp;  
2623 -  
2624 CHECK_SESSION_HANDLE(session); 2621 CHECK_SESSION_HANDLE(session);
2625 2622
2626 if (alt != session->is_altbuffer) 2623 if (alt != session->is_altbuffer)
2627 { 2624 {
  2625 + struct ea *etmp;
2628 2626
2629 etmp = session->ea_buf; 2627 etmp = session->ea_buf;
2630 - session->ea_buf = aea_buf;  
2631 - aea_buf = etmp; 2628 + session->ea_buf = session->aea_buf;
  2629 + session->aea_buf = etmp;
2632 2630
2633 session->is_altbuffer = alt; 2631 session->is_altbuffer = alt;
  2632 + lib3270_unselect(session);
  2633 +
2634 ALL_CHANGED; 2634 ALL_CHANGED;
2635 - // unselect(0, ROWS*COLS);  
2636 2635
2637 /* 2636 /*
2638 * There may be blinkers on the alternate screen; schedule one 2637 * There may be blinkers on the alternate screen; schedule one
src/lib3270/init.c
@@ -77,17 +77,30 @@ void lib3270_session_free(H3270 *h) @@ -77,17 +77,30 @@ void lib3270_session_free(H3270 *h)
77 77
78 static void update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor) 78 static void update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor)
79 { 79 {
80 -  
81 } 80 }
82 81
83 static void nop_char(H3270 *session, unsigned char chr) 82 static void nop_char(H3270 *session, unsigned char chr)
84 { 83 {
85 -  
86 } 84 }
87 85
88 static void nop(H3270 *session) 86 static void nop(H3270 *session)
89 { 87 {
  88 +}
90 89
  90 +static void update_model(H3270 *session, const char *name, int model, int rows, int cols)
  91 +{
  92 +}
  93 +
  94 +static void changed(H3270 *session, int bstart, int bend)
  95 +{
  96 +}
  97 +
  98 +static void update_cursor(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr)
  99 +{
  100 +}
  101 +
  102 +static void update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on)
  103 +{
91 } 104 }
92 105
93 static void lib3270_session_init(H3270 *hSession, const char *model) 106 static void lib3270_session_init(H3270 *hSession, const char *model)
@@ -99,10 +112,17 @@ static void lib3270_session_init(H3270 *hSession, const char *model) @@ -99,10 +112,17 @@ static void lib3270_session_init(H3270 *hSession, const char *model)
99 memset(hSession,0,sizeof(H3270)); 112 memset(hSession,0,sizeof(H3270));
100 hSession->sz = sizeof(H3270); 113 hSession->sz = sizeof(H3270);
101 114
102 - // A few dummy calls to avoid "ifs" 115 + // Dummy calls to avoid "ifs"
103 hSession->update = update_char; 116 hSession->update = update_char;
  117 + hSession->update_model = update_model;
  118 + hSession->update_cursor = update_cursor;
104 hSession->set_selection = nop_char; 119 hSession->set_selection = nop_char;
105 hSession->ctlr_done = nop; 120 hSession->ctlr_done = nop;
  121 + hSession->changed = changed;
  122 + hSession->erase = screen_disp;
  123 + hSession->suspend = nop;
  124 + hSession->resume = screen_disp;
  125 + hSession->update_oia = update_oia;
106 126
107 hSession->sock = -1; 127 hSession->sock = -1;
108 hSession->model_num = -1; 128 hSession->model_num = -1;
src/lib3270/kybd.c
@@ -1750,10 +1750,9 @@ do_delete(void) @@ -1750,10 +1750,9 @@ do_delete(void)
1750 1750
1751 LIB3270_ACTION( delete ) 1751 LIB3270_ACTION( delete )
1752 { 1752 {
1753 -// reset_idle_timer();  
1754 - if (kybdlock) { 1753 + if (kybdlock)
  1754 + {
1755 ENQUEUE_ACTION(lib3270_delete); 1755 ENQUEUE_ACTION(lib3270_delete);
1756 -// enq_ta(Delete_action, CN, CN);  
1757 return 0; 1756 return 0;
1758 } 1757 }
1759 #if defined(X3270_ANSI) /*[*/ 1758 #if defined(X3270_ANSI) /*[*/
@@ -1781,8 +1780,8 @@ LIB3270_ACTION( delete ) @@ -1781,8 +1780,8 @@ LIB3270_ACTION( delete )
1781 */ 1780 */
1782 LIB3270_ACTION( backspace ) 1781 LIB3270_ACTION( backspace )
1783 { 1782 {
1784 -// reset_idle_timer();  
1785 - if (kybdlock) { 1783 + if (kybdlock)
  1784 + {
1786 ENQUEUE_ACTION( lib3270_backspace ); 1785 ENQUEUE_ACTION( lib3270_backspace );
1787 return 0; 1786 return 0;
1788 } 1787 }
@@ -2316,13 +2315,12 @@ LIB3270_CURSOR_ACTION( newline ) @@ -2316,13 +2315,12 @@ LIB3270_CURSOR_ACTION( newline )
2316 2315
2317 /* 2316 /*
2318 * DUP key 2317 * DUP key
2319 - */ /*  
2320 -void  
2321 -Dup_action(Widget w unused, XEvent *event, String *params, Cardinal *num_params) 2318 + */
  2319 +LIB3270_ACTION( dup )
2322 { 2320 {
2323 -// reset_idle_timer();  
2324 - if (kybdlock) {  
2325 - enq_ta(Dup_action, CN, CN); 2321 + if (kybdlock)
  2322 + {
  2323 + ENQUEUE_ACTION(lib3270_enter);
2326 return; 2324 return;
2327 } 2325 }
2328 #if defined(X3270_ANSI) 2326 #if defined(X3270_ANSI)
@@ -2330,10 +2328,9 @@ Dup_action(Widget w unused, XEvent *event, String *params, Cardinal *num_params) @@ -2330,10 +2328,9 @@ Dup_action(Widget w unused, XEvent *event, String *params, Cardinal *num_params)
2330 return; 2328 return;
2331 #endif 2329 #endif
2332 if (key_Character(EBC_dup, False, False, NULL)) 2330 if (key_Character(EBC_dup, False, False, NULL))
2333 - cursor_move(next_unprotected(h3270.cursor_addr)); 2331 + cursor_move(next_unprotected(hSession->cursor_addr));
2334 } 2332 }
2335 -*/  
2336 - 2333 +
2337 /* 2334 /*
2338 * FM key 2335 * FM key
2339 */ /* 2336 */ /*
src/lib3270/macros.c
@@ -104,8 +104,9 @@ @@ -104,8 +104,9 @@
104 104
105 LIB3270_MACRO( get ) 105 LIB3270_MACRO( get )
106 { 106 {
107 - int start, qtd, rows, cols, row, col;  
108 char *buffer = NULL; 107 char *buffer = NULL;
  108 +/*
  109 + int start, qtd, rows, cols, row, col;
109 110
110 switch(argc) 111 switch(argc)
111 { 112 {
@@ -167,6 +168,7 @@ @@ -167,6 +168,7 @@
167 buffer = malloc(qtd+1); 168 buffer = malloc(qtd+1);
168 screen_read(buffer, start, qtd); 169 screen_read(buffer, start, qtd);
169 170
  171 +*/
170 return buffer; 172 return buffer;
171 } 173 }
172 174
src/lib3270/paste.c
@@ -190,7 +190,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) @@ -190,7 +190,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
190 if(kybdlock) 190 if(kybdlock)
191 return -EINVAL; 191 return -EINVAL;
192 192
193 - screen_suspend(h); 193 + h->suspend(h);
194 194
195 while(*str && last && !kybdlock && h->cursor_addr >= data.orig_addr) 195 while(*str && last && !kybdlock && h->cursor_addr >= data.orig_addr)
196 { 196 {
@@ -230,7 +230,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) @@ -230,7 +230,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
230 } 230 }
231 } 231 }
232 232
233 - screen_resume(h); 233 + h->resume(h);
234 return data.qtd; 234 return data.qtd;
235 } 235 }
236 236
src/lib3270/screen.c
@@ -96,9 +96,7 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att @@ -96,9 +96,7 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att
96 /* Converted char has changed, update it */ 96 /* Converted char has changed, update it */
97 session->text[baddr].chr = c; 97 session->text[baddr].chr = c;
98 session->text[baddr].attr = attr; 98 session->text[baddr].attr = attr;
99 -  
100 - if(session->update)  
101 - session->update(session,baddr,c,attr,baddr == session->cursor_addr); 99 + session->update(session,baddr,c,attr,baddr == session->cursor_addr);
102 } 100 }
103 101
104 /** 102 /**
@@ -116,16 +114,12 @@ int screen_init(H3270 *session) @@ -116,16 +114,12 @@ int screen_init(H3270 *session)
116 lib3270_register_schange(session,ST_3270_MODE, status_3270_mode,0); 114 lib3270_register_schange(session,ST_3270_MODE, status_3270_mode,0);
117 lib3270_register_schange(session,ST_PRINTER, status_printer,0); 115 lib3270_register_schange(session,ST_PRINTER, status_printer,0);
118 116
119 -// lib3270_register_schange(session,ST_HALF_CONNECT, relabel,0);  
120 -// lib3270_register_schange(session,ST_CONNECT, relabel,0);  
121 -// lib3270_register_schange(session,ST_3270_MODE, relabel,0);  
122 -  
123 /* Set up the controller. */ 117 /* Set up the controller. */
124 ctlr_init(session,-1); 118 ctlr_init(session,-1);
125 ctlr_reinit(session,-1); 119 ctlr_reinit(session,-1);
126 120
127 /* Finish screen initialization. */ 121 /* Finish screen initialization. */
128 - screen_suspend(session); 122 + session->suspend(session);
129 123
130 return 0; 124 return 0;
131 } 125 }
@@ -143,7 +137,7 @@ static unsigned short color_from_fa(unsigned char fa) @@ -143,7 +137,7 @@ static unsigned short color_from_fa(unsigned char fa)
143 /* 137 /*
144 * Find the display attributes for a baddr, fa_addr and fa. 138 * Find the display attributes for a baddr, fa_addr and fa.
145 */ 139 */
146 -static unsigned short calc_attrs(int baddr, int fa_addr, int fa) 140 +static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa)
147 { 141 {
148 unsigned short fg=0, bg=0, a; 142 unsigned short fg=0, bg=0, a;
149 int gr; 143 int gr;
@@ -152,10 +146,10 @@ static unsigned short calc_attrs(int baddr, int fa_addr, int fa) @@ -152,10 +146,10 @@ static unsigned short calc_attrs(int baddr, int fa_addr, int fa)
152 146
153 /* Monochrome is easy, and so is color if nothing is specified. */ 147 /* Monochrome is easy, and so is color if nothing is specified. */
154 if (!appres.m3279 || 148 if (!appres.m3279 ||
155 - (!h3270.ea_buf[baddr].fg &&  
156 - !h3270.ea_buf[fa_addr].fg &&  
157 - !h3270.ea_buf[baddr].bg &&  
158 - !h3270.ea_buf[fa_addr].bg)) 149 + (!session->ea_buf[baddr].fg &&
  150 + !session->ea_buf[fa_addr].fg &&
  151 + !session->ea_buf[baddr].bg &&
  152 + !session->ea_buf[fa_addr].bg))
159 { 153 {
160 a = color_from_fa(fa); 154 a = color_from_fa(fa);
161 } 155 }
@@ -163,23 +157,23 @@ static unsigned short calc_attrs(int baddr, int fa_addr, int fa) @@ -163,23 +157,23 @@ static unsigned short calc_attrs(int baddr, int fa_addr, int fa)
163 { 157 {
164 158
165 /* The current location or the fa specifies the fg or bg. */ 159 /* The current location or the fa specifies the fg or bg. */
166 - if (h3270.ea_buf[baddr].fg) 160 + if (session->ea_buf[baddr].fg)
167 { 161 {
168 - fg = h3270.ea_buf[baddr].fg & 0x0f; 162 + fg = session->ea_buf[baddr].fg & 0x0f;
169 } 163 }
170 - else if (h3270.ea_buf[fa_addr].fg) 164 + else if (session->ea_buf[fa_addr].fg)
171 { 165 {
172 - fg = h3270.ea_buf[fa_addr].fg & 0x0f; 166 + fg = session->ea_buf[fa_addr].fg & 0x0f;
173 } 167 }
174 else 168 else
175 { 169 {
176 fg = DEFCOLOR_MAP(fa); 170 fg = DEFCOLOR_MAP(fa);
177 } 171 }
178 172
179 - if (h3270.ea_buf[baddr].bg)  
180 - bg = h3270.ea_buf[baddr].bg & 0x0f;  
181 - else if (h3270.ea_buf[fa_addr].bg)  
182 - bg = h3270.ea_buf[fa_addr].bg & 0x0f; 173 + if (session->ea_buf[baddr].bg)
  174 + bg = session->ea_buf[baddr].bg & 0x0f;
  175 + else if (session->ea_buf[fa_addr].bg)
  176 + bg = session->ea_buf[fa_addr].bg & 0x0f;
183 else 177 else
184 bg = 0; 178 bg = 0;
185 179
@@ -188,10 +182,10 @@ static unsigned short calc_attrs(int baddr, int fa_addr, int fa) @@ -188,10 +182,10 @@ static unsigned short calc_attrs(int baddr, int fa_addr, int fa)
188 182
189 /* Compute the display attributes. */ 183 /* Compute the display attributes. */
190 184
191 - if (h3270.ea_buf[baddr].gr)  
192 - gr = h3270.ea_buf[baddr].gr;  
193 - else if (h3270.ea_buf[fa_addr].gr)  
194 - gr = h3270.ea_buf[fa_addr].gr; 185 + if (session->ea_buf[baddr].gr)
  186 + gr = session->ea_buf[baddr].gr;
  187 + else if (session->ea_buf[fa_addr].gr)
  188 + gr = session->ea_buf[fa_addr].gr;
195 else 189 else
196 gr = 0; 190 gr = 0;
197 191
@@ -216,16 +210,6 @@ static unsigned short calc_attrs(int baddr, int fa_addr, int fa) @@ -216,16 +210,6 @@ static unsigned short calc_attrs(int baddr, int fa_addr, int fa)
216 return a; 210 return a;
217 } 211 }
218 212
219 -/* Erase screen */  
220 -void screen_erase(H3270 *session)  
221 -{  
222 - /* If the application supplies a callback use it!, if not just redraw with blanks */  
223 - if(session->erase)  
224 - session->erase(session);  
225 - else  
226 - screen_update(session,0,session->rows * session->cols);  
227 -}  
228 -  
229 LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, int *r, int *c) 213 LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, int *r, int *c)
230 { 214 {
231 *r = h->rows; 215 *r = h->rows;
@@ -244,8 +228,7 @@ void update_model_info(H3270 *session, int model, int cols, int rows) @@ -244,8 +228,7 @@ void update_model_info(H3270 *session, int model, int cols, int rows)
244 /* Update the model name. */ 228 /* Update the model name. */
245 (void) sprintf(session->model_name, "327%c-%d%s",appres.m3279 ? '9' : '8',session->model_num,appres.extended ? "-E" : ""); 229 (void) sprintf(session->model_name, "327%c-%d%s",appres.m3279 ? '9' : '8',session->model_num,appres.extended ? "-E" : "");
246 230
247 - if(session->update_model)  
248 - session->update_model(session, session->model_name,session->model_num,rows,cols); 231 + session->update_model(session, session->model_name,session->model_num,rows,cols);
249 } 232 }
250 233
251 LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned char *chr, unsigned short *attr) 234 LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned char *chr, unsigned short *attr)
@@ -269,40 +252,6 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned @@ -269,40 +252,6 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned
269 return 0; 252 return 0;
270 } 253 }
271 254
272 -/* Get screen contents */  
273 -int screen_read(char *dest, int baddr, int count)  
274 -{  
275 - unsigned char fa = get_field_attribute(&h3270,baddr);  
276 - int max = (h3270.maxROWS * h3270.maxCOLS);  
277 -  
278 - *dest = 0;  
279 -  
280 - while(count-- > 0)  
281 - {  
282 - if(baddr > max)  
283 - {  
284 - *dest = 0;  
285 - return EFAULT;  
286 - }  
287 -  
288 - if (h3270.ea_buf[baddr].fa)  
289 - fa = h3270.ea_buf[baddr].fa;  
290 -  
291 - if(FA_IS_ZERO(fa))  
292 - *dest = ' ';  
293 - else if(h3270.ea_buf[baddr].cc)  
294 - *dest = ebc2asc[h3270.ea_buf[baddr].cc];  
295 - else  
296 - *dest = ' ';  
297 -  
298 - dest++;  
299 - baddr++;  
300 - }  
301 - *dest = 0;  
302 -  
303 - return 0;  
304 -}  
305 -  
306 /* Display what's in the buffer. */ 255 /* Display what's in the buffer. */
307 static void screen_update(H3270 *session, int bstart, int bend) 256 static void screen_update(H3270 *session, int bstart, int bend)
308 { 257 {
@@ -316,8 +265,6 @@ static void screen_update(H3270 *session, int bstart, int bend) @@ -316,8 +265,6 @@ static void screen_update(H3270 *session, int bstart, int bend)
316 a = color_from_fa(fa); 265 a = color_from_fa(fa);
317 fa_addr = find_field_attribute(session,bstart); // may be -1, that's okay 266 fa_addr = find_field_attribute(session,bstart); // may be -1, that's okay
318 267
319 -// Trace("%s ea_buf=%p",__FUNCTION__,ea_buf);  
320 -  
321 for(baddr = bstart; baddr < bend; baddr++) 268 for(baddr = bstart; baddr < bend; baddr++)
322 { 269 {
323 if(session->ea_buf[baddr].fa) 270 if(session->ea_buf[baddr].fa)
@@ -325,7 +272,7 @@ static void screen_update(H3270 *session, int bstart, int bend) @@ -325,7 +272,7 @@ static void screen_update(H3270 *session, int bstart, int bend)
325 // Field attribute. 272 // Field attribute.
326 fa_addr = baddr; 273 fa_addr = baddr;
327 fa = session->ea_buf[baddr].fa; 274 fa = session->ea_buf[baddr].fa;
328 - a = calc_attrs(baddr, baddr, fa); 275 + a = calc_attrs(session, baddr, baddr, fa);
329 addch(session,baddr,' ',(attr = COLOR_GREEN)|CHAR_ATTR_MARKER); 276 addch(session,baddr,' ',(attr = COLOR_GREEN)|CHAR_ATTR_MARKER);
330 } 277 }
331 else if (FA_IS_ZERO(fa)) 278 else if (FA_IS_ZERO(fa))
@@ -342,14 +289,7 @@ static void screen_update(H3270 *session, int bstart, int bend) @@ -342,14 +289,7 @@ static void screen_update(H3270 *session, int bstart, int bend)
342 } 289 }
343 else 290 else
344 { 291 {
345 -// unsigned short b;  
346 - //  
347 - // Override some of the field  
348 - // attributes.  
349 - //  
350 -// attr = b = calc_attrs(baddr, fa_addr, fa);  
351 -  
352 - attr = calc_attrs(baddr, fa_addr, fa); 292 + attr = calc_attrs(session, baddr, fa_addr, fa);
353 } 293 }
354 294
355 if (session->ea_buf[baddr].cs == CS_LINEDRAW) 295 if (session->ea_buf[baddr].cs == CS_LINEDRAW)
@@ -370,10 +310,7 @@ static void screen_update(H3270 *session, int bstart, int bend) @@ -370,10 +310,7 @@ static void screen_update(H3270 *session, int bstart, int bend)
370 } 310 }
371 311
372 } 312 }
373 -  
374 - if(session->changed)  
375 - session->changed(session,bstart,bend);  
376 - 313 + session->changed(session,bstart,bend);
377 } 314 }
378 315
379 void screen_disp(H3270 *session) 316 void screen_disp(H3270 *session)
@@ -381,15 +318,6 @@ void screen_disp(H3270 *session) @@ -381,15 +318,6 @@ void screen_disp(H3270 *session)
381 screen_update(session,0,session->rows*session->cols); 318 screen_update(session,0,session->rows*session->cols);
382 } 319 }
383 320
384 -void screen_suspend(H3270 *session)  
385 -{  
386 -}  
387 -  
388 -void screen_resume(H3270 *session)  
389 -{  
390 - screen_disp(session);  
391 -}  
392 -  
393 LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h) 321 LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h)
394 { 322 {
395 CHECK_SESSION_HANDLE(h); 323 CHECK_SESSION_HANDLE(h);
@@ -408,9 +336,7 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr) @@ -408,9 +336,7 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr)
408 return ret; 336 return ret;
409 337
410 h->cursor_addr = baddr; 338 h->cursor_addr = baddr;
411 -  
412 - if(h->update_cursor)  
413 - h->update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols),h->text[baddr].chr,h->text[baddr].attr); 339 + h->update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols),h->text[baddr].chr,h->text[baddr].attr);
414 340
415 return ret; 341 return ret;
416 } 342 }
@@ -421,13 +347,8 @@ void set_status(H3270 *session, LIB3270_FLAG id, Boolean on) @@ -421,13 +347,8 @@ void set_status(H3270 *session, LIB3270_FLAG id, Boolean on)
421 { 347 {
422 CHECK_SESSION_HANDLE(session); 348 CHECK_SESSION_HANDLE(session);
423 349
424 - if(id < LIB3270_FLAG_COUNT)  
425 - {  
426 - session->oia_flag[id] = (on != 0);  
427 -  
428 - if(session->update_oia)  
429 - session->update_oia(session,id,session->oia_flag[id]);  
430 - } 350 + session->oia_flag[id] = (on != 0);
  351 + session->update_oia(session,id,session->oia_flag[id]);
431 352
432 } 353 }
433 354
src/lib3270/screenc.h
@@ -26,8 +26,9 @@ @@ -26,8 +26,9 @@
26 #define screen_132() /* */ 26 #define screen_132() /* */
27 #define screen_80() /* */ 27 #define screen_80() /* */
28 28
  29 +#define screen_erase(x) x->erase(x)
  30 +// LIB3270_INTERNAL void screen_erase(H3270 *session);
29 31
30 -LIB3270_INTERNAL void screen_erase(H3270 *session);  
31 LIB3270_INTERNAL void screen_changed(H3270 *session, int bstart, int bend); 32 LIB3270_INTERNAL void screen_changed(H3270 *session, int bstart, int bend);
32 LIB3270_INTERNAL int screen_init(H3270 *session); 33 LIB3270_INTERNAL int screen_init(H3270 *session);
33 // LIB3270_INTERNAL void screen_flip(void); 34 // LIB3270_INTERNAL void screen_flip(void);
src/lib3270/trace_dsc.h
1 /* 1 /*
2 - * Copyright 1995, 1999, 2001, 2002, 2003, 2005, 2006 by Paul Mattes.  
3 - * Permission to use, copy, modify, and distribute this software and its  
4 - * documentation for any purpose and without fee is hereby granted,  
5 - * provided that the above copyright notice appear in all copies and that  
6 - * both that copyright notice and this permission notice appear in  
7 - * supporting documentation.  
8 - *  
9 - * x3270, c3270, s3270 and tcl3270 are distributed in the hope that they will  
10 - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of  
11 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file LICENSE  
12 - * for more details. 2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como trace_dsc.h e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
13 */ 28 */
14 29
15 /* 30 /*