Commit d99b30f2c0ef4d70266ce8d7ffac82198d0fd51a

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

Mais ajustes para multi-sessao

Showing 1 changed file with 48 additions and 44 deletions   Show diff stats
src/lib3270/telnet.c
@@ -183,7 +183,7 @@ Boolean local_process = False; @@ -183,7 +183,7 @@ Boolean local_process = False;
183 // static unsigned char *lbptr; 183 // static unsigned char *lbptr;
184 // static int lnext = 0; 184 // static int lnext = 0;
185 // static int backslashed = 0; 185 // static int backslashed = 0;
186 -static int t_valid = 0; 186 +//static int t_valid = 0;
187 static char vintr; 187 static char vintr;
188 static char vquit; 188 static char vquit;
189 static char verase; 189 static char verase;
@@ -230,12 +230,12 @@ static void tn3270e_nak(enum pds); @@ -230,12 +230,12 @@ static void tn3270e_nak(enum pds);
230 230
231 #if defined(X3270_ANSI) /*[*/ 231 #if defined(X3270_ANSI) /*[*/
232 static void do_data(char c); 232 static void do_data(char c);
233 -static void do_intr(char c);  
234 -static void do_quit(char c);  
235 -static void do_cerase(char c);  
236 -static void do_werase(char c);  
237 -static void do_kill(char c);  
238 -static void do_rprnt(char c); 233 +static void do_intr(H3270 *hSession, char c);
  234 +static void do_quit(H3270 *hSession, char c);
  235 +static void do_cerase(H3270 *hSession, char c);
  236 +static void do_werase(H3270 *hSession, char c);
  237 +static void do_kill(H3270 *hSession, char c);
  238 +static void do_rprnt(H3270 *hSession, char c);
