diff --git a/src/core/host.c b/src/core/host.c index bfaf4c1..400c271 100644 --- a/src/core/host.c +++ b/src/core/host.c @@ -238,7 +238,7 @@ static void update_host(H3270 *h) LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) { FAIL_IF_ONLINE(hSession); - strncpy(hSession->luname,luname,LIB3270_LUNAME_LENGTH); + strncpy(hSession->lu.name,luname,LIB3270_LUNAME_LENGTH); return 0; } @@ -422,7 +422,7 @@ LIB3270_EXPORT const char * lib3270_get_host(const H3270 *h) LIB3270_EXPORT const char * lib3270_get_luname(const H3270 *h) { - return h->connected_lu; + return h->lu.connected; } LIB3270_EXPORT int lib3270_has_active_script(const H3270 *h) diff --git a/src/core/iocalls.c b/src/core/iocalls.c index 3ae03fb..27eb1a2 100644 --- a/src/core/iocalls.c +++ b/src/core/iocalls.c @@ -161,7 +161,7 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int #endif /*]*/ /* Find where to insert this item. */ - for (t = (timeout_t *) session->timeouts.first; t != TN; t = t->next) + for (t = (timeout_t *) session->timeouts.first; t != TN; t = (timeout_t *) t->next) { #if defined(_WIN32) if (t->ts > t_new->ts) @@ -177,20 +177,20 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int if (prev == TN) { // t_new is Front. - t_new->next = (timeout_t *) session->timeouts.first; - session->timeouts.first = t_new; + t_new->next = session->timeouts.first; + session->timeouts.first = (struct lib3270_linked_list_node *) t_new; } else if (t == TN) { // t_new is Rear. - t_new->next = TN; - prev->next = t_new; - session->timeouts.last = (timeout_t *) t_new; + t_new->next = NULL; + prev->next = (struct lib3270_linked_list_node *) t_new; + session->timeouts.last = (struct lib3270_linked_list_node *) t_new; } else { // t_new is Middle. - t_new->next = t; - prev->next = t_new; + t_new->next = (struct lib3270_linked_list_node *) t; + prev->next = (struct lib3270_linked_list_node *) t_new; } 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 } } -LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd) +LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd) { input_t *ip; - for (ip = (input_t *) session->input.list.first; ip; ip = ip->next) + for (ip = (input_t *) session->input.list.first; ip; ip = (input_t *) ip->next) { if(ip->fd == fd) { @@ -331,11 +331,11 @@ LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd) } -LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag) +LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag) { input_t *ip; - for (ip = (input_t *) session->input.list.first; ip; ip = ip->next) + for (ip = (input_t *) session->input.list.first; ip; ip = (input_t *) ip->next) { if(ip->fd == fd) { diff --git a/src/core/telnet.c b/src/core/telnet.c index d08d862..60ded7f 100644 --- a/src/core/telnet.c +++ b/src/core/telnet.c @@ -370,10 +370,10 @@ static void setup_lus(H3270 *hSession) int n_lus = 1; int i; - hSession->connected_lu = CN; + hSession->lu.connected = CN; hSession->connected_type = CN; - if (!hSession->luname[0]) + if (!hSession->lu.name[0]) { Replace(hSession->lus, NULL); hSession->curr_lu = (char **)NULL; @@ -385,7 +385,7 @@ static void setup_lus(H3270 *hSession) * Count the commas in the LU name. That plus one is the * number of LUs to try. */ - lu = hSession->luname; + lu = hSession->lu.name; while ((comma = strchr(lu, ',')) != CN) { n_lus++; @@ -396,11 +396,11 @@ static void setup_lus(H3270 *hSession) * Allocate enough memory to construct an argv[] array for * the LUs. */ - Replace(hSession->lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(hSession->luname) + 1)); + Replace(hSession->lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(hSession->lu.name) + 1)); /* Copy each LU into the array. */ lu = (char *)(hSession->lus + n_lus + 1); - (void) strcpy(lu, hSession->luname); + (void) strcpy(lu, hSession->lu.name); i = 0; do @@ -575,7 +575,7 @@ void net_disconnect(H3270 *session) */ /* We're not connected to an LU any more. */ - session->connected_lu = CN; + session->lu.connected = CN; status_lu(session,CN); } @@ -1094,12 +1094,12 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) if (hSession->try_lu != CN && *hSession->try_lu) { tt_len += strlen(hSession->try_lu) + 1; - hSession->connected_lu = hSession->try_lu; + hSession->lu.connected = hSession->try_lu; } else - hSession->connected_lu = CN; + hSession->lu.connected = CN; - status_lu(hSession,hSession->connected_lu); + status_lu(hSession,hSession->lu.connected); tb_len = 4 + tt_len + 2; tt_out = lib3270_malloc(tb_len + 1); @@ -1304,10 +1304,10 @@ static int tn3270e_negotiate(H3270 *hSession) if (snlen) { if (snlen > LIB3270_LU_MAX) snlen = LIB3270_LU_MAX; - (void)strncpy(hSession->reported_lu,(char *)&hSession->sbbuf[3+tnlen+1], snlen); - hSession->reported_lu[snlen] = '\0'; - hSession->connected_lu = hSession->reported_lu; - status_lu(hSession,hSession->connected_lu); + (void)strncpy(hSession->lu.reported,(char *)&hSession->sbbuf[3+tnlen+1], snlen); + hSession->lu.reported[snlen] = '\0'; + hSession->lu.connected = hSession->lu.reported; + status_lu(hSession,hSession->lu.connected); } /* Tell them what we can do. */ diff --git a/src/include/lib3270-internals.h b/src/include/lib3270-internals.h index 714c066..e430be1 100644 --- a/src/include/lib3270-internals.h +++ b/src/include/lib3270-internals.h @@ -94,8 +94,6 @@ // #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -// #define unused __attribute__((__unused__)) - #define GNUC_UNUSED \ __attribute__((__unused__)) @@ -131,7 +129,9 @@ #define RECONNECT_MS 2000 /**< @brief 2 sec before reconnecting to host. */ #define RECONNECT_ERR_MS 5000 /**< @brief 5 sec before reconnecting to host when failed */ -/* types of internal actions */ +/** + * @brief types of internal actions + */ enum iaction { IA_STRING, IA_PASTE, IA_REDRAW, IA_KEYPAD, IA_DEFAULT, IA_KEY, @@ -231,7 +231,9 @@ struct toggle_name { #define PT_ON_THE_SPOT "OnTheSpot" #endif /*]*/ -/** input key type */ +/** + * @brief input key type + */ enum keytype { KT_STD, @@ -250,7 +252,9 @@ LIB3270_INTERNAL struct _ansictl char vlnext; } ansictl; -/** @brief Extended attributes */ +/** + * @brief Extended attributes + */ struct lib3270_ea { unsigned char cc; ///< @brief EBCDIC or ASCII character code @@ -389,9 +393,6 @@ struct _h3270 // Network & Termtype char * connected_type; - char * connected_lu; - char luname[LIB3270_LUNAME_LENGTH+1]; - char full_model_name[LIB3270_FULL_MODEL_NAME_LENGTH+1]; char * model_name; unsigned int model_num; @@ -492,25 +493,39 @@ struct _h3270 int ns_bsent; int ns_rsent; struct timeval ds_ts; - unsigned long e_funcs; /**< @brief negotiated TN3270E functions */ unsigned short e_xmit_seq; /**< @brief transmit sequence number */ int response_required; - int tn3270e_bound; - int tn3270e_negotiated; int ansi_data; int lnext; int backslashed; char plu_name[LIB3270_BIND_PLU_NAME_MAX+1]; - char **lus; + + /* + /// @brief Proxy + struct + { + int type; + char * host; + char * portname; + unsigned short port; + } proxy; + */ + + /// @brief LU char **curr_lu; char * try_lu; - int proxy_type; - char * proxy_host; - char * proxy_portname; - unsigned short proxy_port; - char reported_lu[LIB3270_LU_MAX+1]; + char **lus; ///< @brief Array with the LU names to try. + struct + { + char reported[LIB3270_LU_MAX+1]; + char * connected; + char name[LIB3270_LUNAME_LENGTH+1]; + + } lu; + char reported_type[LIB3270_LU_MAX+1]; + // TN3270e enum { E_NONE, @@ -519,10 +534,14 @@ struct _h3270 E_SSCP } tn3270e_submode; + unsigned long e_funcs; /**< @brief negotiated TN3270E functions */ + int tn3270e_bound; + int tn3270e_negotiated; + + // Line mode unsigned char * lbuf; /**< @brief line-mode input buffer */ unsigned char * lbptr; - // 3270 input buffer unsigned char * ibptr; -- libgit2 0.21.2