Commit 5d3c21b869d2c3635f84965987350d08f21004c7
1 parent
815a26b8
Exists in
master
and in
3 other branches
Refactoring LU properties.
Showing
5 changed files
with
117 additions
and
112 deletions
Show diff stats
src/core/host.c
... | ... | @@ -264,10 +264,18 @@ static void update_url(H3270 *hSession) |
264 | 264 | LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) |
265 | 265 | { |
266 | 266 | FAIL_IF_ONLINE(hSession); |
267 | - strncpy(hSession->lu.name,luname,LIB3270_LUNAME_LENGTH); | |
267 | + strncpy(hSession->lu.names,luname,LIB3270_LUNAME_LENGTH); | |
268 | 268 | return 0; |
269 | 269 | } |
270 | 270 | |
271 | +LIB3270_EXPORT const char * lib3270_get_associated_luname(const H3270 *hSession) | |
272 | +{ | |
273 | + if(check_online_session(hSession)) | |
274 | + return NULL; | |
275 | + | |
276 | + return hSession->lu.associated; | |
277 | +} | |
278 | + | |
271 | 279 | LIB3270_EXPORT const char * lib3270_get_url(const H3270 *hSession) |
272 | 280 | { |
273 | 281 | if(hSession->host.url) |
... | ... | @@ -446,11 +454,6 @@ LIB3270_EXPORT const char * lib3270_get_host(const H3270 *h) |
446 | 454 | return h->host.url; |
447 | 455 | } |
448 | 456 | |
449 | -LIB3270_EXPORT const char * lib3270_get_luname(const H3270 *h) | |
450 | -{ | |
451 | - return h->lu.connected; | |
452 | -} | |
453 | - | |
454 | 457 | LIB3270_EXPORT int lib3270_has_active_script(const H3270 *h) |
455 | 458 | { |
456 | 459 | return (h->oia.flag[LIB3270_FLAG_SCRIPT] != 0); | ... | ... |
src/core/properties/string.c
... | ... | @@ -59,73 +59,73 @@ |
59 | 59 | static const LIB3270_STRING_PROPERTY properties[] = { |
60 | 60 | |
61 | 61 | { |
62 | - .name = "luname", // Property name. | |
63 | - .description = N_( "The name of the active LU" ), // Property description. | |
64 | - .get = lib3270_get_luname, // Get value. | |
65 | - .set = lib3270_set_luname // Set value. | |
62 | + .name = "associated_lu", // Property name. | |
63 | + .description = N_( "The name of the LU associated with the session" ), // Property description. | |
64 | + .get = lib3270_get_associated_luname, // Get value. | |
65 | + .set = NULL // Set value. | |
66 | 66 | }, |
67 | 67 | |
68 | 68 | { |
69 | - .name = "url", // Property name. | |
70 | - .description = N_( "URL of the current host" ), // Property description. | |
71 | - .get = lib3270_get_url, // Get value. | |
72 | - .set = lib3270_set_url // Set value. | |
69 | + .name = "url", // Property name. | |
70 | + .description = N_( "URL of the current host" ), // Property description. | |
71 | + .get = lib3270_get_url, // Get value. | |
72 | + .set = lib3270_set_url // Set value. | |
73 | 73 | }, |
74 | 74 | |
75 | 75 | { |
76 | - .name = "model", // Property name. | |
77 | - .description = N_( "Model name" ), // Property description. | |
78 | - .get = lib3270_get_model_name, // Get value. | |
79 | - .set = lib3270_set_model_name // Set value. | |
76 | + .name = "model", // Property name. | |
77 | + .description = N_( "Model name" ), // Property description. | |
78 | + .get = lib3270_get_model_name, // Get value. | |
79 | + .set = lib3270_set_model_name // Set value. | |
80 | 80 | }, |
81 | 81 | |
82 | 82 | { |
83 | - .name = "hosttype", // Property name. | |
84 | - .description = N_( "Host type name" ), // Property description. | |
85 | - .get = lib3270_get_host_type_name, // Get value. | |
86 | - .set = lib3270_set_host_type_by_name // Set value. | |
83 | + .name = "hosttype", // Property name. | |
84 | + .description = N_( "Host type name" ), // Property description. | |
85 | + .get = lib3270_get_host_type_name, // Get value. | |
86 | + .set = lib3270_set_host_type_by_name // Set value. | |
87 | 87 | }, |
88 | 88 | |
89 | 89 | { |
90 | - .name = "termtype", // Property name. | |
91 | - .description = N_( "Terminal type" ), // Property description. | |
92 | - .get = lib3270_get_termtype, // Get value. | |
93 | - .set = NULL // Set value. | |
90 | + .name = "termtype", // Property name. | |
91 | + .description = N_( "Terminal type" ), // Property description. | |
92 | + .get = lib3270_get_termtype, // Get value. | |
93 | + .set = NULL // Set value. | |
94 | 94 | }, |
95 | 95 | |
96 | 96 | { |
97 | - .name = "termname", // Property name. | |
98 | - .description = N_( "Terminal name" ), // Property description. | |
99 | - .get = lib3270_get_termname, // Get value. | |
100 | - .set = NULL // Set value. | |
97 | + .name = "termname", // Property name. | |
98 | + .description = N_( "Terminal name" ), // Property description. | |
99 | + .get = lib3270_get_termname, // Get value. | |
100 | + .set = NULL // Set value. | |
101 | 101 | }, |
102 | 102 | |
103 | 103 | { |
104 | - .name = "host_charset", // Property name. | |
105 | - .description = N_( "Host charset" ), // Property description. | |
106 | - .get = lib3270_get_host_charset, // Get value. | |
107 | - .set = lib3270_set_host_charset // Set value. | |
104 | + .name = "host_charset", // Property name. | |
105 | + .description = N_( "Host charset" ), // Property description. | |
106 | + .get = lib3270_get_host_charset, // Get value. | |
107 | + .set = lib3270_set_host_charset // Set value. | |
108 | 108 | }, |
109 | 109 | |
110 | 110 | { |
111 | - .name = "display_charset", // Property name. | |
112 | - .description = N_( "Display charset" ), // Property description. | |
113 | - .get = lib3270_get_display_charset, // Get value. | |
114 | - .set = NULL // Set value. | |
111 | + .name = "display_charset", // Property name. | |
112 | + .description = N_( "Display charset" ), // Property description. | |
113 | + .get = lib3270_get_display_charset, // Get value. | |
114 | + .set = NULL // Set value. | |
115 | 115 | }, |
116 | 116 | |
117 | 117 | { |
118 | - .name = "version", // Property name. | |
119 | - .description = N_( "lib3270 version" ), // Property description. | |
120 | - .get = get_version, // Get value. | |
121 | - .set = NULL // Set value. | |
118 | + .name = "version", // Property name. | |
119 | + .description = N_( "lib3270 version" ), // Property description. | |
120 | + .get = get_version, // Get value. | |
121 | + .set = NULL // Set value. | |
122 | 122 | }, |
123 | 123 | |
124 | 124 | { |
125 | - .name = "revision", // Property name. | |
126 | - .description = N_( "lib3270 revision" ), // Property description. | |
127 | - .get = get_revision, // Get value. | |
128 | - .set = NULL // Set value. | |
125 | + .name = "revision", // Property name. | |
126 | + .description = N_( "lib3270 revision" ), // Property description. | |
127 | + .get = get_revision, // Get value. | |
128 | + .set = NULL // Set value. | |
129 | 129 | }, |
130 | 130 | |
131 | 131 | { |
... | ... | @@ -136,24 +136,24 @@ |
136 | 136 | }, |
137 | 137 | |
138 | 138 | { |
139 | - .name = "crlprefer", // Property name. | |
140 | - .description = N_( "Prefered protocol for CRL" ), // Property description. | |
141 | - .get = lib3270_get_crl_prefered_protocol, // Get value. | |
142 | - .set = lib3270_set_crl_prefered_protocol, // Set value. | |
139 | + .name = "crlprefer", // Property name. | |
140 | + .description = N_( "Prefered protocol for CRL" ), // Property description. | |
141 | + .get = lib3270_get_crl_prefered_protocol, // Get value. | |
142 | + .set = lib3270_set_crl_prefered_protocol, // Set value. | |
143 | 143 | }, |
144 | 144 | |
145 | 145 | { |
146 | - .name = "default_host", // Property name. | |
147 | - .description = N_( "Default host URL" ), // Property description. | |
148 | - .get = lib3270_get_default_host, // Get value. | |
149 | - .set = NULL // Set value. | |
146 | + .name = "default_host", // Property name. | |
147 | + .description = N_( "Default host URL" ), // Property description. | |
148 | + .get = lib3270_get_default_host, // Get value. | |
149 | + .set = NULL // Set value. | |
150 | 150 | }, |
151 | 151 | |
152 | 152 | { |
153 | - .name = "sslmessage", // Property name. | |
154 | - .description = N_( "The security state" ), // Property description. | |
155 | - .get = lib3270_get_ssl_state_message, // Get value. | |
156 | - .set = NULL // Set value. | |
153 | + .name = "sslmessage", // Property name. | |
154 | + .description = N_( "The security state" ), // Property description. | |
155 | + .get = lib3270_get_ssl_state_message, // Get value. | |
156 | + .set = NULL // Set value. | |
157 | 157 | }, |
158 | 158 | |
159 | 159 | { | ... | ... |
src/core/telnet.c
... | ... | @@ -366,7 +366,7 @@ void popup_a_sockerr(H3270 *hSession, char *fmt, ...) |
366 | 366 | |
367 | 367 | } |
368 | 368 | |
369 | -/* Set up the LU list. */ | |
369 | +// Set up the LU list. | |
370 | 370 | static void setup_lus(H3270 *hSession) |
371 | 371 | { |
372 | 372 | char *lu; |
... | ... | @@ -374,10 +374,10 @@ static void setup_lus(H3270 *hSession) |
374 | 374 | int n_lus = 1; |
375 | 375 | int i; |
376 | 376 | |
377 | - hSession->lu.connected = CN; | |
377 | + hSession->lu.associated = CN; | |
378 | 378 | hSession->connected_type = CN; |
379 | 379 | |
380 | - if (!hSession->lu.name[0]) | |
380 | + if (!hSession->lu.names[0]) | |
381 | 381 | { |
382 | 382 | Replace(hSession->lus, NULL); |
383 | 383 | hSession->curr_lu = (char **)NULL; |
... | ... | @@ -385,26 +385,26 @@ static void setup_lus(H3270 *hSession) |
385 | 385 | return; |
386 | 386 | } |
387 | 387 | |
388 | - /* | |
389 | - * Count the commas in the LU name. That plus one is the | |
390 | - * number of LUs to try. | |
391 | - */ | |
392 | - lu = hSession->lu.name; | |
388 | + // | |
389 | + // Count the commas in the LU names. That plus one is the | |
390 | + // number of LUs to try. | |
391 | + // | |
392 | + lu = hSession->lu.names; | |
393 | 393 | while ((comma = strchr(lu, ',')) != CN) |
394 | 394 | { |
395 | 395 | n_lus++; |
396 | 396 | lu++; |
397 | 397 | } |
398 | 398 | |
399 | - /* | |
400 | - * Allocate enough memory to construct an argv[] array for | |
401 | - * the LUs. | |
402 | - */ | |
403 | - Replace(hSession->lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(hSession->lu.name) + 1)); | |
399 | + // | |
400 | + // Allocate enough memory to construct an argv[] array for | |
401 | + // the LUs. | |
402 | + // | |
403 | + Replace(hSession->lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(hSession->lu.names) + 1)); | |
404 | 404 | |
405 | - /* Copy each LU into the array. */ | |
405 | + // Copy each LU into the array. | |
406 | 406 | lu = (char *)(hSession->lus + n_lus + 1); |
407 | - (void) strcpy(lu, hSession->lu.name); | |
407 | + (void) strcpy(lu, hSession->lu.names); | |
408 | 408 | |
409 | 409 | i = 0; |
410 | 410 | do |
... | ... | @@ -471,19 +471,19 @@ LIB3270_EXPORT void lib3270_setup_session(H3270 *hSession) |
471 | 471 | (void) memset((char *) hSession->myopts, 0, sizeof(hSession->myopts)); |
472 | 472 | (void) memset((char *) hSession->hisopts, 0, sizeof(hSession->hisopts)); |
473 | 473 | |
474 | -#if defined(X3270_TN3270E) /*[*/ | |
474 | +#if defined(X3270_TN3270E) | |
475 | 475 | hSession->e_funcs = E_OPT(TN3270E_FUNC_BIND_IMAGE) | E_OPT(TN3270E_FUNC_RESPONSES) | E_OPT(TN3270E_FUNC_SYSREQ); |
476 | 476 | hSession->e_xmit_seq = 0; |
477 | 477 | hSession->response_required = TN3270E_RSF_NO_RESPONSE; |
478 | -#endif /*]*/ | |
478 | +#endif | |
479 | 479 | |
480 | -#if defined(HAVE_LIBSSL) /*[*/ | |
480 | +#if defined(HAVE_LIBSSL) | |
481 | 481 | hSession->need_tls_follows = 0; |
482 | -#endif /*]*/ | |
482 | +#endif | |
483 | 483 | hSession->telnet_state = TNS_DATA; |
484 | 484 | hSession->ibptr = hSession->ibuf; |
485 | 485 | |
486 | - /* clear statistics and flags */ | |
486 | + // clear statistics and flags | |
487 | 487 | time(&hSession->ns_time); |
488 | 488 | hSession->ns_brcvd = 0; |
489 | 489 | hSession->ns_rrcvd = 0; |
... | ... | @@ -498,7 +498,7 @@ LIB3270_EXPORT void lib3270_setup_session(H3270 *hSession) |
498 | 498 | |
499 | 499 | check_linemode(hSession,True); |
500 | 500 | |
501 | - /* write out the passthru hostname and port nubmer */ | |
501 | + // write out the passthru hostname and port nubmer | |
502 | 502 | /* |
503 | 503 | if (hSession->passthru_host) |
504 | 504 | { |
... | ... | @@ -578,8 +578,8 @@ void net_disconnect(H3270 *session) |
578 | 578 | session->termtype = session->full_model_name; |
579 | 579 | */ |
580 | 580 | |
581 | - /* We're not connected to an LU any more. */ | |
582 | - session->lu.connected = CN; | |
581 | + // We're not connected to an LU any more. | |
582 | + session->lu.associated = CN; | |
583 | 583 | status_lu(session,CN); |
584 | 584 | |
585 | 585 | } |
... | ... | @@ -1070,13 +1070,13 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) |
1070 | 1070 | } |
1071 | 1071 | hSession->telnet_state = TNS_DATA; |
1072 | 1072 | break; |
1073 | - case TNS_SB: /* telnet sub-option string command */ | |
1073 | + case TNS_SB: // telnet sub-option string command | |
1074 | 1074 | if (c == IAC) |
1075 | 1075 | hSession->telnet_state = TNS_SB_IAC; |
1076 | 1076 | else |
1077 | 1077 | *hSession->sbptr++ = c; |
1078 | 1078 | break; |
1079 | - case TNS_SB_IAC: /* telnet sub-option string command */ | |
1079 | + case TNS_SB_IAC: // telnet sub-option string command | |
1080 | 1080 | *hSession->sbptr++ = c; |
1081 | 1081 | if (c == SE) { |
1082 | 1082 | hSession->telnet_state = TNS_DATA; |
... | ... | @@ -1089,7 +1089,7 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) |
1089 | 1089 | |
1090 | 1090 | if (hSession->lus != (char **)NULL && hSession->try_lu == CN) |
1091 | 1091 | { |
1092 | - /* None of the LUs worked. */ | |
1092 | + // None of the LUs worked. | |
1093 | 1093 | popup_an_error(hSession, _( "Cannot connect to specified LU" ) ); |
1094 | 1094 | return -1; |
1095 | 1095 | } |
... | ... | @@ -1098,12 +1098,14 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) |
1098 | 1098 | if (hSession->try_lu != CN && *hSession->try_lu) |
1099 | 1099 | { |
1100 | 1100 | tt_len += strlen(hSession->try_lu) + 1; |
1101 | - hSession->lu.connected = hSession->try_lu; | |
1101 | + hSession->lu.associated = hSession->try_lu; | |
1102 | 1102 | } |
1103 | 1103 | else |
1104 | - hSession->lu.connected = CN; | |
1104 | + { | |
1105 | + hSession->lu.associated = CN; | |
1106 | + } | |
1105 | 1107 | |
1106 | - status_lu(hSession,hSession->lu.connected); | |
1108 | + status_lu(hSession,hSession->lu.associated); | |
1107 | 1109 | |
1108 | 1110 | tb_len = 4 + tt_len + 2; |
1109 | 1111 | tt_out = lib3270_malloc(tb_len + 1); |
... | ... | @@ -1310,8 +1312,8 @@ static int tn3270e_negotiate(H3270 *hSession) |
1310 | 1312 | snlen = LIB3270_LU_MAX; |
1311 | 1313 | (void)strncpy(hSession->lu.reported,(char *)&hSession->sbbuf[3+tnlen+1], snlen); |
1312 | 1314 | hSession->lu.reported[snlen] = '\0'; |
1313 | - hSession->lu.connected = hSession->lu.reported; | |
1314 | - status_lu(hSession,hSession->lu.connected); | |
1315 | + hSession->lu.associated = hSession->lu.reported; | |
1316 | + status_lu(hSession,hSession->lu.associated); | |
1315 | 1317 | } |
1316 | 1318 | |
1317 | 1319 | /* Tell them what we can do. */ |
... | ... | @@ -2088,19 +2090,19 @@ static void check_in3270(H3270 *hSession) |
2088 | 2090 | int was_in_e = IN_E; |
2089 | 2091 | #endif /*]*/ |
2090 | 2092 | |
2091 | -#if defined(X3270_TN3270E) /*[*/ | |
2092 | - /* | |
2093 | - * If we've now switched between non-TN3270E mode and | |
2094 | - * TN3270E mode, reset the LU list so we can try again | |
2095 | - * in the new mode. | |
2096 | - */ | |
2093 | +#if defined(X3270_TN3270E) | |
2094 | + // | |
2095 | + // If we've now switched between non-TN3270E mode and | |
2096 | + // TN3270E mode, reset the LU list so we can try again | |
2097 | + // in the new mode. | |
2098 | + // | |
2097 | 2099 | if (hSession->lus != (char **)NULL && was_in_e != IN_E) { |
2098 | 2100 | hSession->curr_lu = hSession->lus; |
2099 | 2101 | hSession->try_lu = *hSession->curr_lu; |
2100 | 2102 | } |
2101 | -#endif /*]*/ | |
2103 | +#endif | |
2102 | 2104 | |
2103 | - /* Allocate the initial 3270 input buffer. */ | |
2105 | + // Allocate the initial 3270 input buffer. | |
2104 | 2106 | if(new_cstate >= LIB3270_CONNECTED_INITIAL && !(hSession->ibuf_size && hSession->ibuf)) |
2105 | 2107 | { |
2106 | 2108 | hSession->ibuf = (unsigned char *) lib3270_malloc(BUFSIZ); |
... | ... | @@ -2108,21 +2110,21 @@ static void check_in3270(H3270 *hSession) |
2108 | 2110 | hSession->ibptr = hSession->ibuf; |
2109 | 2111 | } |
2110 | 2112 | |
2111 | -#if defined(X3270_ANSI) /*[*/ | |
2112 | - /* Reinitialize line mode. */ | |
2113 | +#if defined(X3270_ANSI) | |
2114 | + // Reinitialize line mode. | |
2113 | 2115 | if ((new_cstate == LIB3270_CONNECTED_ANSI && hSession->linemode) || |
2114 | 2116 | new_cstate == LIB3270_CONNECTED_NVT) |
2115 | 2117 | cooked_init(hSession); |
2116 | -#endif /*]*/ | |
2118 | +#endif | |
2117 | 2119 | |
2118 | -#if defined(X3270_TN3270E) /*[*/ | |
2119 | - /* If we fell out of TN3270E, remove the state. */ | |
2120 | +#if defined(X3270_TN3270E) | |
2121 | + // If we fell out of TN3270E, remove the state. | |
2120 | 2122 | if (!hSession->myopts[TELOPT_TN3270E]) { |
2121 | 2123 | hSession->tn3270e_negotiated = 0; |
2122 | 2124 | hSession->tn3270e_submode = E_NONE; |
2123 | 2125 | hSession->tn3270e_bound = 0; |
2124 | 2126 | } |
2125 | -#endif /*]*/ | |
2127 | +#endif | |
2126 | 2128 | trace_dsn(hSession,"Now operating in %s mode.\n",state_name[new_cstate]); |
2127 | 2129 | host_in3270(hSession,new_cstate); |
2128 | 2130 | } | ... | ... |
src/include/internals.h
... | ... | @@ -510,12 +510,12 @@ struct _h3270 |
510 | 510 | /// @brief LU |
511 | 511 | char **curr_lu; |
512 | 512 | char * try_lu; |
513 | - char **lus; ///< @brief Array with the LU names to try. | |
513 | + char **lus; ///< @brief Array with the LU names to try. | |
514 | 514 | struct |
515 | 515 | { |
516 | 516 | char reported[LIB3270_LU_MAX+1]; |
517 | - char * connected; | |
518 | - char name[LIB3270_LUNAME_LENGTH+1]; | |
517 | + char * associated; ///< @brief The LU name associated with the session. | |
518 | + char names[LIB3270_LUNAME_LENGTH+1]; ///< @brief The LU names to try. | |
519 | 519 | |
520 | 520 | } lu; |
521 | 521 | ... | ... |
src/include/lib3270.h
... | ... | @@ -976,17 +976,17 @@ |
976 | 976 | LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_program_message(const H3270 *h); |
977 | 977 | |
978 | 978 | /** |
979 | - * Get connected LU name. | |
979 | + * Get the LU name associated with the session, if there is one. | |
980 | 980 | * |
981 | - * Get the name of the connected LU; the value is internal to lib3270 and | |
982 | - * should not be changed ou freed. | |
981 | + * Get the name LU associated with the session; the value is | |
982 | + * internal to lib3270 and should not be changed ou freed. | |
983 | 983 | * |
984 | - * @param h Session handle. | |
984 | + * @param hSession Session handle. | |
985 | 985 | * |
986 | - * @return conected LU name or NULL if not connected. | |
986 | + * @return The associated LU name or NULL if not available. | |
987 | 987 | * |
988 | 988 | */ |
989 | - LIB3270_EXPORT const char * lib3270_get_luname(const H3270 *hSession); | |
989 | + LIB3270_EXPORT const char * lib3270_get_associated_luname(const H3270 *hSession); | |
990 | 990 | |
991 | 991 | LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname); |
992 | 992 | ... | ... |