Commit 97080b25c1df344997d12458bfea6d5706338ccc
1 parent
db04ac3f
Exists in
master
and in
3 other branches
Splitting ssl & host_type properties.
Showing
14 changed files
with
185 additions
and
534 deletions
Show diff stats
src/include/lib3270.h
... | ... | @@ -278,33 +278,27 @@ |
278 | 278 | |
279 | 279 | |
280 | 280 | /** |
281 | - * Connect options | |
281 | + * @brief Host options | |
282 | 282 | * |
283 | 283 | */ |
284 | - typedef enum lib3270_option | |
284 | + typedef enum lib3270_host_type | |
285 | 285 | { |
286 | - /* Host types */ | |
287 | - LIB3270_OPTION_AS400 = 0x0001, /**< AS400 host - Prefix every PF with PA1 */ | |
288 | - LIB3270_OPTION_TSO = 0x0002, /**< Host is TSO? */ | |
289 | - LIB3270_OPTION_S390 = 0x0006, /**< Host is S390? (TSO included) */ | |
286 | + // Host types | |
287 | + LIB3270_HOST_AS400 = 0x0001, ///< AS400 host - Prefix every PF with PA1 | |
288 | + LIB3270_HOST_TSO = 0x0002, ///< Host is TSO? | |
289 | + LIB3270_HOST_S390 = 0x0006, ///< Host is S390? (TSO included) | |
290 | 290 | |
291 | - /* Other options */ | |
292 | - LIB3270_OPTION_SSL = 0x0010, /**< Secure connection ? */ | |
291 | + } LIB3270_HOST_TYPE; | |
293 | 292 | |
293 | + #define LIB3270_HOSTTYPE_DEFAULT LIB3270_HOST_S390 | |
294 | 294 | |
295 | - LIB3270_OPTION_WAIT = 0x8000 /**< Wait for session ready on connect ? */ | |
296 | - } LIB3270_OPTION; | |
297 | - | |
298 | - #define LIB3270_OPTION_HOST_TYPE 0x0007 | |
299 | - #define LIB3270_OPTION_DEFAULTS LIB3270_OPTION_S390 | |
300 | - | |
301 | - typedef struct _lib3270_option_entry | |
295 | + typedef struct _LIB3270_HOST_TYPE_entry | |
302 | 296 | { |
303 | - LIB3270_OPTION option; | |
304 | - const char * name; | |
305 | - const char * description; | |
306 | - const char * tooltip; | |
307 | - } LIB3270_OPTION_ENTRY; | |
297 | + LIB3270_HOST_TYPE type; | |
298 | + const char * name; | |
299 | + const char * description; | |
300 | + const char * tooltip; | |
301 | + } LIB3270_HOST_TYPE_ENTRY; | |
308 | 302 | |
309 | 303 | /** |
310 | 304 | * SSL state |
... | ... | @@ -517,7 +511,9 @@ |
517 | 511 | * @param h Session handle. |
518 | 512 | * |
519 | 513 | */ |
520 | - LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession); | |
514 | + LIB3270_EXPORT LIB3270_HOST_TYPE lib3270_get_host_type(H3270 *hSession); | |
515 | + | |
516 | + LIB3270_EXPORT const char * lib3270_get_host_type_name(H3270 *hSession); | |
521 | 517 | |
522 | 518 | /** |
523 | 519 | * @brief Get URL of the hostname for the connect/reconnect operations. |
... | ... | @@ -531,17 +527,17 @@ |
531 | 527 | |
532 | 528 | |
533 | 529 | /** |
534 | - * @brief Network connect operation, keep main loop running | |
530 | + * @brief Reconnect to host. | |
535 | 531 | * |
536 | 532 | * @param h Session handle. |
537 | - * @param seconds Seconds to wait for connection . | |
533 | + * @param seconds Seconds to wait for connection. | |
538 | 534 | * |
539 | 535 | * @return 0 for success, EAGAIN if auto-reconnect is in progress, EBUSY if connected, ENOTCONN if connection has failed, -1 on unexpected failure. |
540 | 536 | * |
541 | 537 | */ |
542 | - LIB3270_EXPORT int lib3270_connect(H3270 *h,int seconds); | |
538 | + LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int seconds); | |
543 | 539 | |
544 | - LIB3270_EXPORT int lib3270_set_connected(H3270 *h,int state); | |
540 | +// LIB3270_EXPORT int lib3270_set_connected(H3270 *h,int state); | |
545 | 541 | |
546 | 542 | /** |
547 | 543 | * @brief Connect to defined host, keep main loop running. |
... | ... | @@ -554,7 +550,7 @@ |
554 | 550 | * @return 0 for success, EAGAIN if auto-reconnect is in progress, EBUSY if connected, ENOTCONN if connection has failed, -1 on unexpected failure. |
555 | 551 | * |
556 | 552 | */ |
557 | - LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_OPTION opt); | |
553 | +// LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_HOST_TYPE opt); | |
558 | 554 | |
559 | 555 | /** |
560 | 556 | * @brief Connect by URL |
... | ... | @@ -1249,17 +1245,16 @@ |
1249 | 1245 | |
1250 | 1246 | LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession); |
1251 | 1247 | |
1252 | - LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt); | |
1253 | 1248 | |
1254 | 1249 | LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype); |
1255 | 1250 | LIB3270_EXPORT int lib3270_get_color_type(H3270 *hSession); |
1256 | 1251 | |
1257 | - LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name); | |
1258 | - LIB3270_EXPORT const char * lib3270_get_host_type(H3270 *hSession); | |
1252 | + LIB3270_EXPORT int lib3270_set_host_type_by_name(H3270 *hSession, const char *name); | |
1253 | + LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, LIB3270_HOST_TYPE opt); | |
1259 | 1254 | |
1260 | - LIB3270_EXPORT LIB3270_OPTION lib3270_parse_host_type(const char *name); | |
1255 | + LIB3270_EXPORT LIB3270_HOST_TYPE lib3270_parse_host_type(const char *name); | |
1261 | 1256 | |
1262 | - LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void); | |
1257 | + LIB3270_EXPORT const LIB3270_HOST_TYPE_ENTRY * lib3270_get_option_list(void); | |
1263 | 1258 | |
1264 | 1259 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr); |
1265 | 1260 | |
... | ... | @@ -1277,14 +1272,28 @@ |
1277 | 1272 | LIB3270_EXPORT int lib3270_run_task(H3270 *hSession, int(*callback)(H3270 *h, void *), void *parm); |
1278 | 1273 | |
1279 | 1274 | /** |
1280 | - * The host is TSO? | |
1275 | + * @brief The host is TSO? | |
1281 | 1276 | * |
1282 | 1277 | * @param hSession Session Handle |
1283 | 1278 | * |
1284 | 1279 | * @return Non zero if the host is TSO. |
1285 | 1280 | * |
1286 | 1281 | */ |
1287 | - LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession); | |
1282 | + LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession); | |
1283 | + | |
1284 | + LIB3270_EXPORT int lib3270_set_tso(H3270 *hSession, int on); | |
1285 | + | |
1286 | + /** | |
1287 | + * @brief Host is AS400 (Prefix every PF with PA1). | |
1288 | + * | |
1289 | + * @param hSession Session Handle | |
1290 | + * | |
1291 | + * @return Non zero if the host is AS400. | |
1292 | + * | |
1293 | + */ | |
1294 | + LIB3270_EXPORT int lib3270_is_as400(H3270 *hSession); | |
1295 | + | |
1296 | + LIB3270_EXPORT int lib3270_set_as400(H3270 *hSession, int on); | |
1288 | 1297 | |
1289 | 1298 | #ifdef WIN32 |
1290 | 1299 | LIB3270_EXPORT const char * lib3270_win32_strerror(int e); | ... | ... |
src/include/lib3270/macros.h
... | ... | @@ -1,39 +0,0 @@ |
1 | -/* | |
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., 51 Franklin | |
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | - * | |
21 | - * Este programa está nomeado como macros.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 de Mendonça) | |
27 | - * licinio@bb.com.br (Licínio Luis Branco) | |
28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | |
30 | - * | |
31 | - */ | |
32 | - | |
33 | - #error Deprecated | |
34 | - | |
35 | - | |
36 | - // #define LIB3270_MACRO( name ) LIB3270_EXPORT char * lib3270_macro_ ## name (H3270 *hSession, int argc, const char **argv) | |
37 | - | |
38 | -// LIB3270_EXPORT char * lib3270_run_macro(H3270 *session, const char **argv); | |
39 | - |
src/lib3270/ft.c
... | ... | @@ -439,13 +439,13 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
439 | 439 | (ft->flags & LIB3270_FT_OPTION_APPEND) ? " APPEND" : "" |
440 | 440 | ); |
441 | 441 | |
442 | - trace("tso=%s",hSession->options & LIB3270_OPTION_TSO ? "yes" : "No"); | |
442 | + trace("tso=%s",lib3270_is_tso(hSession) ? "yes" : "No"); | |
443 | 443 | |
444 | 444 | if(!(ft->flags & LIB3270_FT_OPTION_RECEIVE)) |
445 | 445 | { |
446 | 446 | // Sending file |
447 | 447 | |
448 | - if(hSession->options & LIB3270_OPTION_TSO) | |
448 | + if(lib3270_is_tso(hSession)) | |
449 | 449 | { |
450 | 450 | // TSO Host |
451 | 451 | if(recfm > 0) |
... | ... | @@ -492,7 +492,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
492 | 492 | |
493 | 493 | if(*op) |
494 | 494 | { |
495 | - if(hSession->options & LIB3270_OPTION_TSO) | |
495 | + if(lib3270_is_tso(hSession)) | |
496 | 496 | snconcat(buffer,4095," %s",op+1); |
497 | 497 | else |
498 | 498 | snconcat(buffer,4095," (%s",op+1); | ... | ... |
src/lib3270/host.c
... | ... | @@ -58,11 +58,21 @@ |
58 | 58 | /** |
59 | 59 | * @brief Called from timer to attempt an automatic reconnection. |
60 | 60 | */ |
61 | -int lib3270_reconnect(H3270 *hSession) | |
61 | +int lib3270_check_for_auto_reconnect(H3270 *hSession) | |
62 | 62 | { |
63 | - lib3270_write_log(hSession,"3270","Starting auto-reconnect on %s",lib3270_get_url(hSession)); | |
64 | - hSession->auto_reconnect_inprogress = 0; | |
65 | - lib3270_connect(hSession,0); | |
63 | + if(hSession->popups) | |
64 | + { | |
65 | + lib3270_write_log(hSession,"3270","Delaying auto-reconnect. There's %u pending popup(s)",(unsigned int) hSession->popups); | |
66 | + return 1; | |
67 | + } | |
68 | + | |
69 | + if(hSession->auto_reconnect_inprogress) | |
70 | + { | |
71 | + lib3270_write_log(hSession,"3270","Starting auto-reconnect on %s",lib3270_get_url(hSession)); | |
72 | + lib3270_reconnect(hSession,0); | |
73 | + hSession->auto_reconnect_inprogress = 0; | |
74 | + } | |
75 | + | |
66 | 76 | return 0; |
67 | 77 | } |
68 | 78 | |
... | ... | @@ -86,7 +96,7 @@ int host_disconnect(H3270 *hSession, int failed) |
86 | 96 | { |
87 | 97 | /* Schedule an automatic reconnection. */ |
88 | 98 | hSession->auto_reconnect_inprogress = 1; |
89 | - (void) AddTimer(failed ? RECONNECT_ERR_MS : RECONNECT_MS, hSession, lib3270_reconnect); | |
99 | + (void) AddTimer(failed ? RECONNECT_ERR_MS : RECONNECT_MS, hSession, lib3270_check_for_auto_reconnect); | |
90 | 100 | } |
91 | 101 | |
92 | 102 | /* |
... | ... | @@ -219,12 +229,16 @@ static void update_host(H3270 *h) |
219 | 229 | Replace(h->host.full, |
220 | 230 | lib3270_strdup_printf( |
221 | 231 | "%s%s:%s", |
222 | - h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
232 | +#ifdef HAVE_LIBSSL | |
233 | + (h->ssl.enabled ? "tn3270s://" : "tn3270://"), | |
234 | +#else | |
235 | + "tn3270://", | |
236 | +#endif // HAVE_LIBSSL | |
223 | 237 | h->host.current, |
224 | 238 | h->host.srvc |
225 | 239 | )); |
226 | 240 | |
227 | - trace("hosturl=[%s] ssl=%s",h->host.full,(h->options&LIB3270_OPTION_SSL) ? "yes" : "no"); | |
241 | + trace("hosturl=[%s] ssl=%s",h->host.full,h->ssl.enabled ? "yes" : "no"); | |
228 | 242 | |
229 | 243 | } |
230 | 244 | |
... | ... | @@ -269,18 +283,21 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) |
269 | 283 | { |
270 | 284 | static const struct _sch |
271 | 285 | { |
272 | - LIB3270_OPTION opt; | |
286 | + char ssl; | |
273 | 287 | const char * text; |
274 | 288 | const char * srvc; |
275 | 289 | } sch[] = |
276 | 290 | { |
277 | - { LIB3270_OPTION_DEFAULTS, "tn3270://", "telnet" }, | |
278 | - { LIB3270_OPTION_SSL, "tn3270s://", "telnets" }, | |
279 | - { LIB3270_OPTION_DEFAULTS, "telnet://", "telnet" }, | |
280 | - { LIB3270_OPTION_DEFAULTS, "telnets://", "telnets" }, | |
281 | - { LIB3270_OPTION_SSL, "L://", "telnets" }, | |
291 | +#ifdef HAVE_LIBSSL | |
292 | + { 1, "tn3270s://", "telnets" }, | |
293 | + { 1, "telnets://", "telnets" }, | |
294 | + { 1, "L://", "telnets" }, | |
295 | + { 1, "L:", "telnets" }, | |
296 | +#endif // HAVE_LIBSSL | |
297 | + | |
298 | + { 0, "tn3270://", "telnet" }, | |
299 | + { 0, "telnet://", "telnet" } | |
282 | 300 | |
283 | - { LIB3270_OPTION_SSL, "L:", "telnets" } // The compatibility should be the last option | |
284 | 301 | }; |
285 | 302 | |
286 | 303 | char * str = strdup(n); |
... | ... | @@ -291,16 +308,21 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) |
291 | 308 | int f; |
292 | 309 | |
293 | 310 | trace("%s(%s)",__FUNCTION__,str); |
294 | - h->options = LIB3270_OPTION_DEFAULTS; | |
311 | + | |
312 | +#ifdef HAVE_LIBSSL | |
313 | + h->ssl.enabled = 0; | |
314 | +#endif // HAVE_LIBSSL | |
295 | 315 | |
296 | 316 | for(f=0;f < sizeof(sch)/sizeof(sch[0]);f++) |
297 | 317 | { |
298 | 318 | size_t sz = strlen(sch[f].text); |
299 | 319 | if(!strncasecmp(hostname,sch[f].text,sz)) |
300 | 320 | { |
301 | - h->options = sch[f].opt; | |
302 | - srvc = sch[f].srvc; | |
303 | - hostname += sz; | |
321 | +#ifdef HAVE_LIBSSL | |
322 | + h->ssl.enabled = sch[f].ssl; | |
323 | +#endif // HAVE_LIBSSL | |
324 | + srvc = sch[f].srvc; | |
325 | + hostname += sz; | |
304 | 326 | break; |
305 | 327 | } |
306 | 328 | } |
... | ... | @@ -348,25 +370,18 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) |
348 | 370 | *(val++) = 0; |
349 | 371 | |
350 | 372 | if(lib3270_set_string_property(h, var, val, 0) == 0) |
351 | - { | |
352 | 373 | continue; |
353 | - } | |
354 | - | |
355 | - /* | |
356 | - if(!(strcasecmp(var,"lu") && strcasecmp(var,"luname"))) | |
357 | - { | |
358 | - lib3270_set_luname(h, val); | |
359 | - // strncpy(h->luname,val,LIB3270_LUNAME_LENGTH); | |
360 | - } | |
361 | - else | |
362 | - { | |
363 | - lib3270_write_log(h,"","Ignoring invalid URL attribute \"%s\"",var); | |
364 | - } | |
365 | - */ | |
366 | 374 | |
367 | 375 | lib3270_write_log(h,"","Can't set attribute \"%s\": %s",var,strerror(errno)); |
368 | 376 | |
369 | 377 | } |
378 | + else | |
379 | + { | |
380 | + if(lib3270_set_int_property(h,var,1,0)) | |
381 | + continue; | |
382 | + | |
383 | + lib3270_write_log(h,"","Can't set attribute \"%s\": %s",var,strerror(errno)); | |
384 | + } | |
370 | 385 | |
371 | 386 | } |
372 | 387 | ... | ... |
src/lib3270/kybd.c
... | ... | @@ -534,14 +534,14 @@ LIB3270_EXPORT int lib3270_pfkey(H3270 *hSession, int key) |
534 | 534 | |
535 | 535 | if (hSession->kybdlock) |
536 | 536 | { |
537 | - if(hSession->options & LIB3270_OPTION_AS400) | |
537 | + if(hSession->host_type & LIB3270_HOST_AS400) | |
538 | 538 | enq_key(hSession,pa_xlate[0]); |
539 | 539 | |
540 | 540 | enq_key(hSession,pf_xlate[key-1]); |
541 | 541 | } |
542 | 542 | else |
543 | 543 | { |
544 | - if(hSession->options & LIB3270_OPTION_AS400) | |
544 | + if(hSession->host_type & LIB3270_HOST_AS400) | |
545 | 545 | key_AID(hSession,pa_xlate[0]); |
546 | 546 | |
547 | 547 | key_AID(hSession,pf_xlate[key-1]); | ... | ... |
src/lib3270/linux/connect.c
... | ... | @@ -124,11 +124,12 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
124 | 124 | lib3270_set_url(hSession,url); |
125 | 125 | } |
126 | 126 | |
127 | - return lib3270_connect(hSession, wait); | |
127 | + return lib3270_reconnect(hSession, wait); | |
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_OPTION opt) | |
131 | + /* | |
132 | + LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_HOST_TYPE opt) | |
132 | 133 | { |
133 | 134 | CHECK_SESSION_HANDLE(hSession); |
134 | 135 | |
... | ... | @@ -155,22 +156,23 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
155 | 156 | hostname = name; |
156 | 157 | } |
157 | 158 | |
158 | - hSession->options = opt & ~LIB3270_OPTION_WAIT; | |
159 | + hSession->options = opt & ~LIB3270_HOST_TYPE_WAIT; | |
159 | 160 | Replace(hSession->host.current,strdup(hostname)); |
160 | 161 | Replace(hSession->host.srvc,strdup(srvc)); |
161 | 162 | |
162 | 163 | Replace(hSession->host.full, |
163 | 164 | lib3270_strdup_printf( |
164 | 165 | "%s%s:%s", |
165 | - opt&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
166 | + opt&LIB3270_HOST_TYPE_SSL ? "tn3270s://" : "tn3270://", | |
166 | 167 | hostname, |
167 | 168 | srvc )); |
168 | 169 | |
169 | 170 | trace("current_host=\"%s\"",hSession->host.current); |
170 | 171 | |
171 | - return lib3270_connect(hSession,opt & LIB3270_OPTION_WAIT); | |
172 | + return lib3270_reconnect(hSession,opt & LIB3270_HOST_TYPE_WAIT); | |
172 | 173 | |
173 | 174 | } |
175 | + */ | |
174 | 176 | |
175 | 177 | struct resolver |
176 | 178 | { |
... | ... | @@ -223,7 +225,7 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
223 | 225 | |
224 | 226 | } |
225 | 227 | |
226 | - int lib3270_connect(H3270 *hSession, int seconds) | |
228 | + int lib3270_reconnect(H3270 *hSession, int seconds) | |
227 | 229 | { |
228 | 230 | int optval; |
229 | 231 | struct resolver host; |
... | ... | @@ -283,22 +285,13 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
283 | 285 | hSession->ever_3270 = False; |
284 | 286 | hSession->ssl.host = 0; |
285 | 287 | |
286 | - if(hSession->options&LIB3270_OPTION_SSL) | |
287 | - { | |
288 | 288 | #if defined(HAVE_LIBSSL) |
289 | + if(hSession->ssl.enabled) | |
290 | + { | |
289 | 291 | hSession->ssl.host = 1; |
290 | 292 | ssl_init(hSession); |
291 | -#else | |
292 | - lib3270_popup_dialog( hSession, | |
293 | - LIB3270_NOTIFY_ERROR, | |
294 | - _( "SSL error" ), | |
295 | - _( "Unable to connect to secure hosts" ), | |
296 | - _( "This version of %s was built without support for secure sockets layer (SSL)." ), | |
297 | - PACKAGE_NAME); | |
298 | - | |
299 | - return errno = EINVAL; | |
300 | -#endif // HAVE_LIBSSL | |
301 | 293 | } |
294 | +#endif // HAVE_LIBSSL | |
302 | 295 | |
303 | 296 | // set options for inline out-of-band data and keepalives |
304 | 297 | optval = 1; | ... | ... |
src/lib3270/macros.c
... | ... | @@ -1,362 +0,0 @@ |
1 | -/* | |
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., 51 Franklin | |
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | - * | |
21 | - * Este programa está nomeado como macros.c 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 | - * licinio@bb.com.br (Licínio Luis Branco) | |
28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | |
30 | - * | |
31 | - */ | |
32 | - | |
33 | -/* | |
34 | -#ifdef WIN32 | |
35 | - #include <winsock2.h> | |
36 | - #include <windows.h> | |
37 | -#endif // WIN32 | |
38 | - | |
39 | - #include <errno.h> | |
40 | - #include <string.h> | |
41 | - #include <stdio.h> | |
42 | - #include <lib3270.h> | |
43 | - #include <lib3270/macros.h> | |
44 | - #include <lib3270/selection.h> | |
45 | - #include <stdlib.h> | |
46 | - #include <strings.h> | |
47 | - #include "private.h" | |
48 | - #include "utilc.h" | |
49 | - #include "api.h" | |
50 | - */ | |
51 | - | |
52 | -/*--[ Structs & Defines ]----------------------------------------------------------------------------*/ | |
53 | - | |
54 | -/* | |
55 | - struct macro_list | |
56 | - { | |
57 | - const char *name; | |
58 | - char *(*exec)(H3270 *session, int argc, const char **argv); | |
59 | - }; | |
60 | -*/ | |
61 | - | |
62 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
63 | - | |
64 | -/* | |
65 | - static const char * get_state(H3270 *h) | |
66 | - { | |
67 | - #define DECLARE_XLAT_STATE(x) { x, #x } | |
68 | - static const struct _xlat_state | |
69 | - { | |
70 | - LIB3270_CSTATE state; | |
71 | - const char * ret; | |
72 | - } xlat_state[] = | |
73 | - { | |
74 | - DECLARE_XLAT_STATE( LIB3270_NOT_CONNECTED ), | |
75 | - DECLARE_XLAT_STATE( LIB3270_RESOLVING ), | |
76 | - DECLARE_XLAT_STATE( LIB3270_PENDING ), | |
77 | - DECLARE_XLAT_STATE( LIB3270_CONNECTED_INITIAL ), | |
78 | - DECLARE_XLAT_STATE( LIB3270_CONNECTED_ANSI ), | |
79 | - DECLARE_XLAT_STATE( LIB3270_CONNECTED_3270 ), | |
80 | - DECLARE_XLAT_STATE( LIB3270_CONNECTED_INITIAL_E ), | |
81 | - DECLARE_XLAT_STATE( LIB3270_CONNECTED_NVT ), | |
82 | - DECLARE_XLAT_STATE( LIB3270_CONNECTED_SSCP ), | |
83 | - DECLARE_XLAT_STATE( LIB3270_CONNECTED_TN3270E ) | |
84 | - }; | |
85 | - | |
86 | - size_t f; | |
87 | - | |
88 | - LIB3270_CSTATE state = lib3270_get_connection_state(h); | |
89 | - | |
90 | - for(f=0;f < (sizeof(xlat_state)/sizeof(struct _xlat_state)); f++) | |
91 | - { | |
92 | - if(state == xlat_state[f].state) | |
93 | - return xlat_state[f].ret; | |
94 | - } | |
95 | - | |
96 | - return "Unexpected"; | |
97 | - } | |
98 | - | |
99 | - LIB3270_MACRO( encoding ) | |
100 | - { | |
101 | - return strdup(lib3270_get_display_charset(hSession)); | |
102 | - } | |
103 | - | |
104 | - LIB3270_MACRO( get ) | |
105 | - { | |
106 | - char *buffer = NULL; | |
107 | - | |
108 | - switch(argc) | |
109 | - { | |
110 | - case 1: // Get entire screen | |
111 | - buffer = lib3270_get_string_at_address(hSession,0,-1,'\n'); | |
112 | - break; | |
113 | - | |
114 | - default: | |
115 | - errno = EINVAL; | |
116 | - } | |
117 | - | |
118 | - return buffer; | |
119 | - } | |
120 | - | |
121 | - LIB3270_MACRO( set ) | |
122 | - { | |
123 | - const char *str = NULL; | |
124 | - int rows, cols; | |
125 | - | |
126 | - if(lib3270_get_program_message(hSession) != LIB3270_MESSAGE_NONE) | |
127 | - { | |
128 | - errno = EBUSY; | |
129 | - return NULL; | |
130 | - } | |
131 | - | |
132 | - lib3270_get_screen_size(hSession,&rows,&cols); | |
133 | - | |
134 | - switch(argc) | |
135 | - { | |
136 | - case 1: | |
137 | - lib3270_enter(hSession); | |
138 | - break; | |
139 | - | |
140 | - case 2: | |
141 | - str = argv[1]; | |
142 | - break; | |
143 | - | |
144 | - case 3: | |
145 | - lib3270_set_cursor_address(hSession,atoi(argv[1])); | |
146 | - str = argv[2]; | |
147 | - break; | |
148 | - | |
149 | - case 4: | |
150 | - lib3270_set_cursor_address(hSession,(atoi(argv[1])-1) * cols + (atoi(argv[2])-1)); | |
151 | - str = argv[3]; | |
152 | - break; | |
153 | - | |
154 | - default: | |
155 | - errno = EINVAL; | |
156 | - return NULL; | |
157 | - } | |
158 | - | |
159 | - if(str) | |
160 | - lib3270_set_string(NULL, (const unsigned char *) str); | |
161 | - | |
162 | - return strdup(get_state(hSession)); | |
163 | - } | |
164 | - | |
165 | - LIB3270_MACRO( status ) | |
166 | - { | |
167 | - const char * luname = (const char *) lib3270_get_luname(hSession); | |
168 | - const char * state = get_state(hSession); | |
169 | - const char * host = (const char *) lib3270_get_hostname(hSession); | |
170 | - char * rsp; | |
171 | - size_t sz; | |
172 | - | |
173 | - if(!luname) | |
174 | - luname = "none"; | |
175 | - | |
176 | - if(!host) | |
177 | - host = "-"; | |
178 | - | |
179 | - sz = strlen(luname)+strlen(state)+strlen(host)+4; | |
180 | - rsp = lib3270_malloc(sz+1); | |
181 | - snprintf(rsp,sz,"%s %s %s",state,luname,host); | |
182 | - return rsp; | |
183 | - } | |
184 | - | |
185 | - LIB3270_MACRO( cstate ) | |
186 | - { | |
187 | - return strdup(get_state(hSession)); | |
188 | - } | |
189 | - | |
190 | - LIB3270_MACRO( luname ) | |
191 | - { | |
192 | - const char * luname = (const char *) lib3270_get_luname(hSession); | |
193 | - return strdup(luname ? luname : "none" ); | |
194 | - } | |
195 | - | |
196 | - LIB3270_MACRO( pf ) | |
197 | - { | |
198 | - char ret[10]; | |
199 | - if(argc != 2) | |
200 | - { | |
201 | - errno = EINVAL; | |
202 | - return NULL; | |
203 | - } | |
204 | - snprintf(ret,9,"%d",lib3270_pfkey(hSession,atoi(argv[1]))); | |
205 | - return strdup(ret); | |
206 | - } | |
207 | - | |
208 | - LIB3270_MACRO( pa ) | |
209 | - { | |
210 | - char ret[10]; | |
211 | - if(argc != 2) | |
212 | - { | |
213 | - errno = EINVAL; | |
214 | - return NULL; | |
215 | - } | |
216 | - snprintf(ret,9,"%d",lib3270_pakey(hSession,atoi(argv[1]))); | |
217 | - return strdup(ret); | |
218 | - } | |
219 | - | |
220 | - LIB3270_MACRO( enter ) | |
221 | - { | |
222 | - char ret[10]; | |
223 | - if(argc != 1) | |
224 | - { | |
225 | - errno = EINVAL; | |
226 | - return NULL; | |
227 | - } | |
228 | - snprintf(ret,9,"%d",lib3270_enter(hSession)); | |
229 | - return strdup(ret); | |
230 | - } | |
231 | - | |
232 | - LIB3270_MACRO( connect ) | |
233 | - { | |
234 | - int rc = EBUSY; | |
235 | - char ret[10]; | |
236 | - | |
237 | - switch(argc) | |
238 | - { | |
239 | - case 1: | |
240 | - rc = lib3270_connect(hSession,0); | |
241 | - break; | |
242 | - | |
243 | - case 2: | |
244 | - lib3270_set_url(hSession,argv[1]); | |
245 | - rc = lib3270_connect(hSession,0); | |
246 | - break; | |
247 | - | |
248 | - case 3: | |
249 | - lib3270_set_url(hSession,argv[1]); | |
250 | - rc = lib3270_connect(hSession,atoi(argv[2])); | |
251 | - break; | |
252 | - | |
253 | - default: | |
254 | - return NULL; | |
255 | - } | |
256 | - | |
257 | - snprintf(ret,9,"%d",rc); | |
258 | - return strdup(ret); | |
259 | - } | |
260 | - | |
261 | - LIB3270_MACRO( disconnect ) | |
262 | - { | |
263 | - lib3270_disconnect(hSession); | |
264 | - return strdup("0"); | |
265 | - } | |
266 | - | |
267 | - LIB3270_MACRO( unselect ) | |
268 | - { | |
269 | - lib3270_unselect(hSession); | |
270 | - return strdup("0"); | |
271 | - } | |
272 | - | |
273 | - LIB3270_MACRO( select ) | |
274 | - { | |
275 | - int rc = -1; | |
276 | - char ret[10]; | |
277 | - | |
278 | - switch(argc) | |
279 | - { | |
280 | - case 1: // 1 argument, select all | |
281 | - rc = lib3270_select_all(hSession); | |
282 | - break; | |
283 | - | |
284 | - case 3: // 2 arguments, first and last addr | |
285 | - rc = lib3270_select_region(hSession,atoi(argv[1]),atoi(argv[2])); | |
286 | - break; | |
287 | - | |
288 | - | |
289 | - default: | |
290 | - errno = EINVAL; | |
291 | - return NULL; | |
292 | - } | |
293 | - | |
294 | - snprintf(ret,9,"%d",rc); | |
295 | - return strdup(ret); | |
296 | - | |
297 | - } | |
298 | -*/ | |
299 | - | |
300 | -/*--[ Macro entry point ]----------------------------------------------------------------------------*/ | |
301 | - | |
302 | -/* | |
303 | - LIB3270_EXPORT char * lib3270_run_macro(H3270 *session, const char **argv) | |
304 | - { | |
305 | - #define LIB3270_MACRO_ENTRY( name ) { #name, lib3270_macro_ ## name } | |
306 | - | |
307 | - static const struct macro_list cmd[] = | |
308 | - { | |
309 | - LIB3270_MACRO_ENTRY( connect ), | |
310 | - LIB3270_MACRO_ENTRY( cstate ), | |
311 | - LIB3270_MACRO_ENTRY( disconnect ), | |
312 | - LIB3270_MACRO_ENTRY( encoding ), | |
313 | - LIB3270_MACRO_ENTRY( enter ), | |
314 | - LIB3270_MACRO_ENTRY( get ), | |
315 | - LIB3270_MACRO_ENTRY( luname ), | |
316 | - LIB3270_MACRO_ENTRY( pa ), | |
317 | - LIB3270_MACRO_ENTRY( pf ), | |
318 | - LIB3270_MACRO_ENTRY( set ), | |
319 | - LIB3270_MACRO_ENTRY( status ), | |
320 | - LIB3270_MACRO_ENTRY( select ), | |
321 | - LIB3270_MACRO_ENTRY( unselect ), | |
322 | - | |
323 | - {NULL, NULL} | |
324 | - }; | |
325 | - | |
326 | - int argc; | |
327 | - int f; | |
328 | - | |
329 | - CHECK_SESSION_HANDLE(session); | |
330 | - | |
331 | - trace("macro(%s)",argv[0]); | |
332 | - | |
333 | - // Get the number of arguments | |
334 | - for(argc = 0; argv[argc]; argc++); | |
335 | - | |
336 | - // Search for macro function | |
337 | - for(f=0;cmd[f].name;f++) | |
338 | - { | |
339 | - if(!strcasecmp(cmd[f].name,argv[0])) | |
340 | - return cmd[f].exec(session,argc,argv); | |
341 | - } | |
342 | - | |
343 | - if(argc == 1) | |
344 | - { | |
345 | - // Search for action | |
346 | - const LIB3270_ACTION_ENTRY *actions = lib3270_get_action_table(); | |
347 | - | |
348 | - for(f=0;actions[f].name;f++) | |
349 | - { | |
350 | - if(!strcasecmp(actions[f].name,argv[0])) | |
351 | - { | |
352 | - int rc = actions[f].call(session); | |
353 | - return xs_buffer("%d",rc); | |
354 | - } | |
355 | - } | |
356 | - | |
357 | - } | |
358 | - | |
359 | - // Not found, return NULL | |
360 | - return NULL; | |
361 | - } | |
362 | -*/ |
src/lib3270/options.c
... | ... | @@ -35,22 +35,22 @@ |
35 | 35 | |
36 | 36 | /*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ |
37 | 37 | |
38 | - static const LIB3270_OPTION_ENTRY host_type[] = | |
38 | + static const LIB3270_HOST_TYPE_ENTRY host_type[] = | |
39 | 39 | { |
40 | 40 | { |
41 | - LIB3270_OPTION_S390, | |
41 | + LIB3270_HOST_S390, | |
42 | 42 | "S390", |
43 | 43 | N_( "IBM S/390" ), |
44 | 44 | NULL |
45 | 45 | }, |
46 | 46 | { |
47 | - LIB3270_OPTION_AS400, | |
47 | + LIB3270_HOST_AS400, | |
48 | 48 | "AS400", |
49 | 49 | N_( "IBM AS/400" ), |
50 | 50 | NULL |
51 | 51 | }, |
52 | 52 | { |
53 | - LIB3270_OPTION_TSO, | |
53 | + LIB3270_HOST_TSO, | |
54 | 54 | "TSO", |
55 | 55 | N_( "Other (TSO)" ), |
56 | 56 | NULL |
... | ... | @@ -73,25 +73,17 @@ |
73 | 73 | |
74 | 74 | /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ |
75 | 75 | |
76 | -LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession) | |
76 | +LIB3270_EXPORT LIB3270_HOST_TYPE lib3270_get_host_type(H3270 *hSession) | |
77 | 77 | { |
78 | 78 | CHECK_SESSION_HANDLE(hSession); |
79 | - return hSession->options; | |
79 | + return hSession->host_type; | |
80 | 80 | } |
81 | 81 | |
82 | -LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt) | |
82 | +LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, LIB3270_HOST_TYPE opt) | |
83 | 83 | { |
84 | - CHECK_SESSION_HANDLE(hSession); | |
85 | - hSession->options = opt; | |
86 | - | |
87 | - Replace(hSession->host.full, | |
88 | - lib3270_strdup_printf( | |
89 | - "%s%s:%s", | |
90 | - hSession->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
91 | - hSession->host.current, | |
92 | - hSession->host.srvc | |
93 | - )); | |
94 | - | |
84 | + FAIL_IF_ONLINE(hSession); | |
85 | + hSession->host_type = opt; | |
86 | + return 0; | |
95 | 87 | } |
96 | 88 | |
97 | 89 | LIB3270_EXPORT int lib3270_get_color_type(H3270 *hSession) |
... | ... | @@ -137,7 +129,7 @@ LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype) |
137 | 129 | } |
138 | 130 | |
139 | 131 | |
140 | -LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void) | |
132 | +LIB3270_EXPORT const LIB3270_HOST_TYPE_ENTRY * lib3270_get_option_list(void) | |
141 | 133 | { |
142 | 134 | return host_type; |
143 | 135 | } |
... | ... | @@ -145,10 +137,40 @@ LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void) |
145 | 137 | LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession) |
146 | 138 | { |
147 | 139 | CHECK_SESSION_HANDLE(hSession); |
148 | - return (hSession->options & LIB3270_OPTION_TSO) != 0; | |
140 | + return (hSession->host_type & LIB3270_HOST_TSO) != 0; | |
141 | +} | |
142 | + | |
143 | +LIB3270_EXPORT int lib3270_set_tso(H3270 *hSession, int on) | |
144 | +{ | |
145 | + FAIL_IF_ONLINE(hSession); | |
146 | + | |
147 | + if(on) | |
148 | + hSession->host_type = LIB3270_HOST_TSO; | |
149 | + else | |
150 | + hSession->host_type &= ~LIB3270_HOST_TSO; | |
151 | + | |
152 | + return 0; | |
153 | +} | |
154 | + | |
155 | +LIB3270_EXPORT int lib3270_is_as400(H3270 *hSession) | |
156 | +{ | |
157 | + CHECK_SESSION_HANDLE(hSession); | |
158 | + return (hSession->host_type & LIB3270_HOST_AS400) != 0; | |
149 | 159 | } |
150 | 160 | |
151 | -LIB3270_EXPORT LIB3270_OPTION lib3270_parse_host_type(const char *name) | |
161 | +LIB3270_EXPORT int lib3270_set_as400(H3270 *hSession, int on) | |
162 | +{ | |
163 | + FAIL_IF_ONLINE(hSession); | |
164 | + | |
165 | + if(on) | |
166 | + hSession->host_type |= LIB3270_HOST_AS400; | |
167 | + else | |
168 | + hSession->host_type &= ~LIB3270_HOST_AS400; | |
169 | + | |
170 | + return 0; | |
171 | +} | |
172 | + | |
173 | +LIB3270_EXPORT LIB3270_HOST_TYPE lib3270_parse_host_type(const char *name) | |
152 | 174 | { |
153 | 175 | |
154 | 176 | int f; |
... | ... | @@ -156,22 +178,23 @@ LIB3270_EXPORT LIB3270_OPTION lib3270_parse_host_type(const char *name) |
156 | 178 | for(f=0;host_type[f].name;f++) |
157 | 179 | { |
158 | 180 | if(!strcasecmp(host_type[f].name,name)) |
159 | - return host_type[f].option; | |
181 | + return host_type[f].type; | |
160 | 182 | } |
161 | 183 | |
184 | + errno = ENOENT; | |
162 | 185 | return 0; |
163 | 186 | } |
164 | 187 | |
165 | -LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name) | |
188 | +LIB3270_EXPORT int lib3270_set_host_type_by_name(H3270 *hSession, const char *name) | |
166 | 189 | { |
167 | - size_t f; | |
190 | + FAIL_IF_ONLINE(hSession); | |
168 | 191 | |
192 | + size_t f; | |
169 | 193 | for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++) |
170 | 194 | { |
171 | 195 | if(host_type[f].name && !strcasecmp(host_type[f].name,name)) |
172 | 196 | { |
173 | - hSession->options &= ~LIB3270_OPTION_HOST_TYPE; | |
174 | - hSession->options |= host_type[f].option; | |
197 | + hSession->host_type = host_type[f].type; | |
175 | 198 | return 0; |
176 | 199 | } |
177 | 200 | } |
... | ... | @@ -179,13 +202,13 @@ LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name) |
179 | 202 | return errno = EINVAL; |
180 | 203 | } |
181 | 204 | |
182 | -LIB3270_EXPORT const char * lib3270_get_host_type(H3270 *hSession) | |
205 | +LIB3270_EXPORT const char * lib3270_get_host_type_name(H3270 *hSession) | |
183 | 206 | { |
184 | 207 | size_t f; |
185 | 208 | |
186 | 209 | for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++) |
187 | 210 | { |
188 | - if(hSession->options & host_type[f].option) | |
211 | + if(hSession->host_type == host_type[f].type) | |
189 | 212 | { |
190 | 213 | return host_type[f].name; |
191 | 214 | } | ... | ... |
src/lib3270/private.h
... | ... | @@ -309,7 +309,7 @@ struct _h3270 |
309 | 309 | LIB3270_CSTATE cstate; ///< @brief Connection state. |
310 | 310 | |
311 | 311 | // flags |
312 | - LIB3270_OPTION options; ///< @brief Session options. | |
312 | + LIB3270_HOST_TYPE host_type; ///< @brief Host type. | |
313 | 313 | |
314 | 314 | int selected : 1; ///< @brief Has selected region? |
315 | 315 | int rectsel : 1; ///< @brief Selected region is a rectangle ? |
... | ... | @@ -605,6 +605,7 @@ struct _h3270 |
605 | 605 | /// @brief SSL Data. |
606 | 606 | struct |
607 | 607 | { |
608 | + char enabled; | |
608 | 609 | char host; |
609 | 610 | LIB3270_SSL_STATE state; |
610 | 611 | unsigned long error; |
... | ... | @@ -647,7 +648,7 @@ LIB3270_INTERNAL int lib3270_default_event_dispatcher(H3270 *hSession, int block |
647 | 648 | /** |
648 | 649 | * @brief Called from timer to attempt an automatic reconnection. |
649 | 650 | */ |
650 | -LIB3270_INTERNAL int lib3270_reconnect(H3270 *hSession); | |
651 | +LIB3270_INTERNAL int lib3270_check_for_auto_reconnect(H3270 *hSession); | |
651 | 652 | |
652 | 653 | #if defined(DEBUG) |
653 | 654 | #define CHECK_SESSION_HANDLE(x) check_session_handle(&x,__FUNCTION__); | ... | ... |
src/lib3270/properties.c
... | ... | @@ -72,7 +72,7 @@ |
72 | 72 | "connected", // Property name. |
73 | 73 | N_( "" ), // Property description. |
74 | 74 | lib3270_is_connected, // Get value. |
75 | - lib3270_set_connected // Set value. | |
75 | + NULL // Set value. | |
76 | 76 | }, |
77 | 77 | |
78 | 78 | { |
... | ... | @@ -86,7 +86,14 @@ |
86 | 86 | "tso", // Property name. |
87 | 87 | N_( "Non zero if the host is TSO." ), // Property description. |
88 | 88 | lib3270_is_tso, // Get value. |
89 | - NULL // Set value. | |
89 | + lib3270_set_tso // Set value. | |
90 | + }, | |
91 | + | |
92 | + { | |
93 | + "as400", // Property name. | |
94 | + N_( "Non zero if the host is AS400." ), // Property description. | |
95 | + lib3270_is_as400, // Get value. | |
96 | + lib3270_set_as400 // Set value. | |
90 | 97 | }, |
91 | 98 | |
92 | 99 | { |
... | ... | @@ -360,8 +367,8 @@ |
360 | 367 | { |
361 | 368 | "host_type", // Property name. |
362 | 369 | N_( "" ), // Property description. |
363 | - lib3270_get_host_type, // Get value. | |
364 | - lib3270_set_host_type // Set value. | |
370 | + lib3270_get_host_type_name, // Get value. | |
371 | + lib3270_set_host_type_by_name // Set value. | |
365 | 372 | }, |
366 | 373 | |
367 | 374 | { |
... | ... | @@ -422,11 +429,12 @@ |
422 | 429 | |
423 | 430 | } |
424 | 431 | |
432 | + /* | |
425 | 433 | int lib3270_set_connected(H3270 *hSession, int state) { |
426 | 434 | |
427 | 435 | if(state) { |
428 | 436 | |
429 | - if(lib3270_connect(hSession,120)) | |
437 | + if(lib3270_reconnect(hSession,120)) | |
430 | 438 | return -1; |
431 | 439 | |
432 | 440 | } else { |
... | ... | @@ -436,6 +444,7 @@ |
436 | 444 | |
437 | 445 | return 0; |
438 | 446 | } |
447 | + */ | |
439 | 448 | |
440 | 449 | int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) |
441 | 450 | { | ... | ... |
src/lib3270/session.c
... | ... | @@ -314,7 +314,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char |
314 | 314 | hSession->saved_wraparound_mode = 1; |
315 | 315 | hSession->once_cset = -1; |
316 | 316 | hSession->state = LIB3270_ANSI_STATE_DATA; |
317 | - hSession->options = LIB3270_OPTION_DEFAULTS; | |
317 | + hSession->host_type = LIB3270_HOSTTYPE_DEFAULT; | |
318 | 318 | hSession->colors = 16; |
319 | 319 | hSession->m3279 = 1; |
320 | 320 | hSession->unlock_delay_ms = 350; // 0.35s after last unlock | ... | ... |
src/lib3270/testprogram/testprogram.c
... | ... | @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) |
50 | 50 | //lib3270_set_toggle(h,LIB3270_TOGGLE_DS_TRACE,1); |
51 | 51 | lib3270_set_toggle(h,LIB3270_TOGGLE_SSL_TRACE,1); |
52 | 52 | |
53 | - rc = lib3270_connect(h,120); | |
53 | + rc = lib3270_reconnect(h,120); | |
54 | 54 | printf("\nConnect %s exits with rc=%d\n",lib3270_get_url(h),rc); |
55 | 55 | |
56 | 56 | lib3270_wait_for_ready(h,10); | ... | ... |
src/lib3270/toggles.c
... | ... | @@ -352,7 +352,7 @@ static void toggle_reconnect(H3270 *hSession, struct lib3270_toggle *t unused, L |
352 | 352 | /* Schedule an automatic reconnection. */ |
353 | 353 | lib3270_write_log(hSession,"toggle","Auto-reconnect toggle was activated when offline, reconnecting"); |
354 | 354 | hSession->auto_reconnect_inprogress = 1; |
355 | - (void) AddTimer(RECONNECT_MS, hSession, lib3270_reconnect); | |
355 | + (void) AddTimer(RECONNECT_MS, hSession, lib3270_check_for_auto_reconnect); | |
356 | 356 | } |
357 | 357 | |
358 | 358 | } | ... | ... |
src/lib3270/windows/connect.c
... | ... | @@ -159,11 +159,12 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai |
159 | 159 | lib3270_set_url(hSession,url); |
160 | 160 | } |
161 | 161 | |
162 | - return lib3270_connect(hSession, wait); | |
162 | + return lib3270_reconnect(hSession, wait); | |
163 | 163 | |
164 | 164 | } |
165 | 165 | |
166 | -LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_OPTION opt) | |
166 | +/* | |
167 | +LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_HOST_TYPE opt) | |
167 | 168 | { |
168 | 169 | CHECK_SESSION_HANDLE(hSession); |
169 | 170 | |
... | ... | @@ -190,22 +191,23 @@ LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, c |
190 | 191 | hostname = name; |
191 | 192 | } |
192 | 193 | |
193 | - hSession->options = opt & ~LIB3270_OPTION_WAIT; | |
194 | + hSession->options = opt & ~LIB3270_HOST_TYPE_WAIT; | |
194 | 195 | Replace(hSession->host.current,strdup(hostname)); |
195 | 196 | Replace(hSession->host.srvc,strdup(srvc)); |
196 | 197 | |
197 | 198 | Replace(hSession->host.full, |
198 | 199 | lib3270_strdup_printf( |
199 | 200 | "%s%s:%s", |
200 | - opt&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
201 | + opt&LIB3270_HOST_TYPE_SSL ? "tn3270s://" : "tn3270://", | |
201 | 202 | hostname, |
202 | 203 | srvc )); |
203 | 204 | |
204 | 205 | trace("current_host=\"%s\"",hSession->host.current); |
205 | 206 | |
206 | - return lib3270_connect(hSession,opt & LIB3270_OPTION_WAIT); | |
207 | + return lib3270_reconnect(hSession,opt & LIB3270_HOST_TYPE_WAIT); | |
207 | 208 | |
208 | 209 | } |
210 | +*/ | |
209 | 211 | |
210 | 212 | struct resolver |
211 | 213 | { |
... | ... | @@ -260,7 +262,7 @@ LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, c |
260 | 262 | |
261 | 263 | } |
262 | 264 | |
263 | -int lib3270_connect(H3270 *hSession, int seconds) | |
265 | +int lib3270_reconnect(H3270 *hSession, int seconds) | |
264 | 266 | { |
265 | 267 | int optval; |
266 | 268 | struct resolver host; |
... | ... | @@ -330,7 +332,7 @@ int lib3270_connect(H3270 *hSession, int seconds) |
330 | 332 | hSession->ever_3270 = False; |
331 | 333 | hSession->ssl.host = 0; |
332 | 334 | |
333 | - if(hSession->options&LIB3270_OPTION_SSL) | |
335 | + if(hSession->options&LIB3270_HOST_TYPE_SSL) | |
334 | 336 | { |
335 | 337 | #if defined(HAVE_LIBSSL) |
336 | 338 | hSession->ssl.host = 1; | ... | ... |