239 static void do_eof(char c); 239 static void do_eof(char c);
240 static void do_eol(char c); 240 static void do_eol(char c);
241 static void do_lnext(char c); 241 static void do_lnext(char c);
@@ -496,6 +496,11 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo @@ -496,6 +496,11 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
496 { 496 {
497 // struct servent * sp; 497 // struct servent * sp;
498 // struct hostent * hp; 498 // struct hostent * hp;
  499 +
  500 +#if defined(X3270_ANSI)
  501 + static int t_valid = 0;
  502 +#endif // X3270_ANSI
  503 +
499 char passthru_haddr[8]; 504 char passthru_haddr[8];
500 int passthru_len = 0; 505 int passthru_len = 0;
501 unsigned short passthru_port = 0; 506 unsigned short passthru_port = 0;
@@ -2163,23 +2168,23 @@ static void net_cookout(H3270 *hSession, const char *buf, int len) @@ -2163,23 +2168,23 @@ static void net_cookout(H3270 *hSession, const char *buf, int len)
2163 if (c == '\n') 2168 if (c == '\n')
2164 do_eol(c); 2169 do_eol(c);
2165 else if (c == vintr) 2170 else if (c == vintr)
2166 - do_intr(c); 2171 + do_intr(hSession, c);
2167 else if (c == vquit) 2172 else if (c == vquit)
2168 - do_quit(c); 2173 + do_quit(hSession,c);
2169 else if (c == verase) 2174 else if (c == verase)
2170 - do_cerase(c); 2175 + do_cerase(hSession,c);
2171 else if (c == vkill) 2176 else if (c == vkill)
2172 - do_kill(c); 2177 + do_kill(hSession,c);
2173 else if (c == vwerase) 2178 else if (c == vwerase)
2174 - do_werase(c); 2179 + do_werase(hSession,c);
2175 else if (c == vrprnt) 2180 else if (c == vrprnt)
2176 - do_rprnt(c); 2181 + do_rprnt(hSession,c);
2177 else if (c == veof) 2182 else if (c == veof)
2178 do_eof(c); 2183 do_eof(c);
2179 else if (c == vlnext) 2184 else if (c == vlnext)
2180 do_lnext(c); 2185 do_lnext(c);
2181 else if (c == 0x08 || c == 0x7f) /* Yes, a hack. */ 2186 else if (c == 0x08 || c == 0x7f) /* Yes, a hack. */
2182 - do_cerase(c); 2187 + do_cerase(hSession,c);
2183 else 2188 else
2184 do_data(c); 2189 do_data(c);
2185 } 2190 }
@@ -2234,10 +2239,10 @@ do_data(char c) @@ -2234,10 +2239,10 @@ do_data(char c)
2234 h3270.backslashed = 0; 2239 h3270.backslashed = 0;
2235 } 2240 }
2236 2241
2237 -static void  
2238 -do_intr(char c) 2242 +static void do_intr(H3270 *hSession, char c)
2239 { 2243 {
2240 - if (h3270.lnext) { 2244 + if (hSession->lnext)
  2245 + {
2241 do_data(c); 2246 do_data(c);
2242 return; 2247 return;
2243 } 2248 }
@@ -2246,10 +2251,10 @@ do_intr(char c) @@ -2246,10 +2251,10 @@ do_intr(char c)
2246 net_interrupt(); 2251 net_interrupt();
2247 } 2252 }
2248 2253
2249 -static void  
2250 -do_quit(char c) 2254 +static void do_quit(H3270 *hSession, char c)
2251 { 2255 {
2252 - if (h3270.lnext) { 2256 + if (hSession->lnext)
  2257 + {
2253 do_data(c); 2258 do_data(c);
2254 return; 2259 return;
2255 } 2260 }
@@ -2258,47 +2263,48 @@ do_quit(char c) @@ -2258,47 +2263,48 @@ do_quit(char c)
2258 net_break(); 2263 net_break();
2259 } 2264 }
2260 2265
2261 -static void  
2262 -do_cerase(char c) 2266 +static void do_cerase(H3270 *hSession, char c)
2263 { 2267 {
2264 int len; 2268 int len;
2265 2269
2266 - if (h3270.backslashed) {  
2267 - h3270.lbptr--; 2270 + if (hSession->backslashed)
  2271 + {
  2272 + hSession->lbptr--;
2268 ansi_process_s("\b"); 2273 ansi_process_s("\b");
2269 do_data(c); 2274 do_data(c);
2270 return; 2275 return;
2271 } 2276 }
2272 - if (h3270.lnext) { 2277 + if (hSession->lnext)
  2278 + {
2273 do_data(c); 2279 do_data(c);
2274 return; 2280 return;
2275 } 2281 }
2276 - if (h3270.lbptr > h3270.lbuf) {  
2277 - len = strlen(ctl_see((int) *--h3270.lbptr)); 2282 + if (hSession->lbptr > hSession->lbuf)
  2283 + {
  2284 + len = strlen(ctl_see((int) *--hSession->lbptr));
2278 2285
2279 while (len--) 2286 while (len--)
2280 ansi_process_s("\b \b"); 2287 ansi_process_s("\b \b");
2281 } 2288 }
2282 } 2289 }
2283 2290
2284 -static void  
2285 -do_werase(char c) 2291 +static void do_werase(H3270 *hSession, char c)
2286 { 2292 {
2287 int any = 0; 2293 int any = 0;
2288 int len; 2294 int len;
2289 2295
2290 - if (h3270.lnext) { 2296 + if (hSession->lnext) {
2291 do_data(c); 2297 do_data(c);
2292 return; 2298 return;
2293 } 2299 }
2294 - while (h3270.lbptr > h3270.lbuf) { 2300 + while (hSession->lbptr > hSession->lbuf) {
2295 char ch; 2301 char ch;
2296 2302
2297 - ch = *--h3270.lbptr; 2303 + ch = *--hSession->lbptr;
2298 2304
2299 if (ch == ' ' || ch == '\t') { 2305 if (ch == ' ' || ch == '\t') {
2300 if (any) { 2306 if (any) {
2301 - ++h3270.lbptr; 2307 + ++hSession->lbptr;
2302 break; 2308 break;
2303 } 2309 }
2304 } else 2310 } else
@@ -2310,41 +2316,39 @@ do_werase(char c) @@ -2310,41 +2316,39 @@ do_werase(char c)
2310 } 2316 }
2311 } 2317 }
2312 2318
2313 -static void  
2314 -do_kill(char c) 2319 +static void do_kill(H3270 *hSession, char c)
2315 { 2320 {
2316 int i, len; 2321 int i, len;
2317 2322
2318 - if (h3270.backslashed) {  
2319 - h3270.lbptr--; 2323 + if (hSession->backslashed) {
  2324 + hSession->lbptr--;
2320 ansi_process_s("\b"); 2325 ansi_process_s("\b");
2321 do_data(c); 2326 do_data(c);
2322 return; 2327 return;
2323 } 2328 }
2324 - if (h3270.lnext) { 2329 + if (hSession->lnext) {
2325 do_data(c); 2330 do_data(c);
2326 return; 2331 return;
2327 } 2332 }
2328 - while (h3270.lbptr > h3270.lbuf) {  
2329 - len = strlen(ctl_see((int) *--h3270.lbptr)); 2333 + while (hSession->lbptr > hSession->lbuf) {
  2334 + len = strlen(ctl_see((int) *--hSession->lbptr));
2330 2335
2331 for (i = 0; i < len; i++) 2336 for (i = 0; i < len; i++)
2332 ansi_process_s("\b \b"); 2337 ansi_process_s("\b \b");
2333 } 2338 }
2334 } 2339 }
2335 2340
2336 -static void  
2337 -do_rprnt(char c) 2341 +static void do_rprnt(H3270 *hSession, char c)
2338 { 2342 {
2339 unsigned char *p; 2343 unsigned char *p;
2340 2344
2341 - if (h3270.lnext) { 2345 + if (hSession->lnext) {
2342 do_data(c); 2346 do_data(c);
2343 return; 2347 return;
2344 } 2348 }
2345 ansi_process_s(ctl_see((int) c)); 2349 ansi_process_s(ctl_see((int) c));
2346 ansi_process_s("\r\n"); 2350 ansi_process_s("\r\n");
2347 - for (p = h3270.lbuf; p < h3270.lbptr; p++) 2351 + for (p = hSession->lbuf; p < hSession->lbptr; p++)
2348 ansi_process_s(ctl_see((int) *p)); 2352 ansi_process_s(ctl_see((int) *p));
2349 } 2353 }
2350 2354