Commit b794a1e07f31f23f8d155acce2b55db885d1348f
1 parent
4a2bbf15
Exists in
master
and in
3 other branches
Atualizando para o novo mecanismo de conexão
Showing
6 changed files
with
184 additions
and
263 deletions
Show diff stats
connect.c
... | ... | @@ -136,7 +136,9 @@ static void net_connected(H3270 *hSession) |
136 | 136 | |
137 | 137 | } |
138 | 138 | |
139 | -#if defined(_WIN32) /*[*/ | |
139 | + | |
140 | +#if defined(_WIN32) | |
141 | + | |
140 | 142 | static void sockstart(H3270 *session) |
141 | 143 | { |
142 | 144 | static int initted = 0; |
... | ... | @@ -171,15 +173,11 @@ static void net_connected(H3270 *hSession) |
171 | 173 | _exit(1); |
172 | 174 | } |
173 | 175 | } |
174 | -#endif /*]*/ | |
176 | +#endif // WIN32 | |
175 | 177 | |
176 | 178 | LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_CONNECT_OPTION opt) |
177 | 179 | { |
178 | - int s; | |
179 | - int optval; | |
180 | - struct addrinfo hints; | |
181 | - struct addrinfo * result = NULL; | |
182 | - struct addrinfo * rp = NULL; | |
180 | + CHECK_SESSION_HANDLE(hSession); | |
183 | 181 | |
184 | 182 | if(!hostname) |
185 | 183 | return EINVAL; |
... | ... | @@ -187,6 +185,48 @@ static void net_connected(H3270 *hSession) |
187 | 185 | if(!srvc) |
188 | 186 | srvc = "telnet"; |
189 | 187 | |
188 | + if(*hostname == '$') | |
189 | + { | |
190 | + const char *name = getenv(hostname+1); | |
191 | + if(!name) | |
192 | + { | |
193 | + lib3270_popup_dialog( hSession, | |
194 | + LIB3270_NOTIFY_ERROR, | |
195 | + _( "Connection error" ), | |
196 | + _( "Unable to find selected hostname." ), | |
197 | + _( "Can't determine value for environment variable \"%s\" " ), | |
198 | + hostname); | |
199 | + lib3270_set_disconnected(hSession); | |
200 | + return ENOENT; | |
201 | + } | |
202 | + hostname = name; | |
203 | + } | |
204 | + | |
205 | + hSession->host.opt = opt & ~LIB3270_CONNECT_OPTION_WAIT; | |
206 | + Replace(hSession->host.current,strdup(hostname)); | |
207 | + Replace(hSession->host.srvc,strdup(srvc)); | |
208 | + | |
209 | + Replace(hSession->host.full, | |
210 | + lib3270_strdup_printf( | |
211 | + "%s%s:%s", | |
212 | + opt&LIB3270_CONNECT_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
213 | + hostname, | |
214 | + srvc )); | |
215 | + | |
216 | + trace("current_host=\"%s\"",hSession->host.current); | |
217 | + | |
218 | + return lib3270_connect(hSession,opt & LIB3270_CONNECT_OPTION_WAIT); | |
219 | + | |
220 | + } | |
221 | + | |
222 | + int lib3270_connect(H3270 *hSession, int wait) | |
223 | + { | |
224 | + int s; | |
225 | + int optval; | |
226 | + struct addrinfo hints; | |
227 | + struct addrinfo * result = NULL; | |
228 | + struct addrinfo * rp = NULL; | |
229 | + | |
190 | 230 | CHECK_SESSION_HANDLE(hSession); |
191 | 231 | |
192 | 232 | lib3270_main_iterate(hSession,0); |
... | ... | @@ -201,20 +241,9 @@ static void net_connected(H3270 *hSession) |
201 | 241 | sockstart(hSession); |
202 | 242 | #endif |
203 | 243 | |
204 | - hSession->host.opt = opt & ~LIB3270_CONNECT_OPTION_WAIT; | |
205 | - Replace(hSession->host.current,strdup(hostname)); | |
206 | - | |
207 | - Replace(hSession->host.full, | |
208 | - lib3270_strdup_printf( | |
209 | - "%s%s:%s", | |
210 | - opt&LIB3270_CONNECT_OPTION_SSL ? "L:" : "", | |
211 | - hostname, | |
212 | - srvc )); | |
213 | - | |
214 | - trace("current_host=\"%s\"",hSession->host.current); | |
215 | - | |
216 | - | |
217 | 244 | set_ssl_state(hSession,LIB3270_SSL_UNSECURE); |
245 | + snprintf(hSession->full_model_name,LIB3270_FULL_MODEL_NAME_LENGTH,"IBM-327%c-%d",hSession->m3279 ? '9' : '8', hSession->model_num); | |
246 | + | |
218 | 247 | |
219 | 248 | hSession->ever_3270 = False; |
220 | 249 | |
... | ... | @@ -227,33 +256,17 @@ static void net_connected(H3270 *hSession) |
227 | 256 | hints.ai_addr = NULL; |
228 | 257 | hints.ai_next = NULL; |
229 | 258 | |
230 | - if(*hostname == '$') | |
231 | - { | |
232 | - const char *name = getenv(hostname+1); | |
233 | - if(!name) | |
234 | - { | |
235 | - lib3270_popup_dialog( hSession, | |
236 | - LIB3270_NOTIFY_ERROR, | |
237 | - _( "Connection error" ), | |
238 | - _( "Unable to find selected hostname." ), | |
239 | - _( "Can't determine value for environment variable \"%s\" " ), | |
240 | - hostname); | |
241 | - lib3270_set_disconnected(hSession); | |
242 | - return ENOENT; | |
243 | - } | |
244 | - hostname = name; | |
245 | - } | |
246 | 259 | |
247 | 260 | hSession->cstate = LIB3270_RESOLVING; |
248 | 261 | lib3270_st_changed(hSession, LIB3270_STATE_RESOLVING, True); |
249 | 262 | |
250 | - s = getaddrinfo(hostname, srvc, &hints, &result); | |
263 | + s = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); | |
251 | 264 | |
252 | 265 | if(s != 0) |
253 | 266 | { |
254 | 267 | char buffer[4096]; |
255 | 268 | |
256 | - snprintf(buffer,4095,_( "Can't connect to %s:%s"), hostname, srvc); | |
269 | + snprintf(buffer,4095,_( "Can't connect to %s:%s"), hSession->host.current, hSession->host.srvc); | |
257 | 270 | |
258 | 271 | #if defined(WIN32) && defined(HAVE_ICONV) |
259 | 272 | { |
... | ... | @@ -303,7 +316,7 @@ static void net_connected(H3270 *hSession) |
303 | 316 | hSession->ever_3270 = False; |
304 | 317 | hSession->ssl_host = 0; |
305 | 318 | |
306 | - if(opt&LIB3270_CONNECT_OPTION_SSL) | |
319 | + if(hSession->host.opt&LIB3270_CONNECT_OPTION_SSL) | |
307 | 320 | { |
308 | 321 | #if defined(HAVE_LIBSSL) |
309 | 322 | hSession->ssl_host = 1; |
... | ... | @@ -380,7 +393,7 @@ static void net_connected(H3270 *hSession) |
380 | 393 | if(err != WSAEWOULDBLOCK) |
381 | 394 | { |
382 | 395 | char buffer[4096]; |
383 | - snprintf(buffer,4095,_( "Can't connect to %s:%s"), hostname, srvc); | |
396 | + snprintf(buffer,4095,_( "Can't connect to %s"), lib3270_get_host(hSession)); | |
384 | 397 | |
385 | 398 | lib3270_popup_dialog( hSession, |
386 | 399 | LIB3270_NOTIFY_ERROR, |
... | ... | @@ -431,7 +444,7 @@ static void net_connected(H3270 *hSession) |
431 | 444 | if( errno != EINPROGRESS ) |
432 | 445 | { |
433 | 446 | char buffer[4096]; |
434 | - snprintf(buffer,4095,_( "Can't connect to %s:%s"), hostname, srvc); | |
447 | + snprintf(buffer,4095,_( "Can't connect to %s:%s"), hSession->host.current, hSession->host.srvc); | |
435 | 448 | |
436 | 449 | lib3270_popup_dialog( hSession, |
437 | 450 | LIB3270_NOTIFY_ERROR, |
... | ... | @@ -511,7 +524,7 @@ static void net_connected(H3270 *hSession) |
511 | 524 | |
512 | 525 | trace("%s: Connection in progress",__FUNCTION__); |
513 | 526 | |
514 | - if(opt&LIB3270_CONNECT_OPTION_WAIT) | |
527 | + if(wait) | |
515 | 528 | { |
516 | 529 | time_t end = time(0)+120; |
517 | 530 | |
... | ... | @@ -564,6 +577,7 @@ int non_blocking(H3270 *hSession, Boolean on) |
564 | 577 | _( "Connection error" ), |
565 | 578 | _( "ioctlsocket(FIONBIO) failed." ), |
566 | 579 | "%s", lib3270_win32_strerror(GetLastError())); |
580 | + return -1; | |
567 | 581 | } |
568 | 582 | #else |
569 | 583 | ... | ... |
globals.h
... | ... | @@ -223,9 +223,21 @@ enum keytype |
223 | 223 | KT_GE |
224 | 224 | }; |
225 | 225 | |
226 | +LIB3270_INTERNAL struct _ansictl | |
227 | +{ | |
228 | + char vintr; | |
229 | + char vquit; | |
230 | + char verase; | |
231 | + char vkill; | |
232 | + char veof; | |
233 | + char vwerase; | |
234 | + char vrprnt; | |
235 | + char vlnext; | |
236 | +} ansictl; | |
237 | + | |
226 | 238 | /* default charset translation tables */ |
227 | -LIB3270_INTERNAL const unsigned short ebc2asc0[256]; | |
228 | -LIB3270_INTERNAL const unsigned short asc2ft0[256]; | |
239 | +// LIB3270_INTERNAL const unsigned short ebc2asc0[256]; | |
240 | +// LIB3270_INTERNAL const unsigned short asc2ft0[256]; | |
229 | 241 | |
230 | 242 | |
231 | 243 | /* Library internal calls */ | ... | ... |
glue.c
... | ... | @@ -94,36 +94,80 @@ |
94 | 94 | |
95 | 95 | /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ |
96 | 96 | |
97 | -#if defined WIN32 | |
98 | - | |
99 | -BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd) | |
97 | +/* | |
98 | + * parse_ctlchar | |
99 | + * Parse an stty control-character specification. | |
100 | + * A cheap, non-complaining implementation. | |
101 | + */ | |
102 | +static char parse_ctlchar(char *s) | |
100 | 103 | { |
101 | -// Trace("%s - Library %s",__FUNCTION__,(dwcallpurpose == DLL_PROCESS_ATTACH) ? "Loaded" : "Unloaded"); | |
102 | - | |
103 | - if(dwcallpurpose == DLL_PROCESS_ATTACH) | |
104 | - get_version_info(); | |
105 | - | |
106 | - return TRUE; | |
104 | + if (!s || !*s) | |
105 | + return 0; | |
106 | + | |
107 | + if ((int) strlen(s) > 1) | |
108 | + { | |
109 | + if (*s != '^') | |
110 | + return 0; | |
111 | + else if (*(s+1) == '?') | |
112 | + return 0177; | |
113 | + else | |
114 | + return *(s+1) - '@'; | |
115 | + } else | |
116 | + return *s; | |
107 | 117 | } |
108 | 118 | |
109 | -#else | |
110 | - | |
111 | 119 | int lib3270_loaded(void) |
112 | 120 | { |
121 | + trace("%s",__FUNCTION__); | |
122 | + | |
123 | + ansictl.vintr = parse_ctlchar("^C"); | |
124 | + ansictl.vquit = parse_ctlchar("^\\"); | |
125 | + ansictl.verase = parse_ctlchar("^H"); | |
126 | + ansictl.vkill = parse_ctlchar("^U"); | |
127 | + ansictl.veof = parse_ctlchar("^D"); | |
128 | + ansictl.vwerase = parse_ctlchar("^W"); | |
129 | + ansictl.vrprnt = parse_ctlchar("^R"); | |
130 | + ansictl.vlnext = parse_ctlchar("^V"); | |
131 | + | |
113 | 132 | return 0; |
114 | 133 | } |
115 | 134 | |
116 | 135 | int lib3270_unloaded(void) |
117 | 136 | { |
137 | + trace("%s",__FUNCTION__); | |
118 | 138 | return 0; |
119 | 139 | } |
120 | 140 | |
141 | + | |
142 | +#if defined WIN32 | |
143 | + | |
144 | +BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd) | |
145 | +{ | |
146 | +// Trace("%s - Library %s",__FUNCTION__,(dwcallpurpose == DLL_PROCESS_ATTACH) ? "Loaded" : "Unloaded"); | |
147 | + | |
148 | + switch(dwcallpurpose) | |
149 | + { | |
150 | + case DLL_PROCESS_ATTACH: | |
151 | + get_version_info(); | |
152 | + lib3270_loaded(); | |
153 | + break; | |
154 | + | |
155 | + case DLL_PROCESS_DETACH: | |
156 | + lib3270_unloaded(); | |
157 | + break; | |
158 | + | |
159 | + } | |
160 | + | |
161 | + return TRUE; | |
162 | +} | |
163 | + | |
121 | 164 | #endif |
122 | 165 | |
123 | 166 | |
124 | 167 | #ifdef DEBUG |
125 | 168 | extern void lib3270_initialize(void) |
126 | 169 | { |
170 | + lib3270_loaded(); | |
127 | 171 | } |
128 | 172 | #endif |
129 | 173 | ... | ... |
host.c
... | ... | @@ -312,151 +312,7 @@ split_success: |
312 | 312 | } |
313 | 313 | */ |
314 | 314 | |
315 | -static int do_connect(H3270 *hSession) | |
316 | -{ | |
317 | -// char nb[2048]; // name buffer | |
318 | -// char *s; // temporary | |
319 | - char *chost = NULL; // to whom we will connect | |
320 | -// char *ps = CN; | |
321 | -// char *port = CN; | |
322 | - Boolean resolving; | |
323 | - Boolean pending; | |
324 | -// static Boolean ansi_host; | |
325 | -// Boolean has_colons = False; | |
326 | - | |
327 | - if (lib3270_connected(hSession) || hSession->auto_reconnect_inprogress) | |
328 | - return EBUSY; | |
329 | - | |
330 | - /* | |
331 | - // Skip leading blanks. | |
332 | - while (*n == ' ') | |
333 | - n++; | |
334 | - | |
335 | - if (!*n) | |
336 | - { | |
337 | - popup_an_error(hSession,_( "Invalid (empty) hostname" )); | |
338 | - return -1; | |
339 | - } | |
340 | - */ | |
341 | - | |
342 | - /* | |
343 | - // Save in a modifiable buffer. | |
344 | - (void) strncpy(nb, n, 2047); | |
345 | - | |
346 | - // Strip trailing blanks. | |
347 | - s = nb + strlen(nb) - 1; | |
348 | - while (*s == ' ') | |
349 | - *s-- = '\0'; | |
350 | - */ | |
351 | - | |
352 | - /* Remember this hostname, as the last hostname we connected to. */ | |
353 | - // lib3270_set_host(hSession,nb); | |
354 | - | |
355 | - /* | |
356 | - { | |
357 | - Boolean needed; | |
358 | - | |
359 | - // Strip off and remember leading qualifiers. | |
360 | - if ((s = split_host(hSession, nb, &ansi_host, &hSession->std_ds_host, | |
361 | - &hSession->passthru_host, &hSession->non_tn3270e_host, &hSession->ssl_host, | |
362 | - &hSession->no_login_host, hSession->luname, &port, | |
363 | - &needed)) == CN) | |
364 | - return EINVAL; | |
365 | - | |
366 | - chost = s; | |
367 | - | |
368 | - // Default the port. | |
369 | - if (port == CN) | |
370 | - port = "telnet"; | |
371 | - } | |
372 | - | |
373 | - // | |
374 | - // Store the original name in globals, even if we fail the connect | |
375 | - // later: | |
376 | - // current_host is the hostname part, stripped of qualifiers, luname | |
377 | - // and port number | |
378 | - // full_current_host is the entire string, for use in reconnecting | |
379 | - // | |
380 | - // | |
381 | - // Replace(hSession->current_host, CN); | |
382 | - | |
383 | - has_colons = (strchr(chost, ':') != NULL); | |
384 | - | |
385 | - Replace(hSession->host.qualified, | |
386 | - xs_buffer("%s%s%s%s:%s", | |
387 | - hSession->ssl_host? "L:": "", | |
388 | - has_colons? "[": "", | |
389 | - chost, | |
390 | - has_colons? "]": "", | |
391 | - port)); | |
392 | - */ | |
393 | - | |
394 | - /* Attempt contact. */ | |
395 | - hSession->ever_3270 = False; | |
396 | - hSession->ssl_host = 0; | |
397 | - | |
398 | - if(hSession->host.opt&LIB3270_CONNECT_OPTION_SSL) | |
399 | - { | |
400 | -#if defined(HAVE_LIBSSL) | |
401 | - hSession->ssl_host = 1; | |
402 | - ssl_init(hSession); | |
403 | -#else | |
404 | - popup_system_error(hSession, _( "SSL error" ), | |
405 | - _( "Unable to connect to secure hosts" ), | |
406 | - _( "This version of %s was built without support for secure sockets layer (SSL)." ), | |
407 | - PACKAGE_NAME | |
408 | - ); | |
409 | -#endif | |
410 | - } | |
411 | - | |
412 | - trace("Conneting to hostname=[%s] service=[%s]",hSession->host.current, hSession->host.srvc); | |
413 | - if(net_connect(hSession, hSession->host.current, hSession->host.srvc, 0, &resolving,&pending) != 0 && !resolving) | |
414 | - { | |
415 | - /* Redundantly signal a disconnect. */ | |
416 | - lib3270_set_disconnected(hSession); | |
417 | - return -1; | |
418 | - } | |
419 | - | |
420 | - chost = lib3270_free(chost); | |
421 | - | |
422 | - /* Still thinking about it? */ | |
423 | - if (resolving) | |
424 | - { | |
425 | - hSession->cstate = RESOLVING; | |
426 | - lib3270_st_changed(hSession, LIB3270_STATE_RESOLVING, True); | |
427 | - return 0; | |
428 | - } | |
429 | - | |
430 | - /* Success. */ | |
431 | - | |
432 | - /* Setup socket I/O. */ | |
433 | -// add_input_calls(hSession,net_input,net_exception); | |
434 | -#ifdef _WIN32 | |
435 | - hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception); | |
436 | - hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input); | |
437 | -#else | |
438 | - hSession->ns_exception_id = AddExcept(hSession->sock, hSession, net_exception); | |
439 | - hSession->ns_read_id = AddInput(hSession->sock, hSession, net_input); | |
440 | -#endif // WIN32 | |
441 | - | |
442 | - hSession->excepting = 1; | |
443 | - hSession->reading = 1; | |
444 | - | |
445 | - | |
446 | - /* Set state and tell the world. */ | |
447 | - if (pending) | |
448 | - { | |
449 | - hSession->cstate = PENDING; | |
450 | - lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True); | |
451 | - } | |
452 | - else | |
453 | - { | |
454 | - lib3270_set_connected(hSession); | |
455 | - } | |
456 | - | |
457 | - return 0; | |
458 | -} | |
459 | - | |
315 | +/* | |
460 | 316 | int lib3270_connect(H3270 *hSession, int wait) |
461 | 317 | { |
462 | 318 | int rc; |
... | ... | @@ -496,6 +352,7 @@ int lib3270_connect(H3270 *hSession, int wait) |
496 | 352 | |
497 | 353 | return rc; |
498 | 354 | } |
355 | +*/ | |
499 | 356 | |
500 | 357 | /* |
501 | 358 | * Called from timer to attempt an automatic reconnection. |
... | ... | @@ -725,6 +582,12 @@ LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) |
725 | 582 | return h->host.current; |
726 | 583 | } |
727 | 584 | |
585 | +LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) | |
586 | +{ | |
587 | + CHECK_SESSION_HANDLE(h); | |
588 | + return h->host.full; | |
589 | +} | |
590 | + | |
728 | 591 | /* |
729 | 592 | LIB3270_EXPORT int lib3270_reconnect(H3270 *hSession,int wait) |
730 | 593 | { | ... | ... |
sources.mak
... | ... | @@ -33,7 +33,7 @@ TERMINAL_SOURCES = bounds.c ctlr.c util.c toggles.c screen.c selection.c kybd.c |
33 | 33 | # tables.c utf8.c |
34 | 34 | |
35 | 35 | # Network I/O Sources |
36 | -NETWORK_SOURCES = iocalls.c proxy.c connect.c | |
36 | +NETWORK_SOURCES = iocalls.c connect.c | |
37 | 37 | |
38 | 38 | # Full library sources |
39 | 39 | SOURCES = $(TERMINAL_SOURCES) $(NETWORK_SOURCES) ft.c ft_cut.c ft_dft.c glue.c resources.c \ | ... | ... |
telnet.c
... | ... | @@ -120,7 +120,8 @@ |
120 | 120 | #define E_OPT(n) (1 << (n)) |
121 | 121 | #endif // X3270_TN3270E |
122 | 122 | |
123 | -#if defined(X3270_ANSI) /*[*/ | |
123 | +/* | |
124 | +#if defined(X3270_ANSI) | |
124 | 125 | static char vintr; |
125 | 126 | static char vquit; |
126 | 127 | static char verase; |
... | ... | @@ -129,7 +130,10 @@ static char veof; |
129 | 130 | static char vwerase; |
130 | 131 | static char vrprnt; |
131 | 132 | static char vlnext; |
132 | -#endif /*]*/ | |
133 | +#endif | |
134 | +*/ | |
135 | + | |
136 | +struct _ansictl ansictl = { 0 }; | |
133 | 137 | |
134 | 138 | static int telnet_fsm(H3270 *session, unsigned char c); |
135 | 139 | static void net_rawout(H3270 *session, unsigned const char *buf, size_t len); |
... | ... | @@ -164,7 +168,7 @@ static void do_rprnt(H3270 *hSession, char c); |
164 | 168 | static void do_eof(H3270 *hSession, char c); |
165 | 169 | static void do_eol(H3270 *hSession, char c); |
166 | 170 | static void do_lnext(H3270 *hSession, char c); |
167 | -static char parse_ctlchar(char *s); | |
171 | +// static char parse_ctlchar(char *s); | |
168 | 172 | static void cooked_init(H3270 *hSession); |
169 | 173 | #endif /*]*/ |
170 | 174 | |
... | ... | @@ -270,7 +274,8 @@ static const char *trsp_flag[2] = { "POSITIVE-RESPONSE", "NEGATIVE-RESPONSE" }; |
270 | 274 | |
271 | 275 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
272 | 276 | |
273 | -#if defined(_WIN32) /*[*/ | |
277 | +/* | |
278 | +#if defined(_WIN32) | |
274 | 279 | void sockstart(H3270 *session) |
275 | 280 | { |
276 | 281 | static int initted = 0; |
... | ... | @@ -305,7 +310,8 @@ void sockstart(H3270 *session) |
305 | 310 | _exit(1); |
306 | 311 | } |
307 | 312 | } |
308 | -#endif /*]*/ | |
313 | +#endif | |
314 | +*/ | |
309 | 315 | |
310 | 316 | static union { |
311 | 317 | struct sockaddr sa; |
... | ... | @@ -323,6 +329,7 @@ void popup_a_sockerr(H3270 *hSession, char *fmt, ...) |
323 | 329 | #else |
324 | 330 | const char *msg = strerror(errno); |
325 | 331 | #endif // WIN32 |
332 | + | |
326 | 333 | va_list args; |
327 | 334 | char *text; |
328 | 335 | |
... | ... | @@ -332,11 +339,17 @@ void popup_a_sockerr(H3270 *hSession, char *fmt, ...) |
332 | 339 | |
333 | 340 | lib3270_write_log(hSession, "3270", "Network error:\n%s\n%s",text,msg); |
334 | 341 | |
335 | - lib3270_popup_dialog(hSession, LIB3270_NOTIFY_ERROR, _( "Network error" ), text, "%s", msg); | |
342 | + lib3270_popup_dialog( hSession, | |
343 | + LIB3270_NOTIFY_ERROR, | |
344 | + _( "Network error" ), | |
345 | + text, | |
346 | + "%s", msg); | |
347 | + | |
336 | 348 | |
337 | 349 | lib3270_free(text); |
338 | 350 | } |
339 | 351 | |
352 | +/* | |
340 | 353 | #pragma pack(1) |
341 | 354 | struct connect_parm |
342 | 355 | { |
... | ... | @@ -347,7 +360,9 @@ struct connect_parm |
347 | 360 | int err; |
348 | 361 | }; |
349 | 362 | #pragma pack() |
363 | +*/ | |
350 | 364 | |
365 | +/* | |
351 | 366 | static int do_connect_sock(H3270 *h, struct connect_parm *p) |
352 | 367 | { |
353 | 368 | #ifdef WIN32 |
... | ... | @@ -428,7 +443,9 @@ static int do_connect_sock(H3270 *h, struct connect_parm *p) |
428 | 443 | |
429 | 444 | return 0; |
430 | 445 | } |
446 | +*/ | |
431 | 447 | |
448 | +/* | |
432 | 449 | static int connect_sock(H3270 *hSession, int sockfd, const struct sockaddr *addr, socklen_t addrlen) |
433 | 450 | { |
434 | 451 | struct connect_parm p = { sizeof(struct connect_parm), sockfd, addr, addrlen, -1 }; |
... | ... | @@ -439,7 +456,7 @@ static int connect_sock(H3270 *hSession, int sockfd, const struct sockaddr *addr |
439 | 456 | |
440 | 457 | return p.err; |
441 | 458 | } |
442 | - | |
459 | +*/ | |
443 | 460 | |
444 | 461 | /** |
445 | 462 | * Establish a telnet socket to the given host passed as an argument. |
... | ... | @@ -450,7 +467,7 @@ static int connect_sock(H3270 *hSession, int sockfd, const struct sockaddr *addr |
450 | 467 | * @param session Handle to the session descriptor. |
451 | 468 | * |
452 | 469 | * @return 0 if ok, non zero if failed |
453 | - */ | |
470 | + */ /* | |
454 | 471 | int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Boolean *resolving, Boolean *pending) |
455 | 472 | { |
456 | 473 | // struct servent * sp; |
... | ... | @@ -467,9 +484,9 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
467 | 484 | int optval; |
468 | 485 | char errmsg[1024]; |
469 | 486 | int rc; |
470 | -#if defined(OMTU) /*[*/ | |
487 | +#if defined(OMTU) | |
471 | 488 | int mtu = OMTU; |
472 | -#endif /*]*/ | |
489 | +#endif | |
473 | 490 | |
474 | 491 | #define close_fail { (void) SOCK_CLOSE(session->sock); session->sock = -1; return -1; } |
475 | 492 | |
... | ... | @@ -482,7 +499,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
482 | 499 | // if (session->netrbuf == (unsigned char *)NULL) |
483 | 500 | // session->netrbuf = (unsigned char *)lib3270_malloc(BUFSZ); |
484 | 501 | |
485 | -#if defined(X3270_ANSI) /*[*/ | |
502 | +#if defined(X3270_ANSI) | |
486 | 503 | if (!t_valid) |
487 | 504 | { |
488 | 505 | vintr = parse_ctlchar("^C"); |
... | ... | @@ -496,14 +513,14 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
496 | 513 | |
497 | 514 | t_valid = 1; |
498 | 515 | } |
499 | -#endif /*]*/ | |
516 | +#endif | |
500 | 517 | |
501 | 518 | *resolving = False; |
502 | 519 | *pending = False; |
503 | 520 | |
504 | 521 | // Replace(session->hostname, NewString(host)); |
505 | 522 | |
506 | - /* get the passthru host and port number */ | |
523 | + // get the passthru host and port number | |
507 | 524 | if (session->passthru_host) |
508 | 525 | { |
509 | 526 | #if defined(HAVE_GETADDRINFO) |
... | ... | @@ -567,7 +584,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
567 | 584 | return -1; |
568 | 585 | } |
569 | 586 | |
570 | - /* fill in the socket address of the given host */ | |
587 | + // fill in the socket address of the given host | |
571 | 588 | (void) memset((char *) &haddr, 0, sizeof(haddr)); |
572 | 589 | if (session->passthru_host) |
573 | 590 | { |
... | ... | @@ -593,14 +610,14 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
593 | 610 | } |
594 | 611 | } |
595 | 612 | |
596 | - /* create the socket */ | |
613 | + // create the socket | |
597 | 614 | if((session->sock = socket(haddr.sa.sa_family, SOCK_STREAM, 0)) == -1) |
598 | 615 | { |
599 | 616 | popup_a_sockerr(session, N_( "socket" ) ); |
600 | 617 | return -1; |
601 | 618 | } |
602 | 619 | |
603 | - /* set options for inline out-of-band data and keepalives */ | |
620 | + // set options for inline out-of-band data and keepalives | |
604 | 621 | if (setsockopt(session->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&on,sizeof(on)) < 0) |
605 | 622 | { |
606 | 623 | popup_a_sockerr(session, N_( "setsockopt(%s)" ), "SO_OOBINLINE"); |
... | ... | @@ -615,22 +632,22 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
615 | 632 | } |
616 | 633 | #endif |
617 | 634 | |
618 | - /* set the socket to be non-delaying during connect */ | |
635 | + // set the socket to be non-delaying during connect | |
619 | 636 | if(non_blocking(session,False) < 0) |
620 | 637 | close_fail; |
621 | 638 | |
622 | 639 | #if !defined(_WIN32) |
623 | - /* don't share the socket with our children */ | |
640 | + // don't share the socket with our children | |
624 | 641 | (void) fcntl(session->sock, F_SETFD, 1); |
625 | 642 | #endif |
626 | 643 | |
627 | - /* init ssl */ | |
644 | + // init ssl | |
628 | 645 | #if defined(HAVE_LIBSSL) |
629 | 646 | if (session->ssl_host) |
630 | 647 | ssl_init(session); |
631 | 648 | #endif |
632 | 649 | |
633 | - /* connect */ | |
650 | + // connect | |
634 | 651 | status_connecting(session,1); |
635 | 652 | rc = connect_sock(session, session->sock, &haddr.sa,ha_len); |
636 | 653 | |
... | ... | @@ -671,15 +688,8 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
671 | 688 | |
672 | 689 | snprintf(session->full_model_name,LIB3270_FULL_MODEL_NAME_LENGTH,"IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num); |
673 | 690 | |
674 | - /* set up temporary termtype | |
675 | - if (session->termname == CN && session->std_ds_host) | |
676 | - { | |
677 | - sprintf(session->ttype_tmpval, "IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num); | |
678 | - session->termtype = session->ttype_tmpval; | |
679 | - } | |
680 | - */ | |
681 | 691 | |
682 | - /* all done */ | |
692 | + // all done | |
683 | 693 | #if defined(_WIN32) |
684 | 694 | if(session->sockEvent == NULL) |
685 | 695 | { |
... | ... | @@ -718,6 +728,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
718 | 728 | return 0; |
719 | 729 | } |
720 | 730 | #undef close_fail |
731 | +*/ | |
721 | 732 | |
722 | 733 | /* Set up the LU list. */ |
723 | 734 | static void setup_lus(H3270 *hSession) |
... | ... | @@ -2113,21 +2124,21 @@ static void net_cookout(H3270 *hSession, const char *buf, int len) |
2113 | 2124 | /* Control chars. */ |
2114 | 2125 | if (c == '\n') |
2115 | 2126 | do_eol(hSession,c); |
2116 | - else if (c == vintr) | |
2127 | + else if (c == ansictl.vintr) | |
2117 | 2128 | do_intr(hSession, c); |
2118 | - else if (c == vquit) | |
2129 | + else if (c == ansictl.vquit) | |
2119 | 2130 | do_quit(hSession,c); |
2120 | - else if (c == verase) | |
2131 | + else if (c == ansictl.verase) | |
2121 | 2132 | do_cerase(hSession,c); |
2122 | - else if (c == vkill) | |
2133 | + else if (c == ansictl.vkill) | |
2123 | 2134 | do_kill(hSession,c); |
2124 | - else if (c == vwerase) | |
2135 | + else if (c == ansictl.vwerase) | |
2125 | 2136 | do_werase(hSession,c); |
2126 | - else if (c == vrprnt) | |
2137 | + else if (c == ansictl.vrprnt) | |
2127 | 2138 | do_rprnt(hSession,c); |
2128 | - else if (c == veof) | |
2139 | + else if (c == ansictl.veof) | |
2129 | 2140 | do_eof(hSession,c); |
2130 | - else if (c == vlnext) | |
2141 | + else if (c == ansictl.vlnext) | |
2131 | 2142 | do_lnext(hSession,c); |
2132 | 2143 | else if (c == 0x08 || c == 0x7f) /* Yes, a hack. */ |
2133 | 2144 | do_cerase(hSession,c); |
... | ... | @@ -2873,7 +2884,7 @@ void net_sends(H3270 *hSession,const char *s) |
2873 | 2884 | */ |
2874 | 2885 | void net_send_erase(H3270 *hSession) |
2875 | 2886 | { |
2876 | - net_cookout(hSession, &verase, 1); | |
2887 | + net_cookout(hSession, &ansictl.verase, 1); | |
2877 | 2888 | } |
2878 | 2889 | |
2879 | 2890 | /** |
... | ... | @@ -2881,7 +2892,7 @@ void net_send_erase(H3270 *hSession) |
2881 | 2892 | */ |
2882 | 2893 | void net_send_kill(H3270 *hSession) |
2883 | 2894 | { |
2884 | - net_cookout(hSession, &vkill, 1); | |
2895 | + net_cookout(hSession, &ansictl.vkill, 1); | |
2885 | 2896 | } |
2886 | 2897 | |
2887 | 2898 | /** |
... | ... | @@ -2889,7 +2900,7 @@ void net_send_kill(H3270 *hSession) |
2889 | 2900 | */ |
2890 | 2901 | void net_send_werase(H3270 *hSession) |
2891 | 2902 | { |
2892 | - net_cookout(hSession, &vwerase, 1); | |
2903 | + net_cookout(hSession, &ansictl.vwerase, 1); | |
2893 | 2904 | } |
2894 | 2905 | #endif /*]*/ |
2895 | 2906 | |
... | ... | @@ -2991,29 +3002,6 @@ void net_abort(H3270 *hSession) |
2991 | 3002 | } |
2992 | 3003 | #endif /*]*/ |
2993 | 3004 | |
2994 | -#if defined(X3270_ANSI) /*[*/ | |
2995 | -/* | |
2996 | - * parse_ctlchar | |
2997 | - * Parse an stty control-character specification. | |
2998 | - * A cheap, non-complaining implementation. | |
2999 | - */ | |
3000 | -static char | |
3001 | -parse_ctlchar(char *s) | |
3002 | -{ | |
3003 | - if (!s || !*s) | |
3004 | - return 0; | |
3005 | - if ((int) strlen(s) > 1) { | |
3006 | - if (*s != '^') | |
3007 | - return 0; | |
3008 | - else if (*(s+1) == '?') | |
3009 | - return 0177; | |
3010 | - else | |
3011 | - return *(s+1) - '@'; | |
3012 | - } else | |
3013 | - return *s; | |
3014 | -} | |
3015 | -#endif /*]*/ | |
3016 | - | |
3017 | 3005 | /* Return the local address for the socket. */ |
3018 | 3006 | int net_getsockname(const H3270 *session, void *buf, int *len) |
3019 | 3007 | { | ... | ... |