diff --git a/lib3270.cbp b/lib3270.cbp
index 515988b..ac34580 100644
--- a/lib3270.cbp
+++ b/lib3270.cbp
@@ -116,6 +116,9 @@
+
+
+
@@ -242,8 +245,8 @@
+
-
diff --git a/src/core/actions/actions.c b/src/core/actions/actions.c
index 90feea5..56d9fc6 100644
--- a/src/core/actions/actions.c
+++ b/src/core/actions/actions.c
@@ -27,10 +27,17 @@
*
*/
-#include
+#include
+#include
#include
#include
+struct lib3270_action_callback
+{
+ LIB3270_LINKED_LIST_HEAD
+ void (*func)(H3270 *, void *); /**< @brief Function to call */
+};
+
/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
const LIB3270_ACTION * lib3270_action_get_by_name(const char *name)
@@ -89,3 +96,40 @@ LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name)
{
return lib3270_action_activate_by_name(name,hSession);
}
+
+LIB3270_INTERNAL void lib3270_notify_actions(H3270 *hSession, LIB3270_ACTION_GROUP group)
+{
+
+ if(group < (sizeof(hSession->listeners.actions)/sizeof(hSession->listeners.actions[0])))
+ {
+ struct lib3270_linked_list_node * node;
+
+ for(node = hSession->listeners.actions[group].first; node; node = node->next)
+ {
+ ((struct lib3270_action_callback *) node)->func(hSession,node->userdata);
+ }
+
+ }
+
+}
+
+LIB3270_EXPORT const void * lib3270_register_action_group_listener(H3270 *hSession, LIB3270_ACTION_GROUP group, void (*func)(H3270 *, void *),void *data)
+{
+
+ if(group < (sizeof(hSession->listeners.actions)/sizeof(hSession->listeners.actions[0])))
+ {
+ struct lib3270_action_callback *st = (struct lib3270_action_callback *) lib3270_linked_list_append_node(&hSession->listeners.actions[group], sizeof(struct lib3270_action_callback), data);
+ st->func = func;
+ return (void *) st;
+ }
+
+ return NULL;
+}
+
+LIB3270_EXPORT int lib3270_unregister_action_group_listener(H3270 *hSession, LIB3270_ACTION_GROUP group, const void *id)
+{
+ if(group < (sizeof(hSession->listeners.actions)/sizeof(hSession->listeners.actions[0])))
+ return lib3270_linked_list_delete_node(&hSession->listeners.actions[group], id);
+
+ return errno = EINVAL;
+}
diff --git a/src/core/actions/table.c b/src/core/actions/table.c
index 146ef21..0920f59 100644
--- a/src/core/actions/table.c
+++ b/src/core/actions/table.c
@@ -32,7 +32,7 @@
*
*/
-#include
+#include
#include
#include
#include
@@ -210,7 +210,7 @@
.summary = N_( "Save selected area." ),
.activate = save_selected,
- .group = LIB3270_ACTION_GROUP_SELECTION,
+ .group = LIB3270_ACTION_GROUP_SELECTED,
.activatable = lib3270_has_selection
},
@@ -591,7 +591,7 @@
.summary = N_( "Print selected area." ),
.activate = lib3270_print_selected,
- .group = LIB3270_ACTION_GROUP_SELECTION,
+ .group = LIB3270_ACTION_GROUP_SELECTED,
.activatable = lib3270_has_selection
},
diff --git a/src/core/ansi.c b/src/core/ansi.c
index 5b5d22c..5c90bd6 100644
--- a/src/core/ansi.c
+++ b/src/core/ansi.c
@@ -40,7 +40,7 @@
#pragma GCC diagnostic ignored "-Wstringop-truncation"
#endif // _WIN32
-#include
+#include
#include
#if defined(X3270_ANSI) /*[*/
diff --git a/src/core/bounds.c b/src/core/bounds.c
index 46f26a1..9da7582 100644
--- a/src/core/bounds.c
+++ b/src/core/bounds.c
@@ -30,7 +30,7 @@
*
*/
-#include
+#include
/*--[ Implement ]------------------------------------------------------------------------------------*/
diff --git a/src/core/charset/charset.c b/src/core/charset/charset.c
index 8482a5f..ab3252c 100644
--- a/src/core/charset/charset.c
+++ b/src/core/charset/charset.c
@@ -35,7 +35,7 @@
* @brief This module handles character sets.
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/charset/convert.c b/src/core/charset/convert.c
index 2daf59c..b6b5a8c 100644
--- a/src/core/charset/convert.c
+++ b/src/core/charset/convert.c
@@ -35,7 +35,7 @@
* @brief This module handles ebc<->asc conversion.
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/charset/getset.c b/src/core/charset/getset.c
index d995fb3..d198eef 100644
--- a/src/core/charset/getset.c
+++ b/src/core/charset/getset.c
@@ -35,7 +35,7 @@
* @brief This module handles get/set the terminal character set.
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/charset/remap.c b/src/core/charset/remap.c
index a5bde92..9bc2555 100644
--- a/src/core/charset/remap.c
+++ b/src/core/charset/remap.c
@@ -35,7 +35,7 @@
* @brief
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/charset/utf8.c b/src/core/charset/utf8.c
index ae99cb0..ec1339b 100644
--- a/src/core/charset/utf8.c
+++ b/src/core/charset/utf8.c
@@ -35,7 +35,7 @@
* @brief 3270 Terminal Emulator UTF-8 conversions
*/
-#include
+#include
// #include "api.h"
#include "popupsc.h"
diff --git a/src/core/charset/view.c b/src/core/charset/view.c
index dc839f7..bf7e3d2 100644
--- a/src/core/charset/view.c
+++ b/src/core/charset/view.c
@@ -35,7 +35,7 @@
* @brief This module shows the charset table.
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/connect.c b/src/core/connect.c
index d8c5383..cf44911 100644
--- a/src/core/connect.c
+++ b/src/core/connect.c
@@ -28,7 +28,7 @@
*/
#include
-#include
+#include
#include "telnetc.h"
#include
#include
@@ -83,7 +83,7 @@
if(hSession->auto_reconnect_inprogress || hSession->popups)
return errno = EAGAIN;
- if(hSession->sock > 0)
+ if(hSession->connection.sock > 0)
return errno = EISCONN;
if(!(hSession->host.current && hSession->host.srvc))
diff --git a/src/core/ctlr.c b/src/core/ctlr.c
index 29e07db..ad280be 100644
--- a/src/core/ctlr.c
+++ b/src/core/ctlr.c
@@ -34,7 +34,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
-#include
+#include
#include
#include
diff --git a/src/core/cursor.c b/src/core/cursor.c
index 0a2bbfb..adb1929 100644
--- a/src/core/cursor.c
+++ b/src/core/cursor.c
@@ -32,7 +32,7 @@
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/ft/ft.c b/src/core/ft/ft.c
index f8dcf04..0649780 100644
--- a/src/core/ft/ft.c
+++ b/src/core/ft/ft.c
@@ -40,7 +40,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/core/ft/ft_cut.c b/src/core/ft/ft_cut.c
index 4264830..a2b75b1 100644
--- a/src/core/ft/ft_cut.c
+++ b/src/core/ft/ft_cut.c
@@ -37,7 +37,7 @@
#include
-#include
+#include
#include
#include
diff --git a/src/core/ft/ft_dft.c b/src/core/ft/ft_dft.c
index d3e331d..385bbac 100644
--- a/src/core/ft/ft_dft.c
+++ b/src/core/ft/ft_dft.c
@@ -42,7 +42,7 @@
#endif // WIN32
#include
-#include
+#include
#if defined(X3270_FT) /*[*/
diff --git a/src/core/ft/ftmessages.c b/src/core/ft/ftmessages.c
index 7c816d5..643f439 100644
--- a/src/core/ft/ftmessages.c
+++ b/src/core/ft/ftmessages.c
@@ -29,7 +29,7 @@
*/
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/host.c b/src/core/host.c
index 8eddebc..fc64e3c 100644
--- a/src/core/host.c
+++ b/src/core/host.c
@@ -38,7 +38,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include
-#include
+#include
#include "resources.h"
#include "hostc.h"
@@ -122,6 +122,36 @@ int host_disconnect(H3270 *hSession, int failed)
}
+int lib3270_set_cstate(H3270 *hSession, LIB3270_CSTATE cstate)
+{
+ if(hSession->connection.state != cstate)
+ {
+ // Salve old states.
+ int connected = lib3270_is_connected(hSession);
+ int disconnected = lib3270_is_disconnected(hSession);
+
+ // Cstate has changed.
+ hSession->connection.state = cstate;
+
+ // Do I need to send notifications?
+
+ if(connected != lib3270_is_connected(hSession)) {
+ // Online state has changed, fire LIB3270_ACTION_GROUP_ONLINE
+ lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_ONLINE);
+ }
+
+ if(disconnected != lib3270_is_disconnected(hSession)) {
+ // Offline state has changed, fire LIB3270_ACTION_GROUP_OFFLINE
+ lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_OFFLINE);
+ }
+
+ return 1;
+ }
+
+ return 0;
+
+}
+
/**
* @brief The host has entered 3270 or ANSI mode, or switched between them.
*/
@@ -131,14 +161,15 @@ void host_in3270(H3270 *hSession, LIB3270_CSTATE new_cstate)
new_cstate == LIB3270_CONNECTED_SSCP ||
new_cstate == LIB3270_CONNECTED_TN3270E);
- hSession->cstate = new_cstate;
+ lib3270_set_cstate(hSession,new_cstate);
hSession->ever_3270 = now3270;
lib3270_st_changed(hSession, LIB3270_STATE_3270_MODE, now3270);
}
void lib3270_set_connected_initial(H3270 *hSession)
{
- hSession->cstate = LIB3270_CONNECTED_INITIAL;
+ lib3270_set_cstate(hSession,LIB3270_CONNECTED_INITIAL);
+
hSession->starting = 1; // Enable autostart
lib3270_st_changed(hSession, LIB3270_STATE_CONNECT, True);
@@ -150,7 +181,7 @@ void lib3270_set_disconnected(H3270 *hSession)
{
CHECK_SESSION_HANDLE(hSession);
- hSession->cstate = LIB3270_NOT_CONNECTED;
+ lib3270_set_cstate(hSession,LIB3270_NOT_CONNECTED);
hSession->starting = 0;
#if defined(HAVE_LIBSSL)
@@ -202,19 +233,6 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode)
((struct lib3270_state_callback *) node)->func(h,mode,node->userdata);
}
- /*
- struct lib3270_state_callback *st;
-
- CHECK_SESSION_HANDLE(h);
-
- trace("%s is %d on session %p",state_name[tx],mode,h);
-
- for(st = h->listeners.state.callbacks[tx];st;st = st->next)
- {
- st->func(h,mode,st->data);
- }
- */
-
trace("%s ends",__FUNCTION__);
}
diff --git a/src/core/html.c b/src/core/html.c
index 103bbb5..06432f2 100644
--- a/src/core/html.c
+++ b/src/core/html.c
@@ -39,7 +39,7 @@
#include "3270ds.h"
#include
- #include
+ #include
#include "utilc.h"
struct chr_xlat
diff --git a/src/core/init.c b/src/core/init.c
index df8a46b..50c735c 100644
--- a/src/core/init.c
+++ b/src/core/init.c
@@ -52,7 +52,7 @@
#endif // _WIN32
#include
-#include
+#include
#ifdef HAVE_SYSLOG
#include
diff --git a/src/core/iocalls.c b/src/core/iocalls.c
index 27eb1a2..9d3d49a 100644
--- a/src/core/iocalls.c
+++ b/src/core/iocalls.c
@@ -29,7 +29,7 @@
*
*/
-#include
+#include
#include
#include
#include "xioc.h"
@@ -301,7 +301,7 @@ static void internal_remove_poll(H3270 *session, void *id)
LIB3270_EXPORT void lib3270_remove_poll(H3270 *session, void *id)
{
- debug("%s(%d,%p)",__FUNCTION__,session->sock,id);
+ debug("%s(%d,%p)",__FUNCTION__,session->connection.sock,id);
remove_poll(session, id);
}
@@ -309,7 +309,7 @@ LIB3270_EXPORT void lib3270_set_poll_state(H3270 *session, void *id, int enabled
{
if(id)
{
- debug("%s: Polling on %d (%p) is %s",__FUNCTION__,session->sock,id,(enabled ? "enabled" : "disabled"));
+ debug("%s: Polling on %d (%p) is %s",__FUNCTION__,session->connection.sock,id,(enabled ? "enabled" : "disabled"));
set_poll_state(session, id, enabled);
}
}
@@ -349,7 +349,7 @@ LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FL
}
LIB3270_EXPORT void * lib3270_add_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ) {
- debug("%s(%d)",__FUNCTION__,session->sock);
+ debug("%s(%d)",__FUNCTION__,session->connection.sock);
return add_poll(session,fd,flag,call,userdata);
}
@@ -400,10 +400,10 @@ void x_except_on(H3270 *h)
if(reading)
lib3270_remove_poll(h,h->xio.read);
- h->xio.except = lib3270_add_poll_fd(h,h->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0);
+ h->xio.except = lib3270_add_poll_fd(h,h->connection.sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0);
if(reading)
- h->xio.read = lib3270_add_poll_fd(h,h->sock,LIB3270_IO_FLAG_READ,net_input,0);
+ h->xio.read = lib3270_add_poll_fd(h,h->connection.sock,LIB3270_IO_FLAG_READ,net_input,0);
debug("%s",__FUNCTION__);
}
@@ -523,7 +523,7 @@ LIB3270_EXPORT int lib3270_run_task(H3270 *hSession, int(*callback)(H3270 *h, vo
int non_blocking(H3270 *hSession, Boolean on)
{
- if(hSession->sock < 0)
+ if(hSession->connection.sock < 0)
return 0;
#ifdef WIN32
@@ -545,7 +545,7 @@ int non_blocking(H3270 *hSession, Boolean on)
int f;
- if ((f = fcntl(hSession->sock, F_GETFL, 0)) == -1)
+ if ((f = fcntl(hSession->connection.sock, F_GETFL, 0)) == -1)
{
lib3270_popup_dialog( hSession,
LIB3270_NOTIFY_ERROR,
@@ -562,7 +562,7 @@ int non_blocking(H3270 *hSession, Boolean on)
else
f &= ~O_NDELAY;
- if (fcntl(hSession->sock, F_SETFL, f) < 0)
+ if (fcntl(hSession->connection.sock, F_SETFL, f) < 0)
{
lib3270_popup_dialog( hSession,
LIB3270_NOTIFY_ERROR,
diff --git a/src/core/keyboard/actions.c b/src/core/keyboard/actions.c
index ccaf55f..cb18be1 100644
--- a/src/core/keyboard/actions.c
+++ b/src/core/keyboard/actions.c
@@ -38,7 +38,7 @@ struct ta;
#define LIB3270_TA struct ta
-#include
+#include
#include
#include
#include
diff --git a/src/core/keyboard/kybd.c b/src/core/keyboard/kybd.c
index 003e909..f6f0a73 100644
--- a/src/core/keyboard/kybd.c
+++ b/src/core/keyboard/kybd.c
@@ -38,7 +38,7 @@ struct ta;
#define LIB3270_TA struct ta
-#include
+#include
#include
#include
#include
diff --git a/src/core/keyboard/properties.c b/src/core/keyboard/properties.c
index 1042f38..b14a225 100644
--- a/src/core/keyboard/properties.c
+++ b/src/core/keyboard/properties.c
@@ -27,7 +27,7 @@
*
*/
-#include
+#include
#include
#include
diff --git a/src/core/linux/connect.c b/src/core/linux/connect.c
index 619191c..94dfd8b 100644
--- a/src/core/linux/connect.c
+++ b/src/core/linux/connect.c
@@ -28,7 +28,7 @@
*/
#include
-#include
+#include
#include
#include
#include
@@ -46,7 +46,7 @@
// #include
// #endif // HAVE_ICONV
-#define SOCK_CLOSE(s) close(s->sock); s->sock = -1;
+#define SOCK_CLOSE(s) close(s->connection.sock); s->connection.sock = -1;
#include
@@ -73,7 +73,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
hSession->xio.write = NULL;
}
- if(getsockopt(hSession->sock, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0)
+ if(getsockopt(hSession->connection.sock, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0)
{
lib3270_disconnect(hSession);
lib3270_popup_dialog(
@@ -102,8 +102,8 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
return;
}
- hSession->xio.except = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0);
- hSession->xio.read = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_READ,net_input,0);
+ hSession->xio.except = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0);
+ hSession->xio.read = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_READ,net_input,0);
#if defined(HAVE_LIBSSL)
if(hSession->ssl.con && hSession->ssl.state == LIB3270_SSL_UNDEFINED)
@@ -147,17 +147,17 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
status_connecting(hSession);
- for(rp = result; hSession->sock < 0 && rp != NULL; rp = rp->ai_next)
+ for(rp = result; hSession->connection.sock < 0 && rp != NULL; rp = rp->ai_next)
{
- hSession->sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
- if(hSession->sock < 0)
+ hSession->connection.sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
+ if(hSession->connection.sock < 0)
{
((struct resolver *) host)->message = strerror(errno);
continue;
}
// Connected!
- if(connect(hSession->sock, rp->ai_addr, rp->ai_addrlen))
+ if(connect(hSession->connection.sock, rp->ai_addr, rp->ai_addrlen))
{
SOCK_CLOSE(hSession);
((struct resolver *) host)->message = strerror(errno);
@@ -178,7 +178,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
memset(&host,0,sizeof(host));
// Connect to host
- if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0)
+ if(lib3270_run_task(hSession, background_connect, &host) || hSession->connection.sock < 0)
{
char buffer[4096];
snprintf(buffer,4095,_( "Can't connect to %s:%s"), hSession->host.current, hSession->host.srvc);
@@ -195,7 +195,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
}
/* don't share the socket with our children */
- (void) fcntl(hSession->sock, F_SETFD, 1);
+ (void) fcntl(hSession->connection.sock, F_SETFD, 1);
hSession->ever_3270 = False;
@@ -212,7 +212,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
// set options for inline out-of-band data and keepalives
int optval = 1;
- if (setsockopt(hSession->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0)
+ if (setsockopt(hSession->connection.sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0)
{
int rc = errno;
lib3270_popup_dialog( hSession,
@@ -226,7 +226,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
}
optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0;
- if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
+ if (setsockopt(hSession->connection.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
{
int rc = errno;
@@ -260,10 +260,10 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
*/
// Connecting, set callbacks, wait for connection
- hSession->cstate = LIB3270_PENDING;
+ lib3270_set_cstate(hSession, LIB3270_PENDING);
lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True);
- hSession->xio.write = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_WRITE,net_connected,0);
+ hSession->xio.write = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_WRITE,net_connected,0);
// hSession->ns_write_id = AddOutput(hSession->sock, hSession, net_connected);
trace("%s: Connection in progress",__FUNCTION__);
@@ -276,7 +276,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
{
lib3270_main_iterate(hSession,1);
- switch(hSession->cstate)
+ switch(hSession->connection.state)
{
case LIB3270_PENDING:
case LIB3270_CONNECTED_INITIAL:
@@ -297,7 +297,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
break;
default:
- lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->cstate);
+ lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->connection.state);
return errno = EINVAL;
}
diff --git a/src/core/linux/curl.c b/src/core/linux/curl.c
index 3bdf597..68d998e 100644
--- a/src/core/linux/curl.c
+++ b/src/core/linux/curl.c
@@ -31,7 +31,7 @@
#if defined(HAVE_LIBCURL)
-#include
+#include
#include
#include
#include
diff --git a/src/core/linux/event_dispatcher.c b/src/core/linux/event_dispatcher.c
index 01ff8c0..9b9b7d8 100644
--- a/src/core/linux/event_dispatcher.c
+++ b/src/core/linux/event_dispatcher.c
@@ -32,7 +32,7 @@
*
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/linux/log.c b/src/core/linux/log.c
index 0213c5c..6e8001d 100644
--- a/src/core/linux/log.c
+++ b/src/core/linux/log.c
@@ -27,7 +27,7 @@
*
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/linux/util.c b/src/core/linux/util.c
index bb15373..4715b3a 100644
--- a/src/core/linux/util.c
+++ b/src/core/linux/util.c
@@ -35,7 +35,7 @@
#include
#include
-#include
+#include
#include
static char * concat(char *path, const char *name, size_t *length)
diff --git a/src/core/log.c b/src/core/log.c
index d36f485..5435708 100644
--- a/src/core/log.c
+++ b/src/core/log.c
@@ -35,7 +35,7 @@
#include
#endif // WIN32
-#include
+#include
#include
#include
#include
diff --git a/src/core/model.c b/src/core/model.c
index dc83dcb..ff16d92 100644
--- a/src/core/model.c
+++ b/src/core/model.c
@@ -27,7 +27,7 @@
*
*/
- #include
+ #include
#include "screen.h"
#include "ctlrc.h"
#include "popupsc.h"
@@ -42,7 +42,7 @@
int lib3270_set_oversize(H3270 *hSession, const char *value)
{
- if(hSession->cstate != LIB3270_NOT_CONNECTED)
+ if(hSession->connection.state != LIB3270_NOT_CONNECTED)
return errno = EISCONN;
if(!hSession->extended)
@@ -177,7 +177,7 @@ int lib3270_set_model(H3270 *hSession, const char *model)
{
int model_number;
- if(hSession->cstate != LIB3270_NOT_CONNECTED)
+ if(hSession->connection.state != LIB3270_NOT_CONNECTED)
return errno = EISCONN;
strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH);
diff --git a/src/core/options.c b/src/core/options.c
index 4596297..bec0b57 100644
--- a/src/core/options.c
+++ b/src/core/options.c
@@ -29,7 +29,7 @@
*
*/
-#include
+#include
/*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/
@@ -94,7 +94,7 @@ LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype)
{
CHECK_SESSION_HANDLE(hSession);
- if(hSession->cstate != LIB3270_NOT_CONNECTED)
+ if(hSession->connection.state != LIB3270_NOT_CONNECTED)
return errno = EISCONN;
switch(colortype)
diff --git a/src/core/paste.c b/src/core/paste.c
index fb306b3..834ebfd 100644
--- a/src/core/paste.c
+++ b/src/core/paste.c
@@ -27,7 +27,7 @@
*
*/
-#include
+#include
/*
#if defined(X3270_DISPLAY)
diff --git a/src/core/print.c b/src/core/print.c
index 42f6eac..99db695 100644
--- a/src/core/print.c
+++ b/src/core/print.c
@@ -35,4 +35,4 @@
* Screen printing functions.
*/
-#include
+#include
diff --git a/src/core/printer.c b/src/core/printer.c
index b021d7f..0f086d5 100644
--- a/src/core/printer.c
+++ b/src/core/printer.c
@@ -36,7 +36,7 @@
* Printer session support
*/
-#include
+#include
#if (defined(C3270) || defined(X3270_DISPLAY)) && defined(X3270_PRINTER) /*[*/
diff --git a/src/core/properties/boolean.c b/src/core/properties/boolean.c
index 0f0d8e1..95e7809 100644
--- a/src/core/properties/boolean.c
+++ b/src/core/properties/boolean.c
@@ -28,7 +28,7 @@
*/
#include
- #include
+ #include
#include
#include
#include
diff --git a/src/core/properties/get.c b/src/core/properties/get.c
index 4f1c369..2d13632 100644
--- a/src/core/properties/get.c
+++ b/src/core/properties/get.c
@@ -28,7 +28,7 @@
*/
#include
- #include
+ #include
#include
#include
#include
diff --git a/src/core/properties/signed.c b/src/core/properties/signed.c
index b018c35..7d72ff9 100644
--- a/src/core/properties/signed.c
+++ b/src/core/properties/signed.c
@@ -28,7 +28,7 @@
*/
#include
- #include
+ #include
#include
#include
#include
diff --git a/src/core/properties/string.c b/src/core/properties/string.c
index d46d3d9..957d98a 100644
--- a/src/core/properties/string.c
+++ b/src/core/properties/string.c
@@ -28,7 +28,7 @@
*/
#include
- #include
+ #include
#include
#include
#include
diff --git a/src/core/properties/unsigned.c b/src/core/properties/unsigned.c
index 25336a6..becbecd 100644
--- a/src/core/properties/unsigned.c
+++ b/src/core/properties/unsigned.c
@@ -28,7 +28,7 @@
*/
#include
- #include
+ #include
#include
#include
#include
diff --git a/src/core/resources.c b/src/core/resources.c
index 25dd6a7..a4014d3 100644
--- a/src/core/resources.c
+++ b/src/core/resources.c
@@ -34,7 +34,7 @@
#include
#include
-#include
+#include
#include "utilc.h"
#include
diff --git a/src/core/rpq.c b/src/core/rpq.c
index 0ee36b3..ebd4a63 100644
--- a/src/core/rpq.c
+++ b/src/core/rpq.c
@@ -37,7 +37,7 @@
*
*/
-#include
+#include
#include
#if !defined(_WIN32) /*[*/
#include
diff --git a/src/core/screen.c b/src/core/screen.c
index fb5c370..3b95c47 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -34,7 +34,7 @@
*
*/
-#include
+#include
#include
#include "3270ds.h"
#include "resources.h"
@@ -550,7 +550,7 @@ void status_oerr(H3270 *session, int error_type)
*/
void status_resolving(H3270 *hSession)
{
- hSession->cstate = LIB3270_RESOLVING;
+ lib3270_set_cstate(hSession,LIB3270_RESOLVING);
lib3270_st_changed(hSession, LIB3270_STATE_RESOLVING, True);
mcursor_set(hSession,LIB3270_POINTER_LOCKED);
@@ -559,7 +559,7 @@ void status_resolving(H3270 *hSession)
void status_connecting(H3270 *hSession)
{
- hSession->cstate = LIB3270_RESOLVING;
+ lib3270_set_cstate(hSession,LIB3270_RESOLVING);
lib3270_st_changed(hSession, LIB3270_STATE_CONNECTING, True);
mcursor_set(hSession,LIB3270_POINTER_LOCKED);
diff --git a/src/core/see.c b/src/core/see.c
index abb4605..cb7a8ac 100644
--- a/src/core/see.c
+++ b/src/core/see.c
@@ -36,7 +36,7 @@
*
*/
-#include
+#include
#if defined(X3270_TRACE) /*[*/
diff --git a/src/core/session.c b/src/core/session.c
index 5dce063..5c88a04 100644
--- a/src/core/session.c
+++ b/src/core/session.c
@@ -33,7 +33,7 @@
#include
#endif // !ANDROID
-#include
+#include
#include "kybdc.h"
#include "ansic.h"
#include "togglesc.h"
@@ -95,6 +95,10 @@ void lib3270_session_free(H3270 *h)
for(f=0;flisteners.toggle[f]);
+ // Release action listeners.
+ for(f=0;flisteners.actions[f]);
+
// Release memory
#define release_pointer(x) lib3270_free(x); x = NULL;
@@ -331,9 +335,9 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char
hSession->unlock_delay = 1;
hSession->icrnl = 1;
hSession->onlcr = 1;
- hSession->sock = -1;
+ hSession->connection.sock = -1;
hSession->model_num = -1;
- hSession->cstate = LIB3270_NOT_CONNECTED;
+ hSession->connection.state = LIB3270_NOT_CONNECTED;
hSession->oia.status = -1;
hSession->kybdlock = KL_NOT_CONNECTED;
hSession->aid = AID_NO;
@@ -453,7 +457,7 @@ LIB3270_INTERNAL int check_online_session(const H3270 *hSession) {
return errno = EINVAL;
// Is it connected?
- if((int) hSession->cstate < (int)LIB3270_CONNECTED_INITIAL)
+ if((int) hSession->connection.state < (int)LIB3270_CONNECTED_INITIAL)
return errno = ENOTCONN;
return 0;
@@ -466,7 +470,7 @@ LIB3270_INTERNAL int check_offline_session(const H3270 *hSession) {
return errno = EINVAL;
// Is it connected?
- if((int) hSession->cstate >= (int)LIB3270_CONNECTED_INITIAL)
+ if((int) hSession->connection.state >= (int)LIB3270_CONNECTED_INITIAL)
return errno = EISCONN;
return 0;
diff --git a/src/core/sf.c b/src/core/sf.c
index ee52c2e..6f8aeeb 100644
--- a/src/core/sf.c
+++ b/src/core/sf.c
@@ -36,7 +36,7 @@
*
*/
-#include
+#include
#include
#include
diff --git a/src/core/state.c b/src/core/state.c
index d675f65..ccd46d8 100644
--- a/src/core/state.c
+++ b/src/core/state.c
@@ -27,63 +27,63 @@
*
*/
-#include
+#include
/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
LIB3270_EXPORT LIB3270_CSTATE lib3270_get_connection_state(const H3270 *h)
{
- return h->cstate;
+ return h->connection.state;
}
LIB3270_EXPORT int lib3270_pconnected(const H3270 *h)
{
- return (((int) h->cstate) >= (int)LIB3270_RESOLVING);
+ return (((int) h->connection.state) >= (int)LIB3270_RESOLVING);
}
LIB3270_EXPORT int lib3270_half_connected(const H3270 *h)
{
- return (h->cstate == LIB3270_RESOLVING || h->cstate == LIB3270_PENDING);
+ return (h->connection.state == LIB3270_RESOLVING || h->connection.state == LIB3270_PENDING);
}
LIB3270_EXPORT int lib3270_is_disconnected(const H3270 *h)
{
- return ((int) h->cstate == (int)LIB3270_NOT_CONNECTED);
+ return ((int) h->connection.state == (int)LIB3270_NOT_CONNECTED);
}
LIB3270_EXPORT int lib3270_in_neither(const H3270 *h)
{
- return (h->cstate == LIB3270_CONNECTED_INITIAL);
+ return (h->connection.state == LIB3270_CONNECTED_INITIAL);
}
LIB3270_EXPORT int lib3270_in_ansi(const H3270 *h)
{
- return (h->cstate == LIB3270_CONNECTED_ANSI || h->cstate == LIB3270_CONNECTED_NVT);
+ return (h->connection.state == LIB3270_CONNECTED_ANSI || h->connection.state == LIB3270_CONNECTED_NVT);
}
LIB3270_EXPORT int lib3270_in_3270(const H3270 *h)
{
- return (h->cstate == LIB3270_CONNECTED_3270 || h->cstate == LIB3270_CONNECTED_TN3270E || h->cstate == LIB3270_CONNECTED_SSCP);
+ return (h->connection.state == LIB3270_CONNECTED_3270 || h->connection.state == LIB3270_CONNECTED_TN3270E || h->connection.state == LIB3270_CONNECTED_SSCP);
}
LIB3270_EXPORT int lib3270_in_sscp(const H3270 *h)
{
- return (h->cstate == LIB3270_CONNECTED_SSCP);
+ return (h->connection.state == LIB3270_CONNECTED_SSCP);
}
LIB3270_EXPORT int lib3270_in_tn3270e(const H3270 *h)
{
- return (h->cstate == LIB3270_CONNECTED_TN3270E);
+ return (h->connection.state == LIB3270_CONNECTED_TN3270E);
}
LIB3270_EXPORT int lib3270_is_connected(const H3270 *h)
{
- return ((int) h->cstate >= (int)LIB3270_CONNECTED_INITIAL);
+ return ((int) h->connection.state >= (int)LIB3270_CONNECTED_INITIAL);
}
LIB3270_EXPORT int lib3270_in_e(const H3270 *h)
{
- return (h->cstate >= LIB3270_CONNECTED_INITIAL_E);
+ return (h->connection.state >= LIB3270_CONNECTED_INITIAL_E);
}
diff --git a/src/core/telnet.c b/src/core/telnet.c
index aa83f2a..73fcc83 100644
--- a/src/core/telnet.c
+++ b/src/core/telnet.c
@@ -55,7 +55,7 @@
#include
#endif
-#include
+#include
#include
#if defined(_WIN32)
@@ -550,17 +550,17 @@ LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession)
hSession->xio.write = 0;
}
- if(hSession->sock >= 0)
+ if(hSession->connection.sock >= 0)
{
- shutdown(hSession->sock, 2);
- SOCK_CLOSE(hSession->sock);
- hSession->sock = -1;
+ shutdown(hSession->connection.sock, 2);
+ SOCK_CLOSE(hSession->connection.sock);
+ hSession->connection.sock = -1;
}
+
}
-/*
- * net_disconnect
- * Shut down the socket.
+/**
+ * @brief Shut down the socket.
*/
void net_disconnect(H3270 *session)
{
@@ -641,7 +641,7 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED
for (;;)
#endif
{
- if (hSession->sock < 0)
+ if (hSession->connection.sock < 0)
return;
#if defined(X3270_ANSI)
@@ -652,9 +652,9 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED
if (hSession->ssl.con != NULL)
nr = SSL_read(hSession->ssl.con, (char *) buffer, BUFSZ);
else
- nr = recv(hSession->sock, (char *) buffer, BUFSZ, 0);
+ nr = recv(hSession->connection.sock, (char *) buffer, BUFSZ, 0);
#else
- nr = recv(hSession->sock, (char *) buffer, BUFSZ, 0);
+ nr = recv(hSession->connection.sock, (char *) buffer, BUFSZ, 0);
#endif // HAVE_LIBSSL
if (nr < 0)
@@ -1638,9 +1638,9 @@ LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf
if(hSession->ssl.con != NULL)
rc = SSL_write(hSession->ssl.con, (const char *) buf, len);
else
- rc = send(hSession->sock, (const char *) buf, len, 0);
+ rc = send(hSession->connection.sock, (const char *) buf, len, 0);
#else
- rc = send(hSession->sock, (const char *) buf, len, 0);
+ rc = send(hSession->connection.sock, (const char *) buf, len, 0);
#endif // HAVE_LIBSSL
if(rc > 0)
@@ -2076,14 +2076,14 @@ static void check_in3270(H3270 *hSession)
hSession->hisopts[TELOPT_BINARY] &&
hSession->hisopts[TELOPT_EOR]) {
new_cstate = LIB3270_CONNECTED_3270;
- } else if (hSession->cstate == LIB3270_CONNECTED_INITIAL) {
+ } else if (hSession->connection.state == LIB3270_CONNECTED_INITIAL) {
/* Nothing has happened, yet. */
return;
} else {
new_cstate = LIB3270_CONNECTED_ANSI;
}
- if (new_cstate != hSession->cstate) {
+ if (new_cstate != hSession->connection.state) {
#if defined(X3270_TN3270E) /*[*/
int was_in_e = IN_E;
#endif /*]*/
@@ -2658,7 +2658,7 @@ void net_abort(H3270 *hSession)
/* Return the local address for the socket. */
int net_getsockname(const H3270 *session, void *buf, int *len)
{
- if (session->sock < 0)
+ if (session->connection.sock < 0)
return -1;
- return getsockname(session->sock, buf, (socklen_t *)(void *)len);
+ return getsockname(session->connection.sock, buf, (socklen_t *)(void *)len);
}
diff --git a/src/core/toggles/getset.c b/src/core/toggles/getset.c
index 50c1741..e9b3756 100644
--- a/src/core/toggles/getset.c
+++ b/src/core/toggles/getset.c
@@ -34,7 +34,7 @@
*/
#include
-#include
+#include
#include
#include
#include "togglesc.h"
diff --git a/src/core/toggles/init.c b/src/core/toggles/init.c
index 8885515..7533ac2 100644
--- a/src/core/toggles/init.c
+++ b/src/core/toggles/init.c
@@ -46,7 +46,7 @@
#include
#include
-#include
+#include
#include "ansic.h"
#include "ctlrc.h"
@@ -79,12 +79,12 @@ static void toggle_nop(H3270 GNUC_UNUSED(*session), struct lib3270_toggle GNUC_U
static void toggle_keepalive(H3270 *session, struct lib3270_toggle GNUC_UNUSED(*t), LIB3270_TOGGLE_TYPE GNUC_UNUSED(tt))
{
- if(session->sock > 0)
+ if(session->connection.sock > 0)
{
// Update keep-alive option
int optval = t->value ? 1 : 0;
- if (setsockopt(session->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
+ if (setsockopt(session->connection.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
{
popup_a_sockerr(session, N_( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" ));
}
diff --git a/src/core/toggles/listener.c b/src/core/toggles/listener.c
index c7b4540..cec988f 100644
--- a/src/core/toggles/listener.c
+++ b/src/core/toggles/listener.c
@@ -34,7 +34,7 @@
*/
#include
-#include
+#include
#include
#include
diff --git a/src/core/toggles/table.c b/src/core/toggles/table.c
index 004ebdc..2a6f0c1 100644
--- a/src/core/toggles/table.c
+++ b/src/core/toggles/table.c
@@ -34,7 +34,7 @@
*/
#include
-#include
+#include
#include
#include "togglesc.h"
diff --git a/src/core/trace_ds.c b/src/core/trace_ds.c
index 8680a3f..20dcf9f 100644
--- a/src/core/trace_ds.c
+++ b/src/core/trace_ds.c
@@ -36,7 +36,7 @@
*
*/
-#include
+#include
#include
#if defined(X3270_TRACE) /*[*/
diff --git a/src/core/util.c b/src/core/util.c
index ab8f71f..fe8ad6c 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -34,7 +34,7 @@
#define _GNU_SOURCE
-#include
+#include
#include "utilc.h"
#include "popupsc.h"
#include
@@ -705,12 +705,12 @@ LIB3270_EXPORT int lib3270_getpeername(H3270 *hSession, struct sockaddr *addr, s
memset(addr,0,*addrlen);
- if(hSession->sock < 0) {
+ if(hSession->connection.sock < 0) {
errno = ENOTCONN;
return -1;
}
- return getpeername(hSession->sock, addr, addrlen);
+ return getpeername(hSession->connection.sock, addr, addrlen);
}
@@ -720,12 +720,12 @@ LIB3270_EXPORT int lib3270_getsockname(H3270 *hSession, struct sockaddr *addr, s
memset(addr,0,*addrlen);
- if(hSession->sock < 0) {
+ if(hSession->connection.sock < 0) {
errno = ENOTCONN;
return -1;
}
- return getsockname(hSession->sock, addr, addrlen);
+ return getsockname(hSession->connection.sock, addr, addrlen);
}
static int xdigit_value(const char scanner)
diff --git a/src/core/wait.c b/src/core/wait.c
index 74ce1fc..c4d8ed4 100644
--- a/src/core/wait.c
+++ b/src/core/wait.c
@@ -27,7 +27,7 @@
*
*/
-#include
+#include
#include
#include
#include "kybdc.h"
diff --git a/src/core/windows/connect.c b/src/core/windows/connect.c
index a8db30f..5c4fd54 100644
--- a/src/core/windows/connect.c
+++ b/src/core/windows/connect.c
@@ -37,7 +37,7 @@
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/windows/event_dispatcher.c b/src/core/windows/event_dispatcher.c
index 3d49ad1..3f53d66 100644
--- a/src/core/windows/event_dispatcher.c
+++ b/src/core/windows/event_dispatcher.c
@@ -32,7 +32,7 @@
*
*/
-#include
+#include
#include
#include
#include
diff --git a/src/core/windows/http.c b/src/core/windows/http.c
index 713b596..c80821e 100644
--- a/src/core/windows/http.c
+++ b/src/core/windows/http.c
@@ -37,7 +37,7 @@
*/
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/windows/log.c b/src/core/windows/log.c
index a01c9e4..603b708 100644
--- a/src/core/windows/log.c
+++ b/src/core/windows/log.c
@@ -32,7 +32,7 @@
#include