Commit 3f46e593bdff429b8de3a27fc57fa08b3104320d

Authored by Perry Werneck
1 parent 229656b1

Adjustments in the session structure.

src/core/host.c
@@ -238,7 +238,7 @@ static void update_host(H3270 *h) @@ -238,7 +238,7 @@ static void update_host(H3270 *h)
238 LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) 238 LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname)
239 { 239 {
240 FAIL_IF_ONLINE(hSession); 240 FAIL_IF_ONLINE(hSession);
241 - strncpy(hSession->luname,luname,LIB3270_LUNAME_LENGTH); 241 + strncpy(hSession->lu.name,luname,LIB3270_LUNAME_LENGTH);
242 return 0; 242 return 0;
243 } 243 }
244 244
@@ -422,7 +422,7 @@ LIB3270_EXPORT const char * lib3270_get_host(const H3270 *h) @@ -422,7 +422,7 @@ LIB3270_EXPORT const char * lib3270_get_host(const H3270 *h)
422 422
423 LIB3270_EXPORT const char * lib3270_get_luname(const H3270 *h) 423 LIB3270_EXPORT const char * lib3270_get_luname(const H3270 *h)
424 { 424 {
425 - return h->connected_lu; 425 + return h->lu.connected;
426 } 426 }
427 427
428 LIB3270_EXPORT int lib3270_has_active_script(const H3270 *h) 428 LIB3270_EXPORT int lib3270_has_active_script(const H3270 *h)
src/core/iocalls.c
@@ -161,7 +161,7 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int @@ -161,7 +161,7 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int
161 #endif /*]*/ 161 #endif /*]*/
162 162
163 /* Find where to insert this item. */ 163 /* Find where to insert this item. */
164 - for (t = (timeout_t *) session->timeouts.first; t != TN; t = t->next) 164 + for (t = (timeout_t *) session->timeouts.first; t != TN; t = (timeout_t *) t->next)
165 { 165 {
166 #if defined(_WIN32) 166 #if defined(_WIN32)
167 if (t->ts > t_new->ts) 167 if (t->ts > t_new->ts)
@@ -177,20 +177,20 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int @@ -177,20 +177,20 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int
177 if (prev == TN) 177 if (prev == TN)
178 { 178 {
179 // t_new is Front. 179 // t_new is Front.
180 - t_new->next = (timeout_t *) session->timeouts.first;  
181 - session->timeouts.first = t_new; 180 + t_new->next = session->timeouts.first;
  181 + session->timeouts.first = (struct lib3270_linked_list_node *) t_new;
182 } 182 }
183 else if (t == TN) 183 else if (t == TN)
184 { 184 {
185 // t_new is Rear. 185 // t_new is Rear.
186 - t_new->next = TN;  
187 - prev->next = t_new;  
188 - session->timeouts.last = (timeout_t *) t_new; 186 + t_new->next = NULL;
  187 + prev->next = (struct lib3270_linked_list_node *) t_new;
  188 + session->timeouts.last = (struct lib3270_linked_list_node *) t_new;
189 } 189 }
190 else 190 else
191 { // t_new is Middle. 191 { // t_new is Middle.
192 - t_new->next = t;  
193 - prev->next = t_new; 192 + t_new->next = (struct lib3270_linked_list_node *) t;
  193 + prev->next = (struct lib3270_linked_list_node *) t_new;
194 } 194 }
195 195
196 trace("Timer %p added with value %ld",t_new,interval_ms); 196 trace("Timer %p added with value %ld",t_new,interval_ms);
@@ -314,11 +314,11 @@ LIB3270_EXPORT void lib3270_set_poll_state(H3270 *session, void *id, int enabled @@ -314,11 +314,11 @@ LIB3270_EXPORT void lib3270_set_poll_state(H3270 *session, void *id, int enabled
314 } 314 }
315 } 315 }
316 316
317 -LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd) 317 +LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd)
318 { 318 {
319 input_t *ip; 319 input_t *ip;
320 320
321 - for (ip = (input_t *) session->input.list.first; ip; ip = ip->next) 321 + for (ip = (input_t *) session->input.list.first; ip; ip = (input_t *) ip->next)
322 { 322 {
323 if(ip->fd == fd) 323 if(ip->fd == fd)
324 { 324 {
@@ -331,11 +331,11 @@ LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd) @@ -331,11 +331,11 @@ LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd)
331 331
332 } 332 }
333 333
334 -LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag) 334 +LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag)
335 { 335 {
336 input_t *ip; 336 input_t *ip;
337 337
338 - for (ip = (input_t *) session->input.list.first; ip; ip = ip->next) 338 + for (ip = (input_t *) session->input.list.first; ip; ip = (input_t *) ip->next)
339 { 339 {
340 if(ip->fd == fd) 340 if(ip->fd == fd)
341 { 341 {
src/core/telnet.c
@@ -370,10 +370,10 @@ static void setup_lus(H3270 *hSession) @@ -370,10 +370,10 @@ static void setup_lus(H3270 *hSession)
370 int n_lus = 1; 370 int n_lus = 1;
371 int i; 371 int i;
372 372
373 - hSession->connected_lu = CN; 373 + hSession->lu.connected = CN;
374 hSession->connected_type = CN; 374 hSession->connected_type = CN;
375 375
376 - if (!hSession->luname[0]) 376 + if (!hSession->lu.name[0])
377 { 377 {
378 Replace(hSession->lus, NULL); 378 Replace(hSession->lus, NULL);
379 hSession->curr_lu = (char **)NULL; 379 hSession->curr_lu = (char **)NULL;
@@ -385,7 +385,7 @@ static void setup_lus(H3270 *hSession) @@ -385,7 +385,7 @@ static void setup_lus(H3270 *hSession)
385 * Count the commas in the LU name. That plus one is the 385 * Count the commas in the LU name. That plus one is the
386 * number of LUs to try. 386 * number of LUs to try.
387 */ 387 */
388 - lu = hSession->luname; 388 + lu = hSession->lu.name;
389 while ((comma = strchr(lu, ',')) != CN) 389 while ((comma = strchr(lu, ',')) != CN)
390 { 390 {
391 n_lus++; 391 n_lus++;
@@ -396,11 +396,11 @@ static void setup_lus(H3270 *hSession) @@ -396,11 +396,11 @@ static void setup_lus(H3270 *hSession)
396 * Allocate enough memory to construct an argv[] array for 396 * Allocate enough memory to construct an argv[] array for
397 * the LUs. 397 * the LUs.
398 */ 398 */
399 - Replace(hSession->lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(hSession->luname) + 1)); 399 + Replace(hSession->lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(hSession->lu.name) + 1));
400 400
401 /* Copy each LU into the array. */ 401 /* Copy each LU into the array. */
402 lu = (char *)(hSession->lus + n_lus + 1); 402 lu = (char *)(hSession->lus + n_lus + 1);
403 - (void) strcpy(lu, hSession->luname); 403 + (void) strcpy(lu, hSession->lu.name);
404 404
405 i = 0; 405 i = 0;
406 do 406 do
@@ -575,7 +575,7 @@ void net_disconnect(H3270 *session) @@ -575,7 +575,7 @@ void net_disconnect(H3270 *session)
575 */ 575 */
576 576
577 /* We're not connected to an LU any more. */ 577 /* We're not connected to an LU any more. */
578 - session->connected_lu = CN; 578 + session->lu.connected = CN;
579 status_lu(session,CN); 579 status_lu(session,CN);
580 580
581 } 581 }
@@ -1094,12 +1094,12 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) @@ -1094,12 +1094,12 @@ static int telnet_fsm(H3270 *hSession, unsigned char c)
1094 if (hSession->try_lu != CN && *hSession->try_lu) 1094 if (hSession->try_lu != CN && *hSession->try_lu)
1095 { 1095 {
1096 tt_len += strlen(hSession->try_lu) + 1; 1096 tt_len += strlen(hSession->try_lu) + 1;
1097 - hSession->connected_lu = hSession->try_lu; 1097 + hSession->lu.connected = hSession->try_lu;
1098 } 1098 }
1099 else 1099 else
1100 - hSession->connected_lu = CN; 1100 + hSession->lu.connected = CN;
1101 1101
1102 - status_lu(hSession,hSession->connected_lu); 1102 + status_lu(hSession,hSession->lu.connected);
1103 1103
1104 tb_len = 4 + tt_len + 2; 1104 tb_len = 4 + tt_len + 2;
1105 tt_out = lib3270_malloc(tb_len + 1); 1105 tt_out = lib3270_malloc(tb_len + 1);
@@ -1304,10 +1304,10 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1304,10 +1304,10 @@ static int tn3270e_negotiate(H3270 *hSession)
1304 if (snlen) { 1304 if (snlen) {
1305 if (snlen > LIB3270_LU_MAX) 1305 if (snlen > LIB3270_LU_MAX)
1306 snlen = LIB3270_LU_MAX; 1306 snlen = LIB3270_LU_MAX;
1307 - (void)strncpy(hSession->reported_lu,(char *)&hSession->sbbuf[3+tnlen+1], snlen);  
1308 - hSession->reported_lu[snlen] = '\0';  
1309 - hSession->connected_lu = hSession->reported_lu;  
1310 - status_lu(hSession,hSession->connected_lu); 1307 + (void)strncpy(hSession->lu.reported,(char *)&hSession->sbbuf[3+tnlen+1], snlen);
  1308 + hSession->lu.reported[snlen] = '\0';
  1309 + hSession->lu.connected = hSession->lu.reported;
  1310 + status_lu(hSession,hSession->lu.connected);
1311 } 1311 }
1312 1312
1313 /* Tell them what we can do. */ 1313 /* Tell them what we can do. */
src/include/lib3270-internals.h
@@ -94,8 +94,6 @@ @@ -94,8 +94,6 @@
94 // 94 //
95 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) 95 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
96 96
97 -// #define unused __attribute__((__unused__))  
98 -  
99 #define GNUC_UNUSED \ 97 #define GNUC_UNUSED \
100 __attribute__((__unused__)) 98 __attribute__((__unused__))
101 99
@@ -131,7 +129,9 @@ @@ -131,7 +129,9 @@
131 #define RECONNECT_MS 2000 /**< @brief 2 sec before reconnecting to host. */ 129 #define RECONNECT_MS 2000 /**< @brief 2 sec before reconnecting to host. */
132 #define RECONNECT_ERR_MS 5000 /**< @brief 5 sec before reconnecting to host when failed */ 130 #define RECONNECT_ERR_MS 5000 /**< @brief 5 sec before reconnecting to host when failed */
133 131
134 -/* types of internal actions */ 132 +/**
  133 + * @brief types of internal actions
  134 + */
135 enum iaction { 135 enum iaction {
136 IA_STRING, IA_PASTE, IA_REDRAW, 136 IA_STRING, IA_PASTE, IA_REDRAW,
137 IA_KEYPAD, IA_DEFAULT, IA_KEY, 137 IA_KEYPAD, IA_DEFAULT, IA_KEY,
@@ -231,7 +231,9 @@ struct toggle_name { @@ -231,7 +231,9 @@ struct toggle_name {
231 #define PT_ON_THE_SPOT "OnTheSpot" 231 #define PT_ON_THE_SPOT "OnTheSpot"
232 #endif /*]*/ 232 #endif /*]*/
233 233
234 -/** input key type */ 234 +/**
  235 + * @brief input key type
  236 + */
235 enum keytype 237 enum keytype
236 { 238 {
237 KT_STD, 239 KT_STD,
@@ -250,7 +252,9 @@ LIB3270_INTERNAL struct _ansictl @@ -250,7 +252,9 @@ LIB3270_INTERNAL struct _ansictl
250 char vlnext; 252 char vlnext;
251 } ansictl; 253 } ansictl;
252 254
253 -/** @brief Extended attributes */ 255 +/**
  256 + * @brief Extended attributes
  257 + */
254 struct lib3270_ea 258 struct lib3270_ea
255 { 259 {
256 unsigned char cc; ///< @brief EBCDIC or ASCII character code 260 unsigned char cc; ///< @brief EBCDIC or ASCII character code
@@ -389,9 +393,6 @@ struct _h3270 @@ -389,9 +393,6 @@ struct _h3270
389 393
390 // Network & Termtype 394 // Network & Termtype
391 char * connected_type; 395 char * connected_type;
392 - char * connected_lu;  
393 - char luname[LIB3270_LUNAME_LENGTH+1];  
394 -  
395 char full_model_name[LIB3270_FULL_MODEL_NAME_LENGTH+1]; 396 char full_model_name[LIB3270_FULL_MODEL_NAME_LENGTH+1];
396 char * model_name; 397 char * model_name;
397 unsigned int model_num; 398 unsigned int model_num;
@@ -492,25 +493,39 @@ struct _h3270 @@ -492,25 +493,39 @@ struct _h3270
492 int ns_bsent; 493 int ns_bsent;
493 int ns_rsent; 494 int ns_rsent;
494 struct timeval ds_ts; 495 struct timeval ds_ts;
495 - unsigned long e_funcs; /**< @brief negotiated TN3270E functions */  
496 unsigned short e_xmit_seq; /**< @brief transmit sequence number */ 496 unsigned short e_xmit_seq; /**< @brief transmit sequence number */
497 int response_required; 497 int response_required;
498 - int tn3270e_bound;  
499 - int tn3270e_negotiated;  
500 int ansi_data; 498 int ansi_data;
501 int lnext; 499 int lnext;
502 int backslashed; 500 int backslashed;
503 char plu_name[LIB3270_BIND_PLU_NAME_MAX+1]; 501 char plu_name[LIB3270_BIND_PLU_NAME_MAX+1];
504 - char **lus; 502 +
  503 + /*
  504 + /// @brief Proxy
  505 + struct
  506 + {
  507 + int type;
  508 + char * host;
  509 + char * portname;
  510 + unsigned short port;
  511 + } proxy;
  512 + */
  513 +
  514 + /// @brief LU
505 char **curr_lu; 515 char **curr_lu;
506 char * try_lu; 516 char * try_lu;
507 - int proxy_type;  
508 - char * proxy_host;  
509 - char * proxy_portname;  
510 - unsigned short proxy_port;  
511 - char reported_lu[LIB3270_LU_MAX+1]; 517 + char **lus; ///< @brief Array with the LU names to try.
  518 + struct
  519 + {
  520 + char reported[LIB3270_LU_MAX+1];
  521 + char * connected;
  522 + char name[LIB3270_LUNAME_LENGTH+1];
  523 +
  524 + } lu;
  525 +
512 char reported_type[LIB3270_LU_MAX+1]; 526 char reported_type[LIB3270_LU_MAX+1];
513 527
  528 + // TN3270e
514 enum 529 enum
515 { 530 {
516 E_NONE, 531 E_NONE,
@@ -519,10 +534,14 @@ struct _h3270 @@ -519,10 +534,14 @@ struct _h3270
519 E_SSCP 534 E_SSCP
520 } tn3270e_submode; 535 } tn3270e_submode;
521 536
  537 + unsigned long e_funcs; /**< @brief negotiated TN3270E functions */
  538 + int tn3270e_bound;
  539 + int tn3270e_negotiated;
  540 +
  541 + // Line mode
522 unsigned char * lbuf; /**< @brief line-mode input buffer */ 542 unsigned char * lbuf; /**< @brief line-mode input buffer */
523 unsigned char * lbptr; 543 unsigned char * lbptr;
524 544
525 -  
526 // 3270 input buffer 545 // 3270 input buffer
527 unsigned char * ibptr; 546 unsigned char * ibptr;
528 547