Commit df8fdf4c7031f2d55c891aa16cbd7621e8e3e6d8

Authored by Perry Werneck
1 parent 6ba51440

Adding listeners for action group state changes (required for the new

UI).
Showing 80 changed files with 1178 additions and 1065 deletions   Show diff stats
lib3270.cbp
... ... @@ -116,6 +116,9 @@
116 116 <Unit filename="src/core/keyboard/properties.c">
117 117 <Option compilerVar="CC" />
118 118 </Unit>
  119 + <Unit filename="src/core/linkedlist.c">
  120 + <Option compilerVar="CC" />
  121 + </Unit>
119 122 <Unit filename="src/core/linux/connect.c">
120 123 <Option compilerVar="CC" />
121 124 </Unit>
... ... @@ -242,8 +245,8 @@
242 245 <Unit filename="src/include/ft_dftc.h" />
243 246 <Unit filename="src/include/ftc.h" />
244 247 <Unit filename="src/include/hostc.h" />
  248 + <Unit filename="src/include/internals.h" />
245 249 <Unit filename="src/include/kybdc.h" />
246   - <Unit filename="src/include/lib3270-internals.h" />
247 250 <Unit filename="src/include/lib3270.h" />
248 251 <Unit filename="src/include/lib3270/actions.h" />
249 252 <Unit filename="src/include/lib3270/charset.h" />
... ...
src/core/actions/actions.c
... ... @@ -27,10 +27,17 @@
27 27 *
28 28 */
29 29  
30   -#include <lib3270-internals.h>
  30 +#include <internals.h>
  31 +#include <lib3270/log.h>
31 32 #include <lib3270/trace.h>
32 33 #include <lib3270/actions.h>
33 34  
  35 +struct lib3270_action_callback
  36 +{
  37 + LIB3270_LINKED_LIST_HEAD
  38 + void (*func)(H3270 *, void *); /**< @brief Function to call */
  39 +};
  40 +
34 41 /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
35 42  
36 43 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)
89 96 {
90 97 return lib3270_action_activate_by_name(name,hSession);
91 98 }
  99 +
  100 +LIB3270_INTERNAL void lib3270_notify_actions(H3270 *hSession, LIB3270_ACTION_GROUP group)
  101 +{
  102 +
  103 + if(group < (sizeof(hSession->listeners.actions)/sizeof(hSession->listeners.actions[0])))
  104 + {
  105 + struct lib3270_linked_list_node * node;
  106 +
  107 + for(node = hSession->listeners.actions[group].first; node; node = node->next)
  108 + {
  109 + ((struct lib3270_action_callback *) node)->func(hSession,node->userdata);
  110 + }
  111 +
  112 + }
  113 +
  114 +}
  115 +
  116 +LIB3270_EXPORT const void * lib3270_register_action_group_listener(H3270 *hSession, LIB3270_ACTION_GROUP group, void (*func)(H3270 *, void *),void *data)
  117 +{
  118 +
  119 + if(group < (sizeof(hSession->listeners.actions)/sizeof(hSession->listeners.actions[0])))
  120 + {
  121 + struct lib3270_action_callback *st = (struct lib3270_action_callback *) lib3270_linked_list_append_node(&hSession->listeners.actions[group], sizeof(struct lib3270_action_callback), data);
  122 + st->func = func;
  123 + return (void *) st;
  124 + }
  125 +
  126 + return NULL;
  127 +}
  128 +
  129 +LIB3270_EXPORT int lib3270_unregister_action_group_listener(H3270 *hSession, LIB3270_ACTION_GROUP group, const void *id)
  130 +{
  131 + if(group < (sizeof(hSession->listeners.actions)/sizeof(hSession->listeners.actions[0])))
  132 + return lib3270_linked_list_delete_node(&hSession->listeners.actions[group], id);
  133 +
  134 + return errno = EINVAL;
  135 +}
... ...
src/core/actions/table.c
... ... @@ -32,7 +32,7 @@
32 32 *
33 33 */
34 34  
35   -#include <lib3270-internals.h>
  35 +#include <internals.h>
36 36 #include <lib3270/trace.h>
37 37 #include <lib3270/actions.h>
38 38 #include <lib3270/toggle.h>
... ... @@ -210,7 +210,7 @@
210 210 .summary = N_( "Save selected area." ),
211 211 .activate = save_selected,
212 212  
213   - .group = LIB3270_ACTION_GROUP_SELECTION,
  213 + .group = LIB3270_ACTION_GROUP_SELECTED,
214 214 .activatable = lib3270_has_selection
215 215 },
216 216  
... ... @@ -591,7 +591,7 @@
591 591 .summary = N_( "Print selected area." ),
592 592 .activate = lib3270_print_selected,
593 593  
594   - .group = LIB3270_ACTION_GROUP_SELECTION,
  594 + .group = LIB3270_ACTION_GROUP_SELECTED,
595 595 .activatable = lib3270_has_selection
596 596 },
597 597  
... ...
src/core/ansi.c
... ... @@ -40,7 +40,7 @@
40 40 #pragma GCC diagnostic ignored "-Wstringop-truncation"
41 41 #endif // _WIN32
42 42  
43   -#include <lib3270-internals.h>
  43 +#include <internals.h>
44 44 #include <lib3270/toggle.h>
45 45  
46 46 #if defined(X3270_ANSI) /*[*/
... ...
src/core/bounds.c
... ... @@ -30,7 +30,7 @@
30 30 *
31 31 */
32 32  
33   -#include <lib3270-internals.h>
  33 +#include <internals.h>
34 34  
35 35 /*--[ Implement ]------------------------------------------------------------------------------------*/
36 36  
... ...
src/core/charset/charset.c
... ... @@ -35,7 +35,7 @@
35 35 * @brief This module handles character sets.
36 36 */
37 37  
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39 #include <X11keysym.h>
40 40 #include <lib3270/charset.h>
41 41 #include <lib3270/log.h>
... ...
src/core/charset/convert.c
... ... @@ -35,7 +35,7 @@
35 35 * @brief This module handles ebc<->asc conversion.
36 36 */
37 37  
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39 #include <lib3270/charset.h>
40 40 #include <lib3270/log.h>
41 41 #include <lib3270/trace.h>
... ...
src/core/charset/getset.c
... ... @@ -35,7 +35,7 @@
35 35 * @brief This module handles get/set the terminal character set.
36 36 */
37 37  
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39 #include <X11keysym.h>
40 40 #include <lib3270/charset.h>
41 41 #include <lib3270/log.h>
... ...
src/core/charset/remap.c
... ... @@ -35,7 +35,7 @@
35 35 * @brief
36 36 */
37 37  
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39 #include <lib3270/charset.h>
40 40 #include <lib3270/log.h>
41 41 #include <lib3270/trace.h>
... ...
src/core/charset/utf8.c
... ... @@ -35,7 +35,7 @@
35 35 * @brief 3270 Terminal Emulator UTF-8 conversions
36 36 */
37 37  
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39 // #include "api.h"
40 40  
41 41 #include "popupsc.h"
... ...
src/core/charset/view.c
... ... @@ -35,7 +35,7 @@
35 35 * @brief This module shows the charset table.
36 36 */
37 37  
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39 #include <lib3270/charset.h>
40 40 #include <lib3270/log.h>
41 41 #include <lib3270/trace.h>
... ...
src/core/connect.c
... ... @@ -28,7 +28,7 @@
28 28 */
29 29  
30 30 #include <config.h>
31   -#include <lib3270-internals.h>
  31 +#include <internals.h>
32 32 #include "telnetc.h"
33 33 #include <errno.h>
34 34 #include <lib3270/log.h>
... ... @@ -83,7 +83,7 @@
83 83 if(hSession->auto_reconnect_inprogress || hSession->popups)
84 84 return errno = EAGAIN;
85 85  
86   - if(hSession->sock > 0)
  86 + if(hSession->connection.sock > 0)
87 87 return errno = EISCONN;
88 88  
89 89 if(!(hSession->host.current && hSession->host.srvc))
... ...
src/core/ctlr.c
... ... @@ -34,7 +34,7 @@
34 34  
35 35 #pragma GCC diagnostic ignored "-Wsign-compare"
36 36  
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38  
39 39 #include <lib3270.h>
40 40 #include <lib3270/trace.h>
... ...
src/core/cursor.c
... ... @@ -32,7 +32,7 @@
32 32 */
33 33  
34 34  
35   -#include <lib3270-internals.h>
  35 +#include <internals.h>
36 36 #include <lib3270/trace.h>
37 37 #include <lib3270/log.h>
38 38 #include <lib3270/selection.h>
... ...
src/core/ft/ft.c
... ... @@ -40,7 +40,7 @@
40 40 #include <lib3270.h>
41 41 #include <lib3270/filetransfer.h>
42 42 #include <lib3270/log.h>
43   -#include <lib3270-internals.h>
  43 +#include <internals.h>
44 44 #include <lib3270/trace.h>
45 45  
46 46 #include <errno.h>
... ...
src/core/ft/ft_cut.c
... ... @@ -37,7 +37,7 @@
37 37  
38 38 #include <errno.h>
39 39  
40   -#include <lib3270-internals.h>
  40 +#include <internals.h>
41 41  
42 42 #include <lib3270.h>
43 43 #include <lib3270/actions.h>
... ...
src/core/ft/ft_dft.c
... ... @@ -42,7 +42,7 @@
42 42 #endif // WIN32
43 43  
44 44 #include <lib3270.h>
45   -#include <lib3270-internals.h>
  45 +#include <internals.h>
46 46  
47 47 #if defined(X3270_FT) /*[*/
48 48  
... ...
src/core/ft/ftmessages.c
... ... @@ -29,7 +29,7 @@
29 29 */
30 30  
31 31 #include <config.h>
32   -#include <lib3270-internals.h>
  32 +#include <internals.h>
33 33 #include <string.h>
34 34 #include <lib3270.h>
35 35 #include <lib3270/filetransfer.h>
... ...
src/core/host.c
... ... @@ -38,7 +38,7 @@
38 38 #pragma GCC diagnostic ignored "-Wsign-compare"
39 39  
40 40 #include <malloc.h>
41   -#include <lib3270-internals.h>
  41 +#include <internals.h>
42 42 #include "resources.h"
43 43  
44 44 #include "hostc.h"
... ... @@ -122,6 +122,36 @@ int host_disconnect(H3270 *hSession, int failed)
122 122  
123 123 }
124 124  
  125 +int lib3270_set_cstate(H3270 *hSession, LIB3270_CSTATE cstate)
  126 +{
  127 + if(hSession->connection.state != cstate)
  128 + {
  129 + // Salve old states.
  130 + int connected = lib3270_is_connected(hSession);
  131 + int disconnected = lib3270_is_disconnected(hSession);
  132 +
  133 + // Cstate has changed.
  134 + hSession->connection.state = cstate;
  135 +
  136 + // Do I need to send notifications?
  137 +
  138 + if(connected != lib3270_is_connected(hSession)) {
  139 + // Online state has changed, fire LIB3270_ACTION_GROUP_ONLINE
  140 + lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_ONLINE);
  141 + }
  142 +
  143 + if(disconnected != lib3270_is_disconnected(hSession)) {
  144 + // Offline state has changed, fire LIB3270_ACTION_GROUP_OFFLINE
  145 + lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_OFFLINE);
  146 + }
  147 +
  148 + return 1;
  149 + }
  150 +
  151 + return 0;
  152 +
  153 +}
  154 +
125 155 /**
126 156 * @brief The host has entered 3270 or ANSI mode, or switched between them.
127 157 */
... ... @@ -131,14 +161,15 @@ void host_in3270(H3270 *hSession, LIB3270_CSTATE new_cstate)
131 161 new_cstate == LIB3270_CONNECTED_SSCP ||
132 162 new_cstate == LIB3270_CONNECTED_TN3270E);
133 163  
134   - hSession->cstate = new_cstate;
  164 + lib3270_set_cstate(hSession,new_cstate);
135 165 hSession->ever_3270 = now3270;
136 166 lib3270_st_changed(hSession, LIB3270_STATE_3270_MODE, now3270);
137 167 }
138 168  
139 169 void lib3270_set_connected_initial(H3270 *hSession)
140 170 {
141   - hSession->cstate = LIB3270_CONNECTED_INITIAL;
  171 + lib3270_set_cstate(hSession,LIB3270_CONNECTED_INITIAL);
  172 +
142 173 hSession->starting = 1; // Enable autostart
143 174  
144 175 lib3270_st_changed(hSession, LIB3270_STATE_CONNECT, True);
... ... @@ -150,7 +181,7 @@ void lib3270_set_disconnected(H3270 *hSession)
150 181 {
151 182 CHECK_SESSION_HANDLE(hSession);
152 183  
153   - hSession->cstate = LIB3270_NOT_CONNECTED;
  184 + lib3270_set_cstate(hSession,LIB3270_NOT_CONNECTED);
154 185 hSession->starting = 0;
155 186  
156 187 #if defined(HAVE_LIBSSL)
... ... @@ -202,19 +233,6 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode)
202 233 ((struct lib3270_state_callback *) node)->func(h,mode,node->userdata);
203 234 }
204 235  
205   - /*
206   - struct lib3270_state_callback *st;
207   -
208   - CHECK_SESSION_HANDLE(h);
209   -
210   - trace("%s is %d on session %p",state_name[tx],mode,h);
211   -
212   - for(st = h->listeners.state.callbacks[tx];st;st = st->next)
213   - {
214   - st->func(h,mode,st->data);
215   - }
216   - */
217   -
218 236 trace("%s ends",__FUNCTION__);
219 237 }
220 238  
... ...
src/core/html.c
... ... @@ -39,7 +39,7 @@
39 39 #include "3270ds.h"
40 40 #include <lib3270/html.h>
41 41  
42   - #include <lib3270-internals.h>
  42 + #include <internals.h>
43 43 #include "utilc.h"
44 44  
45 45 struct chr_xlat
... ...
src/core/init.c
... ... @@ -52,7 +52,7 @@
52 52 #endif // _WIN32
53 53  
54 54 #include <lib3270/log.h>
55   -#include <lib3270-internals.h>
  55 +#include <internals.h>
56 56  
57 57 #ifdef HAVE_SYSLOG
58 58 #include <syslog.h>
... ...
src/core/iocalls.c
... ... @@ -29,7 +29,7 @@
29 29 *
30 30 */
31 31  
32   -#include <lib3270-internals.h>
  32 +#include <internals.h>
33 33 #include <sys/time.h>
34 34 #include <sys/types.h>
35 35 #include "xioc.h"
... ... @@ -301,7 +301,7 @@ static void internal_remove_poll(H3270 *session, void *id)
301 301  
302 302 LIB3270_EXPORT void lib3270_remove_poll(H3270 *session, void *id)
303 303 {
304   - debug("%s(%d,%p)",__FUNCTION__,session->sock,id);
  304 + debug("%s(%d,%p)",__FUNCTION__,session->connection.sock,id);
305 305 remove_poll(session, id);
306 306 }
307 307  
... ... @@ -309,7 +309,7 @@ LIB3270_EXPORT void lib3270_set_poll_state(H3270 *session, void *id, int enabled
309 309 {
310 310 if(id)
311 311 {
312   - debug("%s: Polling on %d (%p) is %s",__FUNCTION__,session->sock,id,(enabled ? "enabled" : "disabled"));
  312 + debug("%s: Polling on %d (%p) is %s",__FUNCTION__,session->connection.sock,id,(enabled ? "enabled" : "disabled"));
313 313 set_poll_state(session, id, enabled);
314 314 }
315 315 }
... ... @@ -349,7 +349,7 @@ LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FL
349 349 }
350 350  
351 351 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 ) {
352   - debug("%s(%d)",__FUNCTION__,session->sock);
  352 + debug("%s(%d)",__FUNCTION__,session->connection.sock);
353 353 return add_poll(session,fd,flag,call,userdata);
354 354 }
355 355  
... ... @@ -400,10 +400,10 @@ void x_except_on(H3270 *h)
400 400 if(reading)
401 401 lib3270_remove_poll(h,h->xio.read);
402 402  
403   - h->xio.except = lib3270_add_poll_fd(h,h->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0);
  403 + h->xio.except = lib3270_add_poll_fd(h,h->connection.sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0);
404 404  
405 405 if(reading)
406   - h->xio.read = lib3270_add_poll_fd(h,h->sock,LIB3270_IO_FLAG_READ,net_input,0);
  406 + h->xio.read = lib3270_add_poll_fd(h,h->connection.sock,LIB3270_IO_FLAG_READ,net_input,0);
407 407 debug("%s",__FUNCTION__);
408 408  
409 409 }
... ... @@ -523,7 +523,7 @@ LIB3270_EXPORT int lib3270_run_task(H3270 *hSession, int(*callback)(H3270 *h, vo
523 523 int non_blocking(H3270 *hSession, Boolean on)
524 524 {
525 525  
526   - if(hSession->sock < 0)
  526 + if(hSession->connection.sock < 0)
527 527 return 0;
528 528  
529 529 #ifdef WIN32
... ... @@ -545,7 +545,7 @@ int non_blocking(H3270 *hSession, Boolean on)
545 545  
546 546 int f;
547 547  
548   - if ((f = fcntl(hSession->sock, F_GETFL, 0)) == -1)
  548 + if ((f = fcntl(hSession->connection.sock, F_GETFL, 0)) == -1)
549 549 {
550 550 lib3270_popup_dialog( hSession,
551 551 LIB3270_NOTIFY_ERROR,
... ... @@ -562,7 +562,7 @@ int non_blocking(H3270 *hSession, Boolean on)
562 562 else
563 563 f &= ~O_NDELAY;
564 564  
565   - if (fcntl(hSession->sock, F_SETFL, f) < 0)
  565 + if (fcntl(hSession->connection.sock, F_SETFL, f) < 0)
566 566 {
567 567 lib3270_popup_dialog( hSession,
568 568 LIB3270_NOTIFY_ERROR,
... ...
src/core/keyboard/actions.c
... ... @@ -38,7 +38,7 @@ struct ta;
38 38  
39 39 #define LIB3270_TA struct ta
40 40  
41   -#include <lib3270-internals.h>
  41 +#include <internals.h>
42 42 #include <lib3270/trace.h>
43 43 #include <lib3270/selection.h>
44 44 #include <lib3270/log.h>
... ...
src/core/keyboard/kybd.c
... ... @@ -38,7 +38,7 @@ struct ta;
38 38  
39 39 #define LIB3270_TA struct ta
40 40  
41   -#include <lib3270-internals.h>
  41 +#include <internals.h>
42 42 #include <lib3270/trace.h>
43 43 #include <lib3270/selection.h>
44 44 #include <lib3270/log.h>
... ...
src/core/keyboard/properties.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   -#include <lib3270-internals.h>
  30 +#include <internals.h>
31 31 #include <lib3270/keyboard.h>
32 32 #include <lib3270/properties.h>
33 33  
... ...
src/core/linux/connect.c
... ... @@ -28,7 +28,7 @@
28 28 */
29 29  
30 30 #include <config.h>
31   -#include <lib3270-internals.h>
  31 +#include <internals.h>
32 32 #include <errno.h>
33 33 #include <lib3270/trace.h>
34 34 #include <lib3270/toggle.h>
... ... @@ -46,7 +46,7 @@
46 46 // #include <iconv.h>
47 47 // #endif // HAVE_ICONV
48 48  
49   -#define SOCK_CLOSE(s) close(s->sock); s->sock = -1;
  49 +#define SOCK_CLOSE(s) close(s->connection.sock); s->connection.sock = -1;
50 50  
51 51 #include <stdlib.h>
52 52  
... ... @@ -73,7 +73,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
73 73 hSession->xio.write = NULL;
74 74 }
75 75  
76   - if(getsockopt(hSession->sock, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0)
  76 + if(getsockopt(hSession->connection.sock, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0)
77 77 {
78 78 lib3270_disconnect(hSession);
79 79 lib3270_popup_dialog(
... ... @@ -102,8 +102,8 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
102 102 return;
103 103 }
104 104  
105   - hSession->xio.except = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0);
106   - hSession->xio.read = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_READ,net_input,0);
  105 + hSession->xio.except = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0);
  106 + hSession->xio.read = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_READ,net_input,0);
107 107  
108 108 #if defined(HAVE_LIBSSL)
109 109 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
147 147  
148 148 status_connecting(hSession);
149 149  
150   - for(rp = result; hSession->sock < 0 && rp != NULL; rp = rp->ai_next)
  150 + for(rp = result; hSession->connection.sock < 0 && rp != NULL; rp = rp->ai_next)
151 151 {
152   - hSession->sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
153   - if(hSession->sock < 0)
  152 + hSession->connection.sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  153 + if(hSession->connection.sock < 0)
154 154 {
155 155 ((struct resolver *) host)->message = strerror(errno);
156 156 continue;
157 157 }
158 158  
159 159 // Connected!
160   - if(connect(hSession->sock, rp->ai_addr, rp->ai_addrlen))
  160 + if(connect(hSession->connection.sock, rp->ai_addr, rp->ai_addrlen))
161 161 {
162 162 SOCK_CLOSE(hSession);
163 163 ((struct resolver *) host)->message = strerror(errno);
... ... @@ -178,7 +178,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
178 178 memset(&host,0,sizeof(host));
179 179  
180 180 // Connect to host
181   - if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0)
  181 + if(lib3270_run_task(hSession, background_connect, &host) || hSession->connection.sock < 0)
182 182 {
183 183 char buffer[4096];
184 184 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
195 195 }
196 196  
197 197 /* don't share the socket with our children */
198   - (void) fcntl(hSession->sock, F_SETFD, 1);
  198 + (void) fcntl(hSession->connection.sock, F_SETFD, 1);
199 199  
200 200 hSession->ever_3270 = False;
201 201  
... ... @@ -212,7 +212,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
212 212  
213 213 // set options for inline out-of-band data and keepalives
214 214 int optval = 1;
215   - if (setsockopt(hSession->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0)
  215 + if (setsockopt(hSession->connection.sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0)
216 216 {
217 217 int rc = errno;
218 218 lib3270_popup_dialog( hSession,
... ... @@ -226,7 +226,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
226 226 }
227 227  
228 228 optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0;
229   - if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
  229 + if (setsockopt(hSession->connection.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
230 230 {
231 231 int rc = errno;
232 232  
... ... @@ -260,10 +260,10 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
260 260 */
261 261  
262 262 // Connecting, set callbacks, wait for connection
263   - hSession->cstate = LIB3270_PENDING;
  263 + lib3270_set_cstate(hSession, LIB3270_PENDING);
264 264 lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True);
265 265  
266   - hSession->xio.write = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_WRITE,net_connected,0);
  266 + hSession->xio.write = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_WRITE,net_connected,0);
267 267 // hSession->ns_write_id = AddOutput(hSession->sock, hSession, net_connected);
268 268  
269 269 trace("%s: Connection in progress",__FUNCTION__);
... ... @@ -276,7 +276,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
276 276 {
277 277 lib3270_main_iterate(hSession,1);
278 278  
279   - switch(hSession->cstate)
  279 + switch(hSession->connection.state)
280 280 {
281 281 case LIB3270_PENDING:
282 282 case LIB3270_CONNECTED_INITIAL:
... ... @@ -297,7 +297,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG
297 297 break;
298 298  
299 299 default:
300   - lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->cstate);
  300 + lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->connection.state);
301 301 return errno = EINVAL;
302 302 }
303 303  
... ...
src/core/linux/curl.c
... ... @@ -31,7 +31,7 @@
31 31  
32 32 #if defined(HAVE_LIBCURL)
33 33  
34   -#include <lib3270-internals.h>
  34 +#include <internals.h>
35 35 #include <lib3270.h>
36 36 #include <lib3270/log.h>
37 37 #include <lib3270/trace.h>
... ...
src/core/linux/event_dispatcher.c
... ... @@ -32,7 +32,7 @@
32 32 *
33 33 */
34 34  
35   -#include <lib3270-internals.h>
  35 +#include <internals.h>
36 36 #include <sys/time.h>
37 37 #include <sys/types.h>
38 38 #include <lib3270/log.h>
... ...
src/core/linux/log.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   -#include <lib3270-internals.h>
  30 +#include <internals.h>
31 31 #include <stdio.h>
32 32 #include <stdarg.h>
33 33 #include <config.h>
... ...
src/core/linux/util.c
... ... @@ -35,7 +35,7 @@
35 35  
36 36 #include <config.h>
37 37 #include <stdarg.h>
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39 #include <unistd.h>
40 40  
41 41 static char * concat(char *path, const char *name, size_t *length)
... ...
src/core/log.c
... ... @@ -35,7 +35,7 @@
35 35 #include <windows.h>
36 36 #endif // WIN32
37 37  
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39 #include <stdio.h>
40 40 #include <stdarg.h>
41 41 #include <config.h>
... ...
src/core/model.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   - #include <lib3270-internals.h>
  30 + #include <internals.h>
31 31 #include "screen.h"
32 32 #include "ctlrc.h"
33 33 #include "popupsc.h"
... ... @@ -42,7 +42,7 @@
42 42  
43 43 int lib3270_set_oversize(H3270 *hSession, const char *value)
44 44 {
45   - if(hSession->cstate != LIB3270_NOT_CONNECTED)
  45 + if(hSession->connection.state != LIB3270_NOT_CONNECTED)
46 46 return errno = EISCONN;
47 47  
48 48 if(!hSession->extended)
... ... @@ -177,7 +177,7 @@ int lib3270_set_model(H3270 *hSession, const char *model)
177 177 {
178 178 int model_number;
179 179  
180   - if(hSession->cstate != LIB3270_NOT_CONNECTED)
  180 + if(hSession->connection.state != LIB3270_NOT_CONNECTED)
181 181 return errno = EISCONN;
182 182  
183 183 strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH);
... ...
src/core/options.c
... ... @@ -29,7 +29,7 @@
29 29 *
30 30 */
31 31  
32   -#include <lib3270-internals.h>
  32 +#include <internals.h>
33 33  
34 34 /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/
35 35  
... ... @@ -94,7 +94,7 @@ LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype)
94 94 {
95 95 CHECK_SESSION_HANDLE(hSession);
96 96  
97   - if(hSession->cstate != LIB3270_NOT_CONNECTED)
  97 + if(hSession->connection.state != LIB3270_NOT_CONNECTED)
98 98 return errno = EISCONN;
99 99  
100 100 switch(colortype)
... ...
src/core/paste.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   -#include <lib3270-internals.h>
  30 +#include <internals.h>
31 31  
32 32 /*
33 33 #if defined(X3270_DISPLAY)
... ...
src/core/print.c
... ... @@ -35,4 +35,4 @@
35 35 * Screen printing functions.
36 36 */
37 37  
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
... ...
src/core/printer.c
... ... @@ -36,7 +36,7 @@
36 36 * Printer session support
37 37 */
38 38  
39   -#include <lib3270-internals.h>
  39 +#include <internals.h>
40 40  
41 41 #if (defined(C3270) || defined(X3270_DISPLAY)) && defined(X3270_PRINTER) /*[*/
42 42  
... ...
src/core/properties/boolean.c
... ... @@ -28,7 +28,7 @@
28 28 */
29 29  
30 30 #include <config.h>
31   - #include <lib3270-internals.h>
  31 + #include <internals.h>
32 32 #include <string.h>
33 33 #include <lib3270.h>
34 34 #include <lib3270/properties.h>
... ...
src/core/properties/get.c
... ... @@ -28,7 +28,7 @@
28 28 */
29 29  
30 30 #include <config.h>
31   - #include <lib3270-internals.h>
  31 + #include <internals.h>
32 32 #include <string.h>
33 33 #include <lib3270.h>
34 34 #include <lib3270/properties.h>
... ...
src/core/properties/signed.c
... ... @@ -28,7 +28,7 @@
28 28 */
29 29  
30 30 #include <config.h>
31   - #include <lib3270-internals.h>
  31 + #include <internals.h>
32 32 #include <string.h>
33 33 #include <lib3270.h>
34 34 #include <lib3270/properties.h>
... ...
src/core/properties/string.c
... ... @@ -28,7 +28,7 @@
28 28 */
29 29  
30 30 #include <config.h>
31   - #include <lib3270-internals.h>
  31 + #include <internals.h>
32 32 #include <string.h>
33 33 #include <lib3270.h>
34 34 #include <lib3270/properties.h>
... ...
src/core/properties/unsigned.c
... ... @@ -28,7 +28,7 @@
28 28 */
29 29  
30 30 #include <config.h>
31   - #include <lib3270-internals.h>
  31 + #include <internals.h>
32 32 #include <string.h>
33 33 #include <lib3270.h>
34 34 #include <lib3270/properties.h>
... ...
src/core/resources.c
... ... @@ -34,7 +34,7 @@
34 34 #include <stdio.h>
35 35 #include <string.h>
36 36  
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38 #include "utilc.h"
39 39 #include <lib3270/log.h>
40 40  
... ...
src/core/rpq.c
... ... @@ -37,7 +37,7 @@
37 37 *
38 38 */
39 39  
40   -#include <lib3270-internals.h>
  40 +#include <internals.h>
41 41 #include <errno.h>
42 42 #if !defined(_WIN32) /*[*/
43 43 #include <netinet/in.h>
... ...
src/core/screen.c
... ... @@ -34,7 +34,7 @@
34 34 *
35 35 */
36 36  
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38 #include <signal.h>
39 39 #include "3270ds.h"
40 40 #include "resources.h"
... ... @@ -550,7 +550,7 @@ void status_oerr(H3270 *session, int error_type)
550 550 */
551 551 void status_resolving(H3270 *hSession)
552 552 {
553   - hSession->cstate = LIB3270_RESOLVING;
  553 + lib3270_set_cstate(hSession,LIB3270_RESOLVING);
554 554 lib3270_st_changed(hSession, LIB3270_STATE_RESOLVING, True);
555 555  
556 556 mcursor_set(hSession,LIB3270_POINTER_LOCKED);
... ... @@ -559,7 +559,7 @@ void status_resolving(H3270 *hSession)
559 559  
560 560 void status_connecting(H3270 *hSession)
561 561 {
562   - hSession->cstate = LIB3270_RESOLVING;
  562 + lib3270_set_cstate(hSession,LIB3270_RESOLVING);
563 563 lib3270_st_changed(hSession, LIB3270_STATE_CONNECTING, True);
564 564  
565 565 mcursor_set(hSession,LIB3270_POINTER_LOCKED);
... ...
src/core/see.c
... ... @@ -36,7 +36,7 @@
36 36 *
37 37 */
38 38  
39   -#include <lib3270-internals.h>
  39 +#include <internals.h>
40 40  
41 41 #if defined(X3270_TRACE) /*[*/
42 42  
... ...
src/core/session.c
... ... @@ -33,7 +33,7 @@
33 33 #include <stdlib.h>
34 34 #endif // !ANDROID
35 35  
36   -#include <lib3270-internals.h>
  36 +#include <internals.h>
37 37 #include "kybdc.h"
38 38 #include "ansic.h"
39 39 #include "togglesc.h"
... ... @@ -95,6 +95,10 @@ void lib3270_session_free(H3270 *h)
95 95 for(f=0;f<LIB3270_TOGGLE_COUNT;f++)
96 96 lib3270_linked_list_free(&h->listeners.toggle[f]);
97 97  
  98 + // Release action listeners.
  99 + for(f=0;f<LIB3270_ACTION_GROUP_CUSTOM;f++)
  100 + lib3270_linked_list_free(&h->listeners.actions[f]);
  101 +
98 102 // Release memory
99 103 #define release_pointer(x) lib3270_free(x); x = NULL;
100 104  
... ... @@ -331,9 +335,9 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char
331 335 hSession->unlock_delay = 1;
332 336 hSession->icrnl = 1;
333 337 hSession->onlcr = 1;
334   - hSession->sock = -1;
  338 + hSession->connection.sock = -1;
335 339 hSession->model_num = -1;
336   - hSession->cstate = LIB3270_NOT_CONNECTED;
  340 + hSession->connection.state = LIB3270_NOT_CONNECTED;
337 341 hSession->oia.status = -1;
338 342 hSession->kybdlock = KL_NOT_CONNECTED;
339 343 hSession->aid = AID_NO;
... ... @@ -453,7 +457,7 @@ LIB3270_INTERNAL int check_online_session(const H3270 *hSession) {
453 457 return errno = EINVAL;
454 458  
455 459 // Is it connected?
456   - if((int) hSession->cstate < (int)LIB3270_CONNECTED_INITIAL)
  460 + if((int) hSession->connection.state < (int)LIB3270_CONNECTED_INITIAL)
457 461 return errno = ENOTCONN;
458 462  
459 463 return 0;
... ... @@ -466,7 +470,7 @@ LIB3270_INTERNAL int check_offline_session(const H3270 *hSession) {
466 470 return errno = EINVAL;
467 471  
468 472 // Is it connected?
469   - if((int) hSession->cstate >= (int)LIB3270_CONNECTED_INITIAL)
  473 + if((int) hSession->connection.state >= (int)LIB3270_CONNECTED_INITIAL)
470 474 return errno = EISCONN;
471 475  
472 476 return 0;
... ...
src/core/sf.c
... ... @@ -36,7 +36,7 @@
36 36 *
37 37 */
38 38  
39   -#include <lib3270-internals.h>
  39 +#include <internals.h>
40 40 #include <lib3270/trace.h>
41 41  
42 42 #include <errno.h>
... ...
src/core/state.c
... ... @@ -27,63 +27,63 @@
27 27 *
28 28 */
29 29  
30   -#include <lib3270-internals.h>
  30 +#include <internals.h>
31 31  
32 32 /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
33 33  
34 34 LIB3270_EXPORT LIB3270_CSTATE lib3270_get_connection_state(const H3270 *h)
35 35 {
36   - return h->cstate;
  36 + return h->connection.state;
37 37 }
38 38  
39 39 LIB3270_EXPORT int lib3270_pconnected(const H3270 *h)
40 40 {
41   - return (((int) h->cstate) >= (int)LIB3270_RESOLVING);
  41 + return (((int) h->connection.state) >= (int)LIB3270_RESOLVING);
42 42 }
43 43  
44 44 LIB3270_EXPORT int lib3270_half_connected(const H3270 *h)
45 45 {
46   - return (h->cstate == LIB3270_RESOLVING || h->cstate == LIB3270_PENDING);
  46 + return (h->connection.state == LIB3270_RESOLVING || h->connection.state == LIB3270_PENDING);
47 47 }
48 48  
49 49 LIB3270_EXPORT int lib3270_is_disconnected(const H3270 *h)
50 50 {
51   - return ((int) h->cstate == (int)LIB3270_NOT_CONNECTED);
  51 + return ((int) h->connection.state == (int)LIB3270_NOT_CONNECTED);
52 52 }
53 53  
54 54 LIB3270_EXPORT int lib3270_in_neither(const H3270 *h)
55 55 {
56   - return (h->cstate == LIB3270_CONNECTED_INITIAL);
  56 + return (h->connection.state == LIB3270_CONNECTED_INITIAL);
57 57 }
58 58  
59 59 LIB3270_EXPORT int lib3270_in_ansi(const H3270 *h)
60 60 {
61   - return (h->cstate == LIB3270_CONNECTED_ANSI || h->cstate == LIB3270_CONNECTED_NVT);
  61 + return (h->connection.state == LIB3270_CONNECTED_ANSI || h->connection.state == LIB3270_CONNECTED_NVT);
62 62 }
63 63  
64 64 LIB3270_EXPORT int lib3270_in_3270(const H3270 *h)
65 65 {
66   - return (h->cstate == LIB3270_CONNECTED_3270 || h->cstate == LIB3270_CONNECTED_TN3270E || h->cstate == LIB3270_CONNECTED_SSCP);
  66 + return (h->connection.state == LIB3270_CONNECTED_3270 || h->connection.state == LIB3270_CONNECTED_TN3270E || h->connection.state == LIB3270_CONNECTED_SSCP);
67 67 }
68 68  
69 69 LIB3270_EXPORT int lib3270_in_sscp(const H3270 *h)
70 70 {
71   - return (h->cstate == LIB3270_CONNECTED_SSCP);
  71 + return (h->connection.state == LIB3270_CONNECTED_SSCP);
72 72 }
73 73  
74 74 LIB3270_EXPORT int lib3270_in_tn3270e(const H3270 *h)
75 75 {
76   - return (h->cstate == LIB3270_CONNECTED_TN3270E);
  76 + return (h->connection.state == LIB3270_CONNECTED_TN3270E);
77 77 }
78 78  
79 79 LIB3270_EXPORT int lib3270_is_connected(const H3270 *h)
80 80 {
81   - return ((int) h->cstate >= (int)LIB3270_CONNECTED_INITIAL);
  81 + return ((int) h->connection.state >= (int)LIB3270_CONNECTED_INITIAL);
82 82 }
83 83  
84 84 LIB3270_EXPORT int lib3270_in_e(const H3270 *h)
85 85 {
86   - return (h->cstate >= LIB3270_CONNECTED_INITIAL_E);
  86 + return (h->connection.state >= LIB3270_CONNECTED_INITIAL_E);
87 87 }
88 88  
89 89  
... ...
src/core/telnet.c
... ... @@ -55,7 +55,7 @@
55 55 #include <openssl/err.h>
56 56 #endif
57 57  
58   -#include <lib3270-internals.h>
  58 +#include <internals.h>
59 59 #include <errno.h>
60 60  
61 61 #if defined(_WIN32)
... ... @@ -550,17 +550,17 @@ LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession)
550 550 hSession->xio.write = 0;
551 551 }
552 552  
553   - if(hSession->sock >= 0)
  553 + if(hSession->connection.sock >= 0)
554 554 {
555   - shutdown(hSession->sock, 2);
556   - SOCK_CLOSE(hSession->sock);
557   - hSession->sock = -1;
  555 + shutdown(hSession->connection.sock, 2);
  556 + SOCK_CLOSE(hSession->connection.sock);
  557 + hSession->connection.sock = -1;
558 558 }
  559 +
559 560 }
560 561  
561   -/*
562   - * net_disconnect
563   - * Shut down the socket.
  562 +/**
  563 + * @brief Shut down the socket.
564 564 */
565 565 void net_disconnect(H3270 *session)
566 566 {
... ... @@ -641,7 +641,7 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED
641 641 for (;;)
642 642 #endif
643 643 {
644   - if (hSession->sock < 0)
  644 + if (hSession->connection.sock < 0)
645 645 return;
646 646  
647 647 #if defined(X3270_ANSI)
... ... @@ -652,9 +652,9 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED
652 652 if (hSession->ssl.con != NULL)
653 653 nr = SSL_read(hSession->ssl.con, (char *) buffer, BUFSZ);
654 654 else
655   - nr = recv(hSession->sock, (char *) buffer, BUFSZ, 0);
  655 + nr = recv(hSession->connection.sock, (char *) buffer, BUFSZ, 0);
656 656 #else
657   - nr = recv(hSession->sock, (char *) buffer, BUFSZ, 0);
  657 + nr = recv(hSession->connection.sock, (char *) buffer, BUFSZ, 0);
658 658 #endif // HAVE_LIBSSL
659 659  
660 660 if (nr < 0)
... ... @@ -1638,9 +1638,9 @@ LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf
1638 1638 if(hSession->ssl.con != NULL)
1639 1639 rc = SSL_write(hSession->ssl.con, (const char *) buf, len);
1640 1640 else
1641   - rc = send(hSession->sock, (const char *) buf, len, 0);
  1641 + rc = send(hSession->connection.sock, (const char *) buf, len, 0);
1642 1642 #else
1643   - rc = send(hSession->sock, (const char *) buf, len, 0);
  1643 + rc = send(hSession->connection.sock, (const char *) buf, len, 0);
1644 1644 #endif // HAVE_LIBSSL
1645 1645  
1646 1646 if(rc > 0)
... ... @@ -2076,14 +2076,14 @@ static void check_in3270(H3270 *hSession)
2076 2076 hSession->hisopts[TELOPT_BINARY] &&
2077 2077 hSession->hisopts[TELOPT_EOR]) {
2078 2078 new_cstate = LIB3270_CONNECTED_3270;
2079   - } else if (hSession->cstate == LIB3270_CONNECTED_INITIAL) {
  2079 + } else if (hSession->connection.state == LIB3270_CONNECTED_INITIAL) {
2080 2080 /* Nothing has happened, yet. */
2081 2081 return;
2082 2082 } else {
2083 2083 new_cstate = LIB3270_CONNECTED_ANSI;
2084 2084 }
2085 2085  
2086   - if (new_cstate != hSession->cstate) {
  2086 + if (new_cstate != hSession->connection.state) {
2087 2087 #if defined(X3270_TN3270E) /*[*/
2088 2088 int was_in_e = IN_E;
2089 2089 #endif /*]*/
... ... @@ -2658,7 +2658,7 @@ void net_abort(H3270 *hSession)
2658 2658 /* Return the local address for the socket. */
2659 2659 int net_getsockname(const H3270 *session, void *buf, int *len)
2660 2660 {
2661   - if (session->sock < 0)
  2661 + if (session->connection.sock < 0)
2662 2662 return -1;
2663   - return getsockname(session->sock, buf, (socklen_t *)(void *)len);
  2663 + return getsockname(session->connection.sock, buf, (socklen_t *)(void *)len);
2664 2664 }
... ...
src/core/toggles/getset.c
... ... @@ -34,7 +34,7 @@
34 34 */
35 35  
36 36 #include <config.h>
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38 #include <lib3270/toggle.h>
39 39 #include <lib3270/log.h>
40 40 #include "togglesc.h"
... ...
src/core/toggles/init.c
... ... @@ -46,7 +46,7 @@
46 46  
47 47 #include <config.h>
48 48 #include <lib3270/toggle.h>
49   -#include <lib3270-internals.h>
  49 +#include <internals.h>
50 50  
51 51 #include "ansic.h"
52 52 #include "ctlrc.h"
... ... @@ -79,12 +79,12 @@ static void toggle_nop(H3270 GNUC_UNUSED(*session), struct lib3270_toggle GNUC_U
79 79  
80 80 static void toggle_keepalive(H3270 *session, struct lib3270_toggle GNUC_UNUSED(*t), LIB3270_TOGGLE_TYPE GNUC_UNUSED(tt))
81 81 {
82   - if(session->sock > 0)
  82 + if(session->connection.sock > 0)
83 83 {
84 84 // Update keep-alive option
85 85 int optval = t->value ? 1 : 0;
86 86  
87   - if (setsockopt(session->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
  87 + if (setsockopt(session->connection.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
88 88 {
89 89 popup_a_sockerr(session, N_( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" ));
90 90 }
... ...
src/core/toggles/listener.c
... ... @@ -34,7 +34,7 @@
34 34 */
35 35  
36 36 #include <config.h>
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38 #include <lib3270/toggle.h>
39 39 #include <lib3270/log.h>
40 40  
... ...
src/core/toggles/table.c
... ... @@ -34,7 +34,7 @@
34 34 */
35 35  
36 36 #include <config.h>
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38 #include <lib3270/toggle.h>
39 39 #include "togglesc.h"
40 40  
... ...
src/core/trace_ds.c
... ... @@ -36,7 +36,7 @@
36 36 *
37 37 */
38 38  
39   -#include <lib3270-internals.h>
  39 +#include <internals.h>
40 40 #include <lib3270/trace.h>
41 41  
42 42 #if defined(X3270_TRACE) /*[*/
... ...
src/core/util.c
... ... @@ -34,7 +34,7 @@
34 34  
35 35 #define _GNU_SOURCE
36 36  
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38 #include "utilc.h"
39 39 #include "popupsc.h"
40 40 #include <lib3270/selection.h>
... ... @@ -705,12 +705,12 @@ LIB3270_EXPORT int lib3270_getpeername(H3270 *hSession, struct sockaddr *addr, s
705 705  
706 706 memset(addr,0,*addrlen);
707 707  
708   - if(hSession->sock < 0) {
  708 + if(hSession->connection.sock < 0) {
709 709 errno = ENOTCONN;
710 710 return -1;
711 711 }
712 712  
713   - return getpeername(hSession->sock, addr, addrlen);
  713 + return getpeername(hSession->connection.sock, addr, addrlen);
714 714  
715 715 }
716 716  
... ... @@ -720,12 +720,12 @@ LIB3270_EXPORT int lib3270_getsockname(H3270 *hSession, struct sockaddr *addr, s
720 720  
721 721 memset(addr,0,*addrlen);
722 722  
723   - if(hSession->sock < 0) {
  723 + if(hSession->connection.sock < 0) {
724 724 errno = ENOTCONN;
725 725 return -1;
726 726 }
727 727  
728   - return getsockname(hSession->sock, addr, addrlen);
  728 + return getsockname(hSession->connection.sock, addr, addrlen);
729 729 }
730 730  
731 731 static int xdigit_value(const char scanner)
... ...
src/core/wait.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   -#include <lib3270-internals.h>
  30 +#include <internals.h>
31 31 #include <lib3270/log.h>
32 32 #include <lib3270/trace.h>
33 33 #include "kybdc.h"
... ...
src/core/windows/connect.c
... ... @@ -37,7 +37,7 @@
37 37 #include <windows.h>
38 38 #include <ws2tcpip.h>
39 39  
40   -#include <lib3270-internals.h>
  40 +#include <internals.h>
41 41 #include <errno.h>
42 42 #include <lib3270/trace.h>
43 43 #include <lib3270/log.h>
... ...
src/core/windows/event_dispatcher.c
... ... @@ -32,7 +32,7 @@
32 32 *
33 33 */
34 34  
35   -#include <lib3270-internals.h>
  35 +#include <internals.h>
36 36 #include <sys/time.h>
37 37 #include <sys/types.h>
38 38 #include <lib3270/log.h>
... ...
src/core/windows/http.c
... ... @@ -37,7 +37,7 @@
37 37 */
38 38  
39 39 #include <config.h>
40   -#include <lib3270-internals.h>
  40 +#include <internals.h>
41 41 #include <lib3270/log.h>
42 42 #include <lib3270/trace.h>
43 43 #include <winhttp.h>
... ...
src/core/windows/log.c
... ... @@ -32,7 +32,7 @@
32 32 #include <wtsapi32.h>
33 33 #include <lmcons.h>
34 34  
35   -#include <lib3270-internals.h>
  35 +#include <internals.h>
36 36 #include <stdio.h>
37 37 #include <stdarg.h>
38 38 #include <config.h>
... ...
src/core/windows/util.c
... ... @@ -35,7 +35,7 @@
35 35 #include <winsock2.h>
36 36 #include <windows.h>
37 37 #include <lmcons.h>
38   -#include <lib3270-internals.h>
  38 +#include <internals.h>
39 39  
40 40 #include "winversc.h"
41 41 #include <ws2tcpip.h>
... ...
src/include/internals.h 0 → 100644
... ... @@ -0,0 +1,882 @@
  1 +/*
  2 + * "Software G3270, 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 ', 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 private.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 + *
  28 + */
  29 +
  30 +#ifdef WIN32
  31 + #include <winsock2.h>
  32 + #include <windows.h>
  33 +#endif // WIN32
  34 +
  35 +#include <config.h> /* autoconf settings */
  36 +#include <lib3270.h> /* lib3270 API calls and defs */
  37 +#include <linkedlist.h>
  38 +#include <lib3270/charset.h>
  39 +#include <lib3270/session.h>
  40 +#include <lib3270/actions.h>
  41 +
  42 +#if defined(HAVE_LIBSSL)
  43 + #include <openssl/ssl.h>
  44 + #include <openssl/x509v3.h>
  45 +
  46 +#endif // HAVE_LIBSSL
  47 +
  48 +#if defined(X3270_TN3270E) && !defined(X3270_ANSI) /*[*/
  49 + #define X3270_ANSI 1 /* RFC2355 requires NVT mode */
  50 +#endif /*]*/
  51 +
  52 +#if defined(HAVE_VASPRINTF) && !defined(_GNU_SOURCE) /*[*/
  53 + #define _GNU_SOURCE /* vasprintf isn't POSIX */
  54 +#endif /*]*/
  55 +
  56 +/*
  57 + * gettext stuff
  58 + */
  59 +#ifdef ANDROID
  60 + #undef HAVE_LIBINTL
  61 + #undef HAVE_LIBSSL
  62 +#endif
  63 +
  64 +#ifdef HAVE_LIBINTL
  65 + #include <libintl.h>
  66 + #define _( x ) gettext(x)
  67 + #define N_( x ) x
  68 +#else
  69 + #define _( x ) x
  70 + #define N_( x ) x
  71 +#endif // HAVE_LIBINTL
  72 +
  73 +#define action_name(x) #x
  74 +
  75 +//
  76 +// Compiler-specific #defines.
  77 +//
  78 +// Reference: GLIBC gmacros.h
  79 +//
  80 +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
  81 +
  82 + #define GNUC_UNUSED \
  83 + __attribute__((__unused__))
  84 +
  85 +#else
  86 +
  87 + #define unused
  88 + #define GNUC_UNUSED
  89 + #define printflike(s, f)
  90 +
  91 +#endif
  92 +
  93 +#if defined(_WIN32) || defined(_MSC_VER)
  94 +
  95 + #include <winsock2.h>
  96 + #include <windows.h>
  97 +
  98 +#else
  99 +
  100 + #include <unistd.h> /* Unix system calls */
  101 + #include <sys/time.h> /* System time-related data types */
  102 +
  103 +#endif // _WIN32
  104 +
  105 +/*
  106 + * Prerequisite #includes.
  107 + */
  108 +#include <stdio.h> /* Unix standard I/O library */
  109 +#include <ctype.h> /* Character classes */
  110 +#include <string.h> /* String manipulations */
  111 +#include <sys/types.h> /* Basic system data types */
  112 +#include <time.h> /* C library time functions */
  113 +#include "localdefs.h" /* {s,tcl,c}3270-specific defines */
  114 +
  115 +/*
  116 + * Cancel out contradictory parts.
  117 + */
  118 +#if !defined(X3270_DISPLAY) /*[*/
  119 + #undef X3270_KEYPAD
  120 + #undef X3270_MENUS
  121 +#endif /*]*/
  122 +
  123 +#define RECONNECT_MS 2000 /**< @brief 2 sec before reconnecting to host. */
  124 +#define RECONNECT_ERR_MS 5000 /**< @brief 5 sec before reconnecting to host when failed */
  125 +
  126 +/**
  127 + * @brief types of internal actions
  128 + */
  129 +enum iaction {
  130 + IA_STRING, IA_PASTE, IA_REDRAW,
  131 + IA_KEYPAD, IA_DEFAULT, IA_KEY,
  132 + IA_MACRO, IA_SCRIPT, IA_PEEK,
  133 + IA_TYPEAHEAD, IA_FT, IA_COMMAND, IA_KEYMAP,
  134 + IA_IDLE
  135 +};
  136 +
  137 +// Version strings
  138 +LIB3270_INTERNAL const char * build;
  139 +LIB3270_INTERNAL const char * app_defaults_version;
  140 +LIB3270_INTERNAL const char * sccsid;
  141 +LIB3270_INTERNAL const char * build_rpq_timestamp;
  142 +LIB3270_INTERNAL const char * build_rpq_version;
  143 +LIB3270_INTERNAL const char * build_rpq_revision;
  144 +
  145 +#if defined(X3270_DBCS) /*[*/
  146 + LIB3270_INTERNAL Boolean dbcs;
  147 +#endif /*]*/
  148 +
  149 +
  150 +/**
  151 + * @brief toggle names
  152 + */ /*
  153 +struct toggle_name {
  154 + const char *name;
  155 + int index;
  156 +}; */
  157 +
  158 +/// @brief State macros
  159 +#define PCONNECTED lib3270_pconnected(hSession)
  160 +#define HALF_CONNECTED lib3270_half_connected(hSession)
  161 +#define CONNECTED lib3270_is_connected(hSession)
  162 +
  163 +#define IN_NEITHER lib3270_in_neither(hSession)
  164 +#define IN_ANSI lib3270_in_ansi(hSession)
  165 +#define IN_3270 lib3270_in_3270(hSession)
  166 +#define IN_SSCP lib3270_in_sscp(hSession)
  167 +#define IN_TN3270E lib3270_in_tn3270e(hSession)
  168 +#define IN_E lib3270_in_e(hSession)
  169 +
  170 +/// @brief Naming convention for private actions.
  171 +#define PA_PFX "PA-"
  172 +
  173 +#define GR_BLINK 0x01
  174 +#define GR_REVERSE 0x02
  175 +#define GR_UNDERLINE 0x04
  176 +#define GR_INTENSIFY 0x08
  177 +
  178 +#define CS_MASK 0x03 ///< @brief mask for specific character sets */
  179 +#define CS_BASE 0x00 ///< @brief base character set (X'00') */
  180 +#define CS_APL 0x01 ///< @brief APL character set (X'01' or GE) */
  181 +#define CS_LINEDRAW 0x02 ///< @brief DEC line-drawing character set (ANSI) */
  182 +#define CS_DBCS 0x03 ///< @brief DBCS character set (X'F8') */
  183 +#define CS_GE 0x04 ///< @brief cs flag for Graphic Escape */
  184 +
  185 +/// @brief Shorthand macros
  186 +#define CN ((char *) NULL)
  187 +#define PN ((XtPointer) NULL)
  188 +#define Replace(var, value) { lib3270_free(var); var = (value); };
  189 +
  190 +/// @brief Configuration change masks.
  191 +//#define NO_CHANGE 0x0000 /// @brief no change
  192 +// #define MODEL_CHANGE 0x0001 /// @brief screen dimensions changed
  193 +//#define FONT_CHANGE 0x0002 /// @brief emulator font changed
  194 +//#define COLOR_CHANGE 0x0004 /// @brief color scheme or 3278/9 mode changed
  195 +//#define SCROLL_CHANGE 0x0008 /// @brief scrollbar snapped on or off
  196 +//#define CHARSET_CHANGE 0x0010 /// @brief character set changed
  197 +// #define ALL_CHANGE 0xffff /// @brief everything changed
  198 +
  199 +/* Portability macros */
  200 +
  201 +/* Equivalent of setlinebuf */
  202 +
  203 +#if defined(_IOLBF) /*[*/
  204 + #define SETLINEBUF(s) setvbuf(s, (char *)NULL, _IOLBF, BUFSIZ)
  205 +#else /*][*/
  206 + #define SETLINEBUF(s) setlinebuf(s)
  207 +#endif /*]*/
  208 +
  209 +/* Motorola version of gettimeofday */
  210 +
  211 +#if defined(MOTOROLA)
  212 + #define gettimeofday(tp,tz) gettimeofday(tp)
  213 +#endif
  214 +
  215 +/* Default DFT file transfer buffer size. */
  216 +#if defined(X3270_FT) && !defined(DFT_BUF) /*[*/
  217 + #define DFT_BUF (4 * 1024)
  218 +#endif /*]*/
  219 +
  220 +/* DBCS Preedit Types */ /*
  221 +#if defined(X3270_DBCS)
  222 + #define PT_ROOT "Root"
  223 + #define PT_OVER_THE_SPOT "OverTheSpot"
  224 + #define PT_OFF_THE_SPOT "OffTheSpot"
  225 + #define PT_ON_THE_SPOT "OnTheSpot"
  226 +#endif */
  227 +
  228 +/**
  229 + * @brief input key type
  230 + */
  231 +enum keytype
  232 +{
  233 + KT_STD,
  234 + KT_GE
  235 +};
  236 +
  237 +LIB3270_INTERNAL struct _ansictl
  238 +{
  239 + char vintr;
  240 + char vquit;
  241 + char verase;
  242 + char vkill;
  243 + char veof;
  244 + char vwerase;
  245 + char vrprnt;
  246 + char vlnext;
  247 +} ansictl;
  248 +
  249 +/**
  250 + * @brief Extended attributes
  251 + */
  252 +struct lib3270_ea
  253 +{
  254 + unsigned char cc; ///< @brief EBCDIC or ASCII character code
  255 + unsigned char fa; ///< @brief field attribute, it nonzero
  256 + unsigned char fg; ///< @brief foreground color (0x00 or 0xf<n>)
  257 + unsigned char bg; ///< @brief background color (0x00 or 0xf<n>)
  258 + unsigned char gr; ///< @brief ANSI graphics rendition bits
  259 + unsigned char cs; ///< @brief character set (GE flag, or 0..2)
  260 + unsigned char ic; ///< @brief input control (DBCS)
  261 + unsigned char db; ///< @brief DBCS state
  262 +};
  263 +
  264 +struct lib3270_text
  265 +{
  266 + unsigned char chr; ///< @brief ASCII character code
  267 + unsigned short attr; ///< @brief Converted character attribute (color & etc)
  268 +};
  269 +
  270 +#ifndef LIB3270_TA
  271 + #define LIB3270_TA void
  272 +#endif // !LIB3270_TA
  273 +
  274 +#define LIB3270_MB_MAX 16
  275 +
  276 +#define LIB3270_FULL_MODEL_NAME_LENGTH 13
  277 +#define LIB3270_LU_MAX 32
  278 +
  279 +#define LIB3270_TELNET_N_OPTS 256
  280 +
  281 +/**
  282 + *
  283 + * @brief Timeout control structure.
  284 + *
  285 + */
  286 +typedef struct timeout
  287 +{
  288 + LIB3270_LINKED_LIST_HEAD
  289 +
  290 + unsigned char in_play;
  291 +
  292 +#if defined(_WIN32) /*[*/
  293 + unsigned long long ts;
  294 +#else /*][*/
  295 + struct timeval tv;
  296 +#endif /*]*/
  297 +
  298 + int (*proc)(H3270 *session);
  299 +
  300 +} timeout_t;
  301 +
  302 +
  303 +/**
  304 + *
  305 + * @brief I/O events.
  306 + *
  307 + */
  308 +typedef struct _input_t
  309 +{
  310 + LIB3270_LINKED_LIST_HEAD
  311 +
  312 + unsigned char enabled;
  313 + int fd;
  314 + LIB3270_IO_FLAG flag;
  315 +
  316 + void (*call)(H3270 *, int, LIB3270_IO_FLAG, void *);
  317 +
  318 +} input_t;
  319 +
  320 +struct lib3270_state_callback
  321 +{
  322 + LIB3270_LINKED_LIST_HEAD
  323 +
  324 + void (*func)(H3270 *, int, void *); /**< @brief Function to call */
  325 +};
  326 +
  327 +struct lib3270_toggle_callback
  328 +{
  329 + LIB3270_LINKED_LIST_HEAD
  330 +
  331 + void (*func)(H3270 *, LIB3270_TOGGLE_ID, char, void *); /**< @brief Function to call */
  332 +};
  333 +
  334 +/**
  335 + *
  336 + * @brief lib3270 session data
  337 + *
  338 + */
  339 +struct _h3270
  340 +{
  341 + struct lib3270_session_callbacks cbk; ///< @brief Callback table - Always the first one.
  342 +
  343 + // Session info
  344 + char id; ///< @brief Session Identifier.
  345 +
  346 + // Connection info
  347 + struct {
  348 + int sock; ///< @brief Network socket.
  349 + LIB3270_CSTATE state; ///< @brief Connection state.
  350 + } connection;
  351 +
  352 + // flags
  353 + LIB3270_HOST_TYPE host_type; ///< @brief Host type.
  354 +
  355 + int selected : 1; ///< @brief Has selected region?
  356 + int rectsel : 1; ///< @brief Selected region is a rectangle ?
  357 + int vcontrol : 1; ///< @brief Visible control ?
  358 + int modified_sel : 1;
  359 + int mono : 1; ///< @brief Forces monochrome display
  360 + int m3279 : 1;
  361 + int extended : 1; ///< @brief Extended data stream.
  362 + int typeahead : 1;
  363 + int numeric_lock : 1;
  364 + int oerr_lock : 1; ///< @brief If true, operator errors will lock the keyboard.
  365 + int unlock_delay : 1; ///< @brief If true the unlock delay feature is enabled. @see lib3270_set_unlock_delay
  366 + int auto_reconnect_inprogress : 1;
  367 + unsigned int colors : 5;
  368 + int apl_mode : 1; ///< @brief If true enables APL mode.
  369 + int icrnl : 1;
  370 + int inlcr : 1;
  371 + int onlcr : 1;
  372 + int bsd_tm : 1;
  373 + int syncing : 1;
  374 + int reverse : 1; /**< @brief reverse-input mode */
  375 + int dbcs : 1;
  376 + int linemode : 1;
  377 + int trace_skipping : 1;
  378 + int need_tls_follows : 1;
  379 + int cut_xfer_in_progress : 1;
  380 +// int auto_keymap : 1;
  381 + int formatted : 1; /**< @brief Formatted screen flag */
  382 + int starting : 1; /**< @brief Is starting (no first screen)? */
  383 +
  384 + struct lib3270_toggle
  385 + {
  386 + char value; /**< toggle value */
  387 + void (*upcall)(H3270 *, struct lib3270_toggle *, LIB3270_TOGGLE_TYPE); /**< change value */
  388 + } toggle[LIB3270_TOGGLE_COUNT];
  389 +
  390 + // Network & Termtype
  391 + char * connected_type;
  392 + char full_model_name[LIB3270_FULL_MODEL_NAME_LENGTH+1];
  393 + char * model_name;
  394 + unsigned int model_num;
  395 + char * termtype;
  396 +
  397 + struct
  398 + {
  399 + char * url; /**< The host URL, for use in reconnecting */
  400 + char * current; /**< The hostname part, stripped of qualifiers, luname and port number */
  401 + char * srvc; /**< The service name */
  402 + char * qualified;
  403 + } host;
  404 +
  405 + char * termname;
  406 +
  407 + struct lib3270_charset charset;
  408 +
  409 + struct
  410 + {
  411 + LIB3270_MESSAGE status;
  412 + unsigned char flag[LIB3270_FLAG_COUNT];
  413 + } oia;
  414 +
  415 + unsigned short current_port;
  416 +
  417 + // Misc
  418 + H3270FT * ft; /**< @brief Active file transfer data */
  419 +
  420 + // screen info
  421 +
  422 + // Oversize.
  423 + struct
  424 + {
  425 + char * str;
  426 + unsigned int rows;
  427 + unsigned int cols;
  428 + } oversize;
  429 +
  430 + // Maximum screen size.
  431 + struct
  432 + {
  433 + unsigned int rows;
  434 + unsigned int cols;
  435 + } max;
  436 +
  437 + // View size
  438 + struct {
  439 + unsigned int rows;
  440 + unsigned int cols;
  441 + } view;
  442 +
  443 + LIB3270_POINTER pointer; /**< @brief Current pointer. */
  444 + int cursor_addr;
  445 + int buffer_addr;
  446 + char flipped;
  447 + int screen_alt; /**< @brief alternate screen? */
  448 + int is_altbuffer;
  449 +
  450 + // Screen contents
  451 + void * buffer[2]; /**< @brief Internal buffers */
  452 + struct lib3270_ea * ea_buf; /**< @brief 3270 device buffer. ea_buf[-1] is the dummy default field attribute */
  453 + struct lib3270_ea * aea_buf; /**< @brief alternate 3270 extended attribute buffer */
  454 + struct lib3270_text * text; /**< @brief Converted 3270 chars */
  455 +
  456 + // host.c
  457 + char std_ds_host;
  458 + char no_login_host;
  459 + char non_tn3270e_host;
  460 + char passthru_host;
  461 + char ever_3270;
  462 +
  463 + // ctlr.c
  464 + int sscp_start;
  465 + unsigned char default_fg;
  466 + unsigned char default_bg;
  467 + unsigned char default_gr;
  468 + unsigned char default_cs;
  469 + unsigned char default_ic;
  470 + char reply_mode;
  471 + int trace_primed : 1;
  472 + int ticking : 1;
  473 + int mticking : 1;
  474 + int crm_nattr;
  475 + unsigned char crm_attr[16];
  476 + unsigned char * zero_buf; /**< @brief Empty buffer, for area clears */
  477 +
  478 + struct timeval t_start;
  479 + void * tick_id;
  480 + struct timeval t_want;
  481 +
  482 + // Telnet.c
  483 + unsigned char * ibuf;
  484 + int ibuf_size; /**< @brief size of ibuf */
  485 + time_t ns_time;
  486 + int ns_brcvd;
  487 + int ns_rrcvd;
  488 + int ns_bsent;
  489 + int ns_rsent;
  490 + struct timeval ds_ts;
  491 + unsigned short e_xmit_seq; /**< @brief transmit sequence number */
  492 + int response_required;
  493 + int ansi_data;
  494 + int lnext;
  495 + int backslashed;
  496 + char plu_name[LIB3270_BIND_PLU_NAME_MAX+1];
  497 +
  498 + /*
  499 + /// @brief Proxy
  500 + struct
  501 + {
  502 + char * proxy; ///< Proxy server (type:host[:port])
  503 + int type;
  504 + char * host;
  505 + char * portname;
  506 + unsigned short port;
  507 + } proxy;
  508 + */
  509 +
  510 + /// @brief LU
  511 + char **curr_lu;
  512 + char * try_lu;
  513 + char **lus; ///< @brief Array with the LU names to try.
  514 + struct
  515 + {
  516 + char reported[LIB3270_LU_MAX+1];
  517 + char * connected;
  518 + char name[LIB3270_LUNAME_LENGTH+1];
  519 +
  520 + } lu;
  521 +
  522 + char reported_type[LIB3270_LU_MAX+1];
  523 +
  524 + // TN3270e
  525 + enum
  526 + {
  527 + E_NONE,
  528 + E_3270,
  529 + E_NVT,
  530 + E_SSCP
  531 + } tn3270e_submode;
  532 +
  533 + unsigned long e_funcs; /**< @brief negotiated TN3270E functions */
  534 + int tn3270e_bound;
  535 + int tn3270e_negotiated;
  536 +
  537 + // Line mode
  538 + unsigned char * lbuf; /**< @brief line-mode input buffer */
  539 + unsigned char * lbptr;
  540 +
  541 + // 3270 input buffer
  542 + unsigned char * ibptr;
  543 +
  544 + // Output buffer.
  545 + struct
  546 + {
  547 + unsigned char * buf; ///< @brief 3270 output buffer */
  548 + unsigned char * base;
  549 + int length; ///< @brief Length of the output buffer.
  550 + unsigned char * ptr;
  551 + } output;
  552 +
  553 + // network input buffer
  554 + unsigned char * sbbuf;
  555 +
  556 + // telnet sub-option buffer
  557 + unsigned char * sbptr;
  558 + unsigned char telnet_state;
  559 +
  560 + unsigned char myopts[LIB3270_TELNET_N_OPTS];
  561 + unsigned char hisopts[LIB3270_TELNET_N_OPTS];
  562 +
  563 + // kybd.c
  564 + unsigned int kybdlock; ///< @brief @brief keyboard lock state.
  565 + unsigned char aid; ///< @brief @brief current attention ID.
  566 + void * unlock_id;
  567 + time_t unlock_delay_time;
  568 + unsigned long unlock_delay_ms; ///< @brief Delay before actually unlocking the keyboard after the host permits it.
  569 + LIB3270_TA * ta_head;
  570 + LIB3270_TA * ta_tail;
  571 +
  572 + // ft_dft.c
  573 + int dft_buffersize; ///< @brief Buffer size (LIMIN, LIMOUT)
  574 +
  575 + // rpq.c
  576 + int rpq_complained : 1;
  577 +#if !defined(_WIN32)
  578 + int omit_due_space_limit : 1;
  579 +#endif
  580 +
  581 + char * rpq_warnbuf;
  582 + int rpq_wbcnt;
  583 +
  584 + // User data (Usually points to session's widget)
  585 + void * user_data;
  586 +
  587 + // selection
  588 + char * paste_buffer;
  589 + struct
  590 + {
  591 + int start;
  592 + int end;
  593 + } select;
  594 +
  595 + // ansi.c
  596 + int scroll_top;
  597 + int scroll_bottom;
  598 + int once_cset;
  599 + int saved_cursor;
  600 +
  601 + int held_wrap : 1;
  602 +
  603 + int insert_mode : 1;
  604 + int auto_newline_mode : 1;
  605 +
  606 + int appl_cursor : 1;
  607 + int saved_appl_cursor : 1;
  608 +
  609 + int wraparound_mode : 1;
  610 + int saved_wraparound_mode : 1;
  611 +
  612 + int rev_wraparound_mode : 1;
  613 + int saved_rev_wraparound_mode : 1;
  614 +
  615 + int allow_wide_mode : 1;
  616 + int saved_allow_wide_mode : 1;
  617 +
  618 + int wide_mode : 1;
  619 + int saved_wide_mode : 1;
  620 +
  621 + int saved_altbuffer : 1;
  622 + int ansi_reset : 1; /**< @brief Non zero if the ansi_reset() was called in this session */
  623 +
  624 + int ansi_ch;
  625 + int cs_to_change;
  626 +
  627 + /** @brief ANSI Character sets. */
  628 + enum lib3270_ansi_cs
  629 + {
  630 + LIB3270_ANSI_CS_G0 = 0,
  631 + LIB3270_ANSI_CS_G1 = 1,
  632 + LIB3270_ANSI_CS_G2 = 2,
  633 + LIB3270_ANSI_CS_G3 = 3
  634 + } cset;
  635 + enum lib3270_ansi_cs saved_cset;
  636 +
  637 + /** @brief Character set designations. */
  638 + enum lib3270_ansi_csd
  639 + {
  640 + LIB3270_ANSI_CSD_LD = 0,
  641 + LIB3270_ANSI_CSD_UK = 1,
  642 + LIB3270_ANSI_CSD_US = 2
  643 + } csd[4];
  644 + enum lib3270_ansi_csd saved_csd[4];
  645 +
  646 + enum lib3270_ansi_state
  647 + {
  648 + LIB3270_ANSI_STATE_DATA = 0,
  649 + LIB3270_ANSI_STATE_ESC = 1,
  650 + LIB3270_ANSI_STATE_CSDES = 2,
  651 + LIB3270_ANSI_STATE_N1 = 3,
  652 + LIB3270_ANSI_STATE_DECP = 4,
  653 + LIB3270_ANSI_STATE_TEXT = 5,
  654 + LIB3270_ANSI_STATE_TEXT2 = 6,
  655 + LIB3270_ANSI_STATE_MBPEND = 7
  656 + } state;
  657 +
  658 + unsigned char * tabs;
  659 +
  660 + int pmi;
  661 + char pending_mbs[LIB3270_MB_MAX];
  662 +
  663 + unsigned char gr;
  664 + unsigned char saved_gr;
  665 +
  666 + unsigned char fg;
  667 + unsigned char saved_fg;
  668 +
  669 + unsigned char bg;
  670 + unsigned char saved_bg;
  671 +
  672 + // xio
  673 + struct {
  674 + void * read;
  675 + void * write;
  676 + void * except;
  677 + } xio;
  678 +
  679 + size_t popups; ///< @brief Count open popups.
  680 +
  681 +#ifdef HAVE_LIBSSL
  682 + /// @brief SSL Data.
  683 + struct
  684 + {
  685 + char enabled;
  686 + char host;
  687 + LIB3270_SSL_STATE state;
  688 + unsigned long error;
  689 +#ifdef SSL_ENABLE_CRL_CHECK
  690 + struct
  691 + {
  692 + char * prefer; ///< @brief Prefered protocol for CRL.
  693 + char * url; ///< @brief URL for CRL download.
  694 + X509_CRL * cert; ///< @brief Loaded CRL (can be null).
  695 + } crl;
  696 +#endif // SSL_ENABLE_CRL_CHECK
  697 + SSL * con;
  698 + } ssl;
  699 +#endif // HAVE_LIBSSL
  700 +
  701 + struct lib3270_linked_list_head timeouts;
  702 +
  703 + struct
  704 + {
  705 + struct lib3270_linked_list_head list;
  706 + int changed : 1;
  707 + } input;
  708 +
  709 + // Trace methods.
  710 + struct
  711 + {
  712 + void (*handler)(H3270 *session, void *userdata, const char *fmt, va_list args);
  713 + void *userdata;
  714 + } trace;
  715 +
  716 + /// @brief Event Listeners.
  717 + struct
  718 + {
  719 + /// @brief State listeners.
  720 + struct lib3270_linked_list_head state[LIB3270_STATE_USER];
  721 +
  722 + /// @brief Toggle listeners.
  723 + struct lib3270_linked_list_head toggle[LIB3270_TOGGLE_COUNT];
  724 +
  725 + /// @brief Action listeners.
  726 + struct lib3270_linked_list_head actions[LIB3270_ACTION_GROUP_CUSTOM];
  727 +
  728 + } listeners;
  729 +
  730 +
  731 +};
  732 +
  733 +#define SELECTION_LEFT 0x01
  734 +#define SELECTION_TOP 0x02
  735 +#define SELECTION_RIGHT 0x04
  736 +#define SELECTION_BOTTOM 0x08
  737 +
  738 +#define SELECTION_SINGLE_COL 0x10
  739 +#define SELECTION_SINGLE_ROW 0x20
  740 +
  741 +#define SELECTION_ACTIVE 0x80
  742 +
  743 +#ifdef _WIN32
  744 +/// @brief Windows Event Log Handler.
  745 +LIB3270_INTERNAL HANDLE hEventLog;
  746 +LIB3270_INTERNAL HANDLE hModule;
  747 +#endif // _WIN32
  748 +
  749 +#ifdef HAVE_SYSLOG
  750 +/// @brief Windows Event Log Handler.
  751 +LIB3270_INTERNAL int use_syslog;
  752 +#endif // HAVE_SYSLOG
  753 +
  754 +
  755 +/* Library internal calls */
  756 +LIB3270_INTERNAL int key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped);
  757 +LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr);
  758 +
  759 +LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt);
  760 +LIB3270_INTERNAL void remove_input_calls(H3270 *session);
  761 +
  762 +LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf, int len);
  763 +LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession);
  764 +
  765 +LIB3270_INTERNAL int lib3270_default_event_dispatcher(H3270 *hSession, int block);
  766 +
  767 +LIB3270_INTERNAL void do_select(H3270 *h, unsigned int start, unsigned int end, unsigned int rect);
  768 +
  769 +
  770 +/**
  771 + * @brief Called from timer to attempt an automatic reconnection.
  772 + */
  773 +LIB3270_INTERNAL int lib3270_check_for_auto_reconnect(H3270 *hSession);
  774 +
  775 +#if defined(DEBUG)
  776 + #define CHECK_SESSION_HANDLE(x) check_session_handle(&x,__FUNCTION__);
  777 + LIB3270_INTERNAL void check_session_handle(H3270 **hSession, const char *fname);
  778 +#else
  779 + #define CHECK_SESSION_HANDLE(x) check_session_handle(&x);
  780 + LIB3270_INTERNAL void check_session_handle(H3270 **hSession);
  781 +#endif // DEBUG
  782 +
  783 +LIB3270_INTERNAL int check_online_session(const H3270 *hSession);
  784 +LIB3270_INTERNAL int check_offline_session(const H3270 *hSession);
  785 +
  786 +/// @brief Returns -1 if the session is invalid or not online (sets errno).
  787 +#define FAIL_IF_NOT_ONLINE(x) if(check_online_session(x)) return errno;
  788 +
  789 +/// @brief Returns -1 if the session is invalid or online (sets errno).
  790 +#define FAIL_IF_ONLINE(x) if(check_offline_session(x)) return errno;
  791 +
  792 +LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on);
  793 +
  794 +#if defined(HAVE_LIBSSL)
  795 +
  796 + typedef struct _ssl_error_message
  797 + {
  798 + int error;
  799 + const char * title;
  800 + const char * text;
  801 + const char * description;
  802 +#ifdef _WIN32
  803 + DWORD lasterror;
  804 +#endif // _WIN32
  805 + } SSL_ERROR_MESSAGE;
  806 +
  807 + struct ssl_status_msg
  808 + {
  809 + long id;
  810 + LIB3270_NOTIFY icon;
  811 + const char * iconName; // Icon name from https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
  812 + const char * message;
  813 + const char * description;
  814 + };
  815 +
  816 + LIB3270_INTERNAL int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE *message);
  817 + LIB3270_INTERNAL int ssl_init(H3270 *session);
  818 + LIB3270_INTERNAL int ssl_negotiate(H3270 *hSession);
  819 + LIB3270_INTERNAL void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state);
  820 + LIB3270_INTERNAL const struct ssl_status_msg * ssl_get_status_from_error_code(long id);
  821 +
  822 +
  823 + #if OPENSSL_VERSION_NUMBER >= 0x00907000L
  824 + #define INFO_CONST const
  825 + #else
  826 + #define INFO_CONST
  827 + #endif
  828 +
  829 + LIB3270_INTERNAL void ssl_info_callback(INFO_CONST SSL *s, int where, int ret);
  830 +
  831 + /**
  832 + * @brief Global SSL_CTX object as framework to establish TLS/SSL or DTLS enabled connections.
  833 + *
  834 + */
  835 + LIB3270_INTERNAL SSL_CTX * ssl_ctx;
  836 +
  837 + /**
  838 + * @brief Index of h3270 handle in SSL session.
  839 + *
  840 + */
  841 + LIB3270_INTERNAL int ssl_3270_ex_index;
  842 +
  843 + /**
  844 + * @brief Emit popup on ssl error.
  845 + *
  846 + */
  847 + LIB3270_INTERNAL int popup_ssl_error(H3270 *session, int rc, const char *title, const char *summary, const char *body);
  848 +
  849 + /**
  850 + * @brief Emite popup on SSL error.
  851 + *
  852 + */
  853 + LIB3270_INTERNAL int notify_ssl_error(H3270 *hSession, int rc, const SSL_ERROR_MESSAGE *message);
  854 +
  855 +#endif
  856 +
  857 + /// @brief Clear element at adress.
  858 + LIB3270_INTERNAL void clear_chr(H3270 *hSession, int baddr);
  859 +
  860 + LIB3270_INTERNAL unsigned char get_field_attribute(H3270 *session, int baddr);
  861 +
  862 + /// @brief Default log writer.
  863 + LIB3270_INTERNAL void default_log_writer(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr);
  864 +
  865 + LIB3270_INTERNAL char * lib3270_get_user_name();
  866 +
  867 + /// @brief Query data from URL.
  868 + ///
  869 + /// @param hSession Handle of the TN3270 Session.
  870 + /// @param url The url to get.
  871 + /// @param length Pointer to the response lenght (can be NULL).
  872 + /// @param error_message Pointer to the error message.
  873 + ///
  874 + /// @return The data from URL (release it with lib3270_free) or NULL on error.
  875 + ///
  876 + LIB3270_INTERNAL char * lib3270_get_from_url(H3270 *hSession, const char *url, size_t *length, const char **error_message);
  877 +
  878 + /// @brief Fire CState change.
  879 + LIB3270_INTERNAL int lib3270_set_cstate(H3270 *hSession, LIB3270_CSTATE cstate);
  880 +
  881 + /// @brief Notify actions.
  882 + LIB3270_INTERNAL void lib3270_notify_actions(H3270 *hSession, LIB3270_ACTION_GROUP group);
... ...
src/include/lib3270-internals.h
... ... @@ -1,888 +0,0 @@
1   -/*
2   - * "Software G3270, 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 ', 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 private.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   - *
28   - */
29   -
30   -#ifdef WIN32
31   - #include <winsock2.h>
32   - #include <windows.h>
33   -#endif // WIN32
34   -
35   -#include <config.h> /* autoconf settings */
36   -#include <lib3270.h> /* lib3270 API calls and defs */
37   -#include <linkedlist.h>
38   -#include <lib3270/charset.h>
39   -#include <lib3270/session.h>
40   -// #include "api.h"
41   -
42   -#if defined(HAVE_LIBSSL)
43   - #include <openssl/ssl.h>
44   - #include <openssl/x509v3.h>
45   -
46   -#endif // HAVE_LIBSSL
47   -
48   -#if defined(X3270_TN3270E) && !defined(X3270_ANSI) /*[*/
49   - #define X3270_ANSI 1 /* RFC2355 requires NVT mode */
50   -#endif /*]*/
51   -
52   -#if defined(HAVE_VASPRINTF) && !defined(_GNU_SOURCE) /*[*/
53   - #define _GNU_SOURCE /* vasprintf isn't POSIX */
54   -#endif /*]*/
55   -
56   -/*
57   - * gettext stuff
58   - */
59   -#ifdef ANDROID
60   - #undef HAVE_LIBINTL
61   - #undef HAVE_LIBSSL
62   -#endif
63   -
64   -#ifdef HAVE_LIBINTL
65   - #include <libintl.h>
66   - #define _( x ) gettext(x)
67   - #define N_( x ) x
68   -#else
69   - #define _( x ) x
70   - #define N_( x ) x
71   -#endif // HAVE_LIBINTL
72   -
73   -#define action_name(x) #x
74   -
75   -/*
76   - * OS-specific #defines. Except for the blocking-connect workarounds, these
77   - * should be replaced with autoconf probes as soon as possible.
78   - */
79   -
80   -/*
81   - * BLOCKING_CONNECT_ONLY
82   - * Use only blocking sockets.
83   - */
84   -#if defined(sco) /*[*/
85   - #define BLOCKING_CONNECT_ONLY 1
86   -#endif /*]*/
87   -
88   -#if defined(apollo) /*[*/
89   - #define BLOCKING_CONNECT_ONLY 1
90   -#endif /*]*/
91   -
92   -//
93   -// Compiler-specific #defines.
94   -//
95   -// Reference: GLIBC gmacros.h
96   -//
97   -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
98   -
99   - #define GNUC_UNUSED \
100   - __attribute__((__unused__))
101   -
102   -#else
103   -
104   - #define unused
105   - #define GNUC_UNUSED
106   - #define printflike(s, f)
107   -
108   -#endif
109   -
110   -#if defined(_WIN32) || defined(_MSC_VER)
111   -
112   - #include <winsock2.h>
113   - #include <windows.h>
114   -
115   -#else
116   -
117   - #include <unistd.h> /* Unix system calls */
118   - #include <sys/time.h> /* System time-related data types */
119   -
120   -#endif // _WIN32
121   -
122   -/*
123   - * Prerequisite #includes.
124   - */
125   -#include <stdio.h> /* Unix standard I/O library */
126   -#include <ctype.h> /* Character classes */
127   -#include <string.h> /* String manipulations */
128   -#include <sys/types.h> /* Basic system data types */
129   -#include <time.h> /* C library time functions */
130   -#include "localdefs.h" /* {s,tcl,c}3270-specific defines */
131   -
132   -/*
133   - * Cancel out contradictory parts.
134   - */
135   -#if !defined(X3270_DISPLAY) /*[*/
136   - #undef X3270_KEYPAD
137   - #undef X3270_MENUS
138   -#endif /*]*/
139   -
140   -#define RECONNECT_MS 2000 /**< @brief 2 sec before reconnecting to host. */
141   -#define RECONNECT_ERR_MS 5000 /**< @brief 5 sec before reconnecting to host when failed */
142   -
143   -/**
144   - * @brief types of internal actions
145   - */
146   -enum iaction {
147   - IA_STRING, IA_PASTE, IA_REDRAW,
148   - IA_KEYPAD, IA_DEFAULT, IA_KEY,
149   - IA_MACRO, IA_SCRIPT, IA_PEEK,
150   - IA_TYPEAHEAD, IA_FT, IA_COMMAND, IA_KEYMAP,
151   - IA_IDLE
152   -};
153   -
154   -// Version strings
155   -LIB3270_INTERNAL const char * build;
156   -LIB3270_INTERNAL const char * app_defaults_version;
157   -LIB3270_INTERNAL const char * sccsid;
158   -LIB3270_INTERNAL const char * build_rpq_timestamp;
159   -LIB3270_INTERNAL const char * build_rpq_version;
160   -LIB3270_INTERNAL const char * build_rpq_revision;
161   -
162   -#if defined(X3270_DBCS) /*[*/
163   - LIB3270_INTERNAL Boolean dbcs;
164   -#endif /*]*/
165   -
166   -
167   -/**
168   - * @brief toggle names
169   - */ /*
170   -struct toggle_name {
171   - const char *name;
172   - int index;
173   -}; */
174   -
175   -/// @brief State macros
176   -#define PCONNECTED lib3270_pconnected(hSession)
177   -#define HALF_CONNECTED lib3270_half_connected(hSession)
178   -#define CONNECTED lib3270_is_connected(hSession)
179   -
180   -#define IN_NEITHER lib3270_in_neither(hSession)
181   -#define IN_ANSI lib3270_in_ansi(hSession)
182   -#define IN_3270 lib3270_in_3270(hSession)
183   -#define IN_SSCP lib3270_in_sscp(hSession)
184   -#define IN_TN3270E lib3270_in_tn3270e(hSession)
185   -#define IN_E lib3270_in_e(hSession)
186   -
187   -/// @brief Naming convention for private actions.
188   -#define PA_PFX "PA-"
189   -
190   -#define GR_BLINK 0x01
191   -#define GR_REVERSE 0x02
192   -#define GR_UNDERLINE 0x04
193   -#define GR_INTENSIFY 0x08
194   -
195   -#define CS_MASK 0x03 ///< @brief mask for specific character sets */
196   -#define CS_BASE 0x00 ///< @brief base character set (X'00') */
197   -#define CS_APL 0x01 ///< @brief APL character set (X'01' or GE) */
198   -#define CS_LINEDRAW 0x02 ///< @brief DEC line-drawing character set (ANSI) */
199   -#define CS_DBCS 0x03 ///< @brief DBCS character set (X'F8') */
200   -#define CS_GE 0x04 ///< @brief cs flag for Graphic Escape */
201   -
202   -/// @brief Shorthand macros
203   -#define CN ((char *) NULL)
204   -#define PN ((XtPointer) NULL)
205   -#define Replace(var, value) { lib3270_free(var); var = (value); };
206   -
207   -/// @brief Configuration change masks.
208   -//#define NO_CHANGE 0x0000 /// @brief no change
209   -// #define MODEL_CHANGE 0x0001 /// @brief screen dimensions changed
210   -//#define FONT_CHANGE 0x0002 /// @brief emulator font changed
211   -//#define COLOR_CHANGE 0x0004 /// @brief color scheme or 3278/9 mode changed
212   -//#define SCROLL_CHANGE 0x0008 /// @brief scrollbar snapped on or off
213   -//#define CHARSET_CHANGE 0x0010 /// @brief character set changed
214   -// #define ALL_CHANGE 0xffff /// @brief everything changed
215   -
216   -/* Portability macros */
217   -
218   -/* Equivalent of setlinebuf */
219   -
220   -#if defined(_IOLBF) /*[*/
221   - #define SETLINEBUF(s) setvbuf(s, (char *)NULL, _IOLBF, BUFSIZ)
222   -#else /*][*/
223   - #define SETLINEBUF(s) setlinebuf(s)
224   -#endif /*]*/
225   -
226   -/* Motorola version of gettimeofday */
227   -
228   -#if defined(MOTOROLA)
229   - #define gettimeofday(tp,tz) gettimeofday(tp)
230   -#endif
231   -
232   -/* Default DFT file transfer buffer size. */
233   -#if defined(X3270_FT) && !defined(DFT_BUF) /*[*/
234   - #define DFT_BUF (4 * 1024)
235   -#endif /*]*/
236   -
237   -/* DBCS Preedit Types */ /*
238   -#if defined(X3270_DBCS)
239   - #define PT_ROOT "Root"
240   - #define PT_OVER_THE_SPOT "OverTheSpot"
241   - #define PT_OFF_THE_SPOT "OffTheSpot"
242   - #define PT_ON_THE_SPOT "OnTheSpot"
243   -#endif */
244   -
245   -/**
246   - * @brief input key type
247   - */
248   -enum keytype
249   -{
250   - KT_STD,
251   - KT_GE
252   -};
253   -
254   -LIB3270_INTERNAL struct _ansictl
255   -{
256   - char vintr;
257   - char vquit;
258   - char verase;
259   - char vkill;
260   - char veof;
261   - char vwerase;
262   - char vrprnt;
263   - char vlnext;
264   -} ansictl;
265   -
266   -/**
267   - * @brief Extended attributes
268   - */
269   -struct lib3270_ea
270   -{
271   - unsigned char cc; ///< @brief EBCDIC or ASCII character code
272   - unsigned char fa; ///< @brief field attribute, it nonzero
273   - unsigned char fg; ///< @brief foreground color (0x00 or 0xf<n>)
274   - unsigned char bg; ///< @brief background color (0x00 or 0xf<n>)
275   - unsigned char gr; ///< @brief ANSI graphics rendition bits
276   - unsigned char cs; ///< @brief character set (GE flag, or 0..2)
277   - unsigned char ic; ///< @brief input control (DBCS)
278   - unsigned char db; ///< @brief DBCS state
279   -};
280   -
281   -struct lib3270_text
282   -{
283   - unsigned char chr; ///< @brief ASCII character code
284   - unsigned short attr; ///< @brief Converted character attribute (color & etc)
285   -};
286   -
287   -#ifndef LIB3270_TA
288   - #define LIB3270_TA void
289   -#endif // !LIB3270_TA
290   -
291   -#define LIB3270_MB_MAX 16
292   -
293   -#define LIB3270_FULL_MODEL_NAME_LENGTH 13
294   -#define LIB3270_LU_MAX 32
295   -
296   -#define LIB3270_TELNET_N_OPTS 256
297   -
298   -/**
299   - *
300   - * @brief Timeout control structure.
301   - *
302   - */
303   -typedef struct timeout
304   -{
305   - LIB3270_LINKED_LIST_HEAD
306   -
307   - unsigned char in_play;
308   -
309   -#if defined(_WIN32) /*[*/
310   - unsigned long long ts;
311   -#else /*][*/
312   - struct timeval tv;
313   -#endif /*]*/
314   -
315   - int (*proc)(H3270 *session);
316   -
317   -} timeout_t;
318   -
319   -
320   -/**
321   - *
322   - * @brief I/O events.
323   - *
324   - */
325   -typedef struct _input_t
326   -{
327   - LIB3270_LINKED_LIST_HEAD
328   -
329   - unsigned char enabled;
330   - int fd;
331   - LIB3270_IO_FLAG flag;
332   -
333   - void (*call)(H3270 *, int, LIB3270_IO_FLAG, void *);
334   -
335   -} input_t;
336   -
337   -struct lib3270_state_callback
338   -{
339   - LIB3270_LINKED_LIST_HEAD
340   -
341   - void (*func)(H3270 *, int, void *); /**< @brief Function to call */
342   -};
343   -
344   -struct lib3270_toggle_callback
345   -{
346   - LIB3270_LINKED_LIST_HEAD
347   -
348   - void (*func)(H3270 *, LIB3270_TOGGLE_ID, char, void *); /**< @brief Function to call */
349   -};
350   -
351   -/**
352   - *
353   - * @brief lib3270 session data
354   - *
355   - */
356   -struct _h3270
357   -{
358   - struct lib3270_session_callbacks cbk; ///< @brief Callback table - Always the first one.
359   -
360   - // Session info
361   - char id; ///< @brief Session Identifier.
362   -
363   - // Connection info
364   - int sock; ///< @brief Network socket.
365   - LIB3270_CSTATE cstate; ///< @brief Connection state.
366   -
367   - // flags
368   - LIB3270_HOST_TYPE host_type; ///< @brief Host type.
369   -
370   - int selected : 1; ///< @brief Has selected region?
371   - int rectsel : 1; ///< @brief Selected region is a rectangle ?
372   - int vcontrol : 1; ///< @brief Visible control ?
373   - int modified_sel : 1;
374   - int mono : 1; ///< @brief Forces monochrome display
375   - int m3279 : 1;
376   - int extended : 1; ///< @brief Extended data stream.
377   - int typeahead : 1;
378   - int numeric_lock : 1;
379   - int oerr_lock : 1; ///< @brief If true, operator errors will lock the keyboard.
380   - int unlock_delay : 1; ///< @brief If true the unlock delay feature is enabled. @see lib3270_set_unlock_delay
381   - int auto_reconnect_inprogress : 1;
382   - unsigned int colors : 5;
383   - int apl_mode : 1; ///< @brief If true enables APL mode.
384   - int icrnl : 1;
385   - int inlcr : 1;
386   - int onlcr : 1;
387   - int bsd_tm : 1;
388   - int syncing : 1;
389   - int reverse : 1; /**< @brief reverse-input mode */
390   - int dbcs : 1;
391   - int linemode : 1;
392   - int trace_skipping : 1;
393   - int need_tls_follows : 1;
394   - int cut_xfer_in_progress : 1;
395   -// int auto_keymap : 1;
396   - int formatted : 1; /**< @brief Formatted screen flag */
397   - int starting : 1; /**< @brief Is starting (no first screen)? */
398   -
399   - struct lib3270_toggle
400   - {
401   - char value; /**< toggle value */
402   - void (*upcall)(H3270 *, struct lib3270_toggle *, LIB3270_TOGGLE_TYPE); /**< change value */
403   - } toggle[LIB3270_TOGGLE_COUNT];
404   -
405   - // Network & Termtype
406   - char * connected_type;
407   - char full_model_name[LIB3270_FULL_MODEL_NAME_LENGTH+1];
408   - char * model_name;
409   - unsigned int model_num;
410   - char * termtype;
411   -
412   - struct
413   - {
414   - char * url; /**< The host URL, for use in reconnecting */
415   - char * current; /**< The hostname part, stripped of qualifiers, luname and port number */
416   - char * srvc; /**< The service name */
417   - char * qualified;
418   - } host;
419   -
420   - char * termname;
421   -
422   - struct lib3270_charset charset;
423   -
424   - struct
425   - {
426   - LIB3270_MESSAGE status;
427   - unsigned char flag[LIB3270_FLAG_COUNT];
428   - } oia;
429   -
430   - unsigned short current_port;
431   -
432   - // Misc
433   - H3270FT * ft; /**< @brief Active file transfer data */
434   -
435   - // screen info
436   -
437   - // Oversize.
438   - struct
439   - {
440   - char * str;
441   - unsigned int rows;
442   - unsigned int cols;
443   - } oversize;
444   -
445   - // Maximum screen size.
446   - struct
447   - {
448   - unsigned int rows;
449   - unsigned int cols;
450   - } max;
451   -
452   - // View size
453   - struct {
454   - unsigned int rows;
455   - unsigned int cols;
456   - } view;
457   -
458   - LIB3270_POINTER pointer; /**< @brief Current pointer. */
459   - int cursor_addr;
460   - int buffer_addr;
461   - char flipped;
462   - int screen_alt; /**< @brief alternate screen? */
463   - int is_altbuffer;
464   -
465   - // Screen contents
466   - void * buffer[2]; /**< @brief Internal buffers */
467   - struct lib3270_ea * ea_buf; /**< @brief 3270 device buffer. ea_buf[-1] is the dummy default field attribute */
468   - struct lib3270_ea * aea_buf; /**< @brief alternate 3270 extended attribute buffer */
469   - struct lib3270_text * text; /**< @brief Converted 3270 chars */
470   -
471   - // host.c
472   - char std_ds_host;
473   - char no_login_host;
474   - char non_tn3270e_host;
475   - char passthru_host;
476   - char ever_3270;
477   -
478   - // ctlr.c
479   - int sscp_start;
480   - unsigned char default_fg;
481   - unsigned char default_bg;
482   - unsigned char default_gr;
483   - unsigned char default_cs;
484   - unsigned char default_ic;
485   - char reply_mode;
486   - int trace_primed : 1;
487   - int ticking : 1;
488   - int mticking : 1;
489   - int crm_nattr;
490   - unsigned char crm_attr[16];
491   - unsigned char * zero_buf; /**< @brief Empty buffer, for area clears */
492   -
493   - struct timeval t_start;
494   - void * tick_id;
495   - struct timeval t_want;
496   -
497   - // Telnet.c
498   - unsigned char * ibuf;
499   - int ibuf_size; /**< @brief size of ibuf */
500   - time_t ns_time;
501   - int ns_brcvd;
502   - int ns_rrcvd;
503   - int ns_bsent;
504   - int ns_rsent;
505   - struct timeval ds_ts;
506   - unsigned short e_xmit_seq; /**< @brief transmit sequence number */
507   - int response_required;
508   - int ansi_data;
509   - int lnext;
510   - int backslashed;
511   - char plu_name[LIB3270_BIND_PLU_NAME_MAX+1];
512   -
513   - /*
514   - /// @brief Proxy
515   - struct
516   - {
517   - char * proxy; ///< Proxy server (type:host[:port])
518   - int type;
519   - char * host;
520   - char * portname;
521   - unsigned short port;
522   - } proxy;
523   - */
524   -
525   - /// @brief LU
526   - char **curr_lu;
527   - char * try_lu;
528   - char **lus; ///< @brief Array with the LU names to try.
529   - struct
530   - {
531   - char reported[LIB3270_LU_MAX+1];
532   - char * connected;
533   - char name[LIB3270_LUNAME_LENGTH+1];
534   -
535   - } lu;
536   -
537   - char reported_type[LIB3270_LU_MAX+1];
538   -
539   - // TN3270e
540   - enum
541   - {
542   - E_NONE,
543   - E_3270,
544   - E_NVT,
545   - E_SSCP
546   - } tn3270e_submode;
547   -
548   - unsigned long e_funcs; /**< @brief negotiated TN3270E functions */
549   - int tn3270e_bound;
550   - int tn3270e_negotiated;
551   -
552   - // Line mode
553   - unsigned char * lbuf; /**< @brief line-mode input buffer */
554   - unsigned char * lbptr;
555   -
556   - // 3270 input buffer
557   - unsigned char * ibptr;
558   -
559   - // Output buffer.
560   - struct
561   - {
562   - unsigned char * buf; ///< @brief 3270 output buffer */
563   - unsigned char * base;
564   - int length; ///< @brief Length of the output buffer.
565   - unsigned char * ptr;
566   - } output;
567   -
568   - // network input buffer
569   - unsigned char * sbbuf;
570   -
571   - // telnet sub-option buffer
572   - unsigned char * sbptr;
573   - unsigned char telnet_state;
574   -
575   - unsigned char myopts[LIB3270_TELNET_N_OPTS];
576   - unsigned char hisopts[LIB3270_TELNET_N_OPTS];
577   -
578   - // kybd.c
579   - unsigned int kybdlock; ///< @brief @brief keyboard lock state.
580   - unsigned char aid; ///< @brief @brief current attention ID.
581   - void * unlock_id;
582   - time_t unlock_delay_time;
583   - unsigned long unlock_delay_ms; ///< @brief Delay before actually unlocking the keyboard after the host permits it.
584   - LIB3270_TA * ta_head;
585   - LIB3270_TA * ta_tail;
586   -
587   - // ft_dft.c
588   - int dft_buffersize; ///< @brief Buffer size (LIMIN, LIMOUT)
589   -
590   - // rpq.c
591   - int rpq_complained : 1;
592   -#if !defined(_WIN32)
593   - int omit_due_space_limit : 1;
594   -#endif
595   -
596   - char * rpq_warnbuf;
597   - int rpq_wbcnt;
598   -
599   - // User data (Usually points to session's widget)
600   - void * user_data;
601   -
602   - // selection
603   - char * paste_buffer;
604   - struct
605   - {
606   - int start;
607   - int end;
608   - } select;
609   -
610   - // ansi.c
611   - int scroll_top;
612   - int scroll_bottom;
613   - int once_cset;
614   - int saved_cursor;
615   -
616   - int held_wrap : 1;
617   -
618   - int insert_mode : 1;
619   - int auto_newline_mode : 1;
620   -
621   - int appl_cursor : 1;
622   - int saved_appl_cursor : 1;
623   -
624   - int wraparound_mode : 1;
625   - int saved_wraparound_mode : 1;
626   -
627   - int rev_wraparound_mode : 1;
628   - int saved_rev_wraparound_mode : 1;
629   -
630   - int allow_wide_mode : 1;
631   - int saved_allow_wide_mode : 1;
632   -
633   - int wide_mode : 1;
634   - int saved_wide_mode : 1;
635   -
636   - int saved_altbuffer : 1;
637   - int ansi_reset : 1; /**< @brief Non zero if the ansi_reset() was called in this session */
638   -
639   - int ansi_ch;
640   - int cs_to_change;
641   -
642   - /** @brief ANSI Character sets. */
643   - enum lib3270_ansi_cs
644   - {
645   - LIB3270_ANSI_CS_G0 = 0,
646   - LIB3270_ANSI_CS_G1 = 1,
647   - LIB3270_ANSI_CS_G2 = 2,
648   - LIB3270_ANSI_CS_G3 = 3
649   - } cset;
650   - enum lib3270_ansi_cs saved_cset;
651   -
652   - /** @brief Character set designations. */
653   - enum lib3270_ansi_csd
654   - {
655   - LIB3270_ANSI_CSD_LD = 0,
656   - LIB3270_ANSI_CSD_UK = 1,
657   - LIB3270_ANSI_CSD_US = 2
658   - } csd[4];
659   - enum lib3270_ansi_csd saved_csd[4];
660   -
661   - enum lib3270_ansi_state
662   - {
663   - LIB3270_ANSI_STATE_DATA = 0,
664   - LIB3270_ANSI_STATE_ESC = 1,
665   - LIB3270_ANSI_STATE_CSDES = 2,
666   - LIB3270_ANSI_STATE_N1 = 3,
667   - LIB3270_ANSI_STATE_DECP = 4,
668   - LIB3270_ANSI_STATE_TEXT = 5,
669   - LIB3270_ANSI_STATE_TEXT2 = 6,
670   - LIB3270_ANSI_STATE_MBPEND = 7
671   - } state;
672   -
673   - unsigned char * tabs;
674   -
675   - int pmi;
676   - char pending_mbs[LIB3270_MB_MAX];
677   -
678   - unsigned char gr;
679   - unsigned char saved_gr;
680   -
681   - unsigned char fg;
682   - unsigned char saved_fg;
683   -
684   - unsigned char bg;
685   - unsigned char saved_bg;
686   -
687   - // xio
688   - struct {
689   - void * read;
690   - void * write;
691   - void * except;
692   - } xio;
693   -
694   - size_t popups; ///< @brief Count open popups.
695   -
696   -#ifdef HAVE_LIBSSL
697   - /// @brief SSL Data.
698   - struct
699   - {
700   - char enabled;
701   - char host;
702   - LIB3270_SSL_STATE state;
703   - unsigned long error;
704   -#ifdef SSL_ENABLE_CRL_CHECK
705   - struct
706   - {
707   - char * prefer; ///< @brief Prefered protocol for CRL.
708   - char * url; ///< @brief URL for CRL download.
709   - X509_CRL * cert; ///< @brief Loaded CRL (can be null).
710   - } crl;
711   -#endif // SSL_ENABLE_CRL_CHECK
712   - SSL * con;
713   - } ssl;
714   -#endif // HAVE_LIBSSL
715   -
716   - struct lib3270_linked_list_head timeouts;
717   -
718   - struct
719   - {
720   - struct lib3270_linked_list_head list;
721   - int changed : 1;
722   - } input;
723   -
724   - // Trace methods.
725   - struct
726   - {
727   - void (*handler)(H3270 *session, void *userdata, const char *fmt, va_list args);
728   - void *userdata;
729   - } trace;
730   -
731   - /// @brief Event Listeners.
732   - struct
733   - {
734   - /// @brief State listeners.
735   - struct lib3270_linked_list_head state[LIB3270_STATE_USER];
736   -
737   - /// @brief Toggle listeners.
738   - struct lib3270_linked_list_head toggle[LIB3270_TOGGLE_COUNT];
739   -
740   - } listeners;
741   -
742   -
743   -};
744   -
745   -#define SELECTION_LEFT 0x01
746   -#define SELECTION_TOP 0x02
747   -#define SELECTION_RIGHT 0x04
748   -#define SELECTION_BOTTOM 0x08
749   -
750   -#define SELECTION_SINGLE_COL 0x10
751   -#define SELECTION_SINGLE_ROW 0x20
752   -
753   -#define SELECTION_ACTIVE 0x80
754   -
755   -#ifdef _WIN32
756   -/// @brief Windows Event Log Handler.
757   -LIB3270_INTERNAL HANDLE hEventLog;
758   -LIB3270_INTERNAL HANDLE hModule;
759   -#endif // _WIN32
760   -
761   -#ifdef HAVE_SYSLOG
762   -/// @brief Windows Event Log Handler.
763   -LIB3270_INTERNAL int use_syslog;
764   -#endif // HAVE_SYSLOG
765   -
766   -
767   -/* Library internal calls */
768   -LIB3270_INTERNAL int key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped);
769   -LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr);
770   -
771   -LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt);
772   -LIB3270_INTERNAL void remove_input_calls(H3270 *session);
773   -
774   -LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf, int len);
775   -LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession);
776   -
777   -LIB3270_INTERNAL int lib3270_default_event_dispatcher(H3270 *hSession, int block);
778   -
779   -LIB3270_INTERNAL void do_select(H3270 *h, unsigned int start, unsigned int end, unsigned int rect);
780   -
781   -
782   -/**
783   - * @brief Called from timer to attempt an automatic reconnection.
784   - */
785   -LIB3270_INTERNAL int lib3270_check_for_auto_reconnect(H3270 *hSession);
786   -
787   -#if defined(DEBUG)
788   - #define CHECK_SESSION_HANDLE(x) check_session_handle(&x,__FUNCTION__);
789   - LIB3270_INTERNAL void check_session_handle(H3270 **hSession, const char *fname);
790   -#else
791   - #define CHECK_SESSION_HANDLE(x) check_session_handle(&x);
792   - LIB3270_INTERNAL void check_session_handle(H3270 **hSession);
793   -#endif // DEBUG
794   -
795   -LIB3270_INTERNAL int check_online_session(const H3270 *hSession);
796   -LIB3270_INTERNAL int check_offline_session(const H3270 *hSession);
797   -
798   -/// @brief Returns -1 if the session is invalid or not online (sets errno).
799   -#define FAIL_IF_NOT_ONLINE(x) if(check_online_session(x)) return errno;
800   -
801   -/// @brief Returns -1 if the session is invalid or online (sets errno).
802   -#define FAIL_IF_ONLINE(x) if(check_offline_session(x)) return errno;
803   -
804   -LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on);
805   -
806   -#if defined(HAVE_LIBSSL)
807   -
808   - typedef struct _ssl_error_message
809   - {
810   - int error;
811   - const char * title;
812   - const char * text;
813   - const char * description;
814   -#ifdef _WIN32
815   - DWORD lasterror;
816   -#endif // _WIN32
817   - } SSL_ERROR_MESSAGE;
818   -
819   - struct ssl_status_msg
820   - {
821   - long id;
822   - LIB3270_NOTIFY icon;
823   - const char * iconName; // Icon name from https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
824   - const char * message;
825   - const char * description;
826   - };
827   -
828   - LIB3270_INTERNAL int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE *message);
829   - LIB3270_INTERNAL int ssl_init(H3270 *session);
830   - LIB3270_INTERNAL int ssl_negotiate(H3270 *hSession);
831   - LIB3270_INTERNAL void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state);
832   - LIB3270_INTERNAL const struct ssl_status_msg * ssl_get_status_from_error_code(long id);
833   -
834   -
835   - #if OPENSSL_VERSION_NUMBER >= 0x00907000L
836   - #define INFO_CONST const
837   - #else
838   - #define INFO_CONST
839   - #endif
840   -
841   - LIB3270_INTERNAL void ssl_info_callback(INFO_CONST SSL *s, int where, int ret);
842   -
843   - /**
844   - * @brief Global SSL_CTX object as framework to establish TLS/SSL or DTLS enabled connections.
845   - *
846   - */
847   - LIB3270_INTERNAL SSL_CTX * ssl_ctx;
848   -
849   - /**
850   - * @brief Index of h3270 handle in SSL session.
851   - *
852   - */
853   - LIB3270_INTERNAL int ssl_3270_ex_index;
854   -
855   - /**
856   - * @brief Emit popup on ssl error.
857   - *
858   - */
859   - LIB3270_INTERNAL int popup_ssl_error(H3270 *session, int rc, const char *title, const char *summary, const char *body);
860   -
861   - /**
862   - * @brief Emite popup on SSL error.
863   - *
864   - */
865   - LIB3270_INTERNAL int notify_ssl_error(H3270 *hSession, int rc, const SSL_ERROR_MESSAGE *message);
866   -
867   -#endif
868   -
869   - /// @brief Clear element at adress.
870   - LIB3270_INTERNAL void clear_chr(H3270 *hSession, int baddr);
871   -
872   - LIB3270_INTERNAL unsigned char get_field_attribute(H3270 *session, int baddr);
873   -
874   - /// @brief Default log writer.
875   - LIB3270_INTERNAL void default_log_writer(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr);
876   -
877   - LIB3270_INTERNAL char * lib3270_get_user_name();
878   -
879   - /// @brief Query data from URL.
880   - ///
881   - /// @param hSession Handle of the TN3270 Session.
882   - /// @param url The url to get.
883   - /// @param length Pointer to the response lenght (can be NULL).
884   - /// @param error_message Pointer to the error message.
885   - ///
886   - /// @return The data from URL (release it with lib3270_free) or NULL on error.
887   - ///
888   - LIB3270_INTERNAL char * lib3270_get_from_url(H3270 *hSession, const char *url, size_t *length, const char **error_message);
src/include/lib3270.h
... ... @@ -1000,7 +1000,6 @@
1000 1000 LIB3270_EXPORT int lib3270_in_e(const H3270 *h);
1001 1001  
1002 1002 LIB3270_EXPORT int lib3270_is_ready(const H3270 *h);
1003   - LIB3270_EXPORT int lib3270_is_connected(const H3270 *h);
1004 1003 LIB3270_EXPORT int lib3270_is_secure(const H3270 *h);
1005 1004  
1006 1005 LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_lock_status(const H3270 *h);
... ...
src/include/lib3270/actions.h
... ... @@ -38,15 +38,28 @@
38 38 LIB3270_ACTION_GROUP_NONE, ///< @brief Simple action, no signals os special treatment.
39 39 LIB3270_ACTION_GROUP_ONLINE, ///< @brief Action requires online state.
40 40 LIB3270_ACTION_GROUP_OFFLINE, ///< @brief Action requires offline state.
41   - LIB3270_ACTION_GROUP_SELECTION, ///< @brief Action requires an active selection.
  41 + LIB3270_ACTION_GROUP_SELECTED, ///< @brief Action requires an active selection.
42 42 LIB3270_ACTION_GROUP_UNSELECTED, ///< @brief Action fails if there has a selection.
  43 +
  44 + LIB3270_ACTION_GROUP_CUSTOM ///< @brief Custom group/Number of groups.
43 45 } LIB3270_ACTION_GROUP;
44 46  
  47 + typedef enum _lib3270_action_type
  48 + {
  49 + LIB3270_ACTION_TYPE_GENERIC, ///< @brief Generic action.
  50 + LIB3270_ACTION_TYPE_NAVIGATION, ///< @brief Cursor and field navigation.
  51 + LIB3270_ACTION_CONNECTION, ///< @brief Connection action.
  52 + LIB3270_ACTION_CLIPBOARD, ///< @brief Clipboard action.
  53 +
  54 + LIB3270_ACTION_CUSTOM ///< @brief Custom action/Number of actions.
  55 + } LIB3270_ACTION_TYPE;
  56 +
45 57 typedef struct _lib3270_action
46 58 {
47 59 LIB3270_PROPERTY_HEAD
48 60  
49 61 LIB3270_ACTION_GROUP group; ///< @brief Action group.
  62 + LIB3270_ACTION_TYPE type; ///< @brief Action type.
50 63  
51 64 int (*activate)(H3270 *hSession); ///< @brief lib3270 associated method.
52 65 int (*activatable)(const H3270 *hSession); ///< @brief Is the action activatable?
... ... @@ -57,6 +70,32 @@
57 70  
58 71 } LIB3270_ACTION;
59 72  
  73 +
  74 +/**
  75 + * @brief Register an action group listener.
  76 + *
  77 + * @param hSession TN3270 Session handle.
  78 + * @param group The group to listen.
  79 + * @param func Callback for group events.
  80 + * @param data Argument data for callback.
  81 + *
  82 + * @return Listener ID (for removal) or NULL if error.
  83 + *
  84 + */
  85 + LIB3270_EXPORT const void * lib3270_register_action_group_listener(H3270 *hSession, LIB3270_ACTION_GROUP group, void (*func)(H3270 *, void *),void *data);
  86 +
  87 +/**
  88 + * @brief Unregister an action group listener.
  89 + *
  90 + * @param hSession TN3270 Session handle.
  91 + * @param group The group to listen.
  92 + * @param id ID of the listener to remove.
  93 + *
  94 + * @return 0 if ok, error code if not.
  95 + *
  96 + */
  97 + LIB3270_EXPORT int lib3270_unregister_action_group_listener(H3270 *hSession, LIB3270_ACTION_GROUP group, const void *id);
  98 +
60 99 /**
61 100 *
62 101 * @brief Call lib3270 action by name.
... ...
src/mkfb/mkfb.c
... ... @@ -384,7 +384,7 @@ main(int argc, char *argv[])
384 384 fprintf(t, "/* This file was created automatically from %s by mkfb. */\n\n",
385 385 filename);
386 386 if (cmode) {
387   - fprintf(t, "#include \"lib3270-internals.h\"\n");
  387 + fprintf(t, "#include \"internals.h\"\n");
388 388 fprintf(t, "static unsigned char fsd[] = {\n");
389 389 } else {
390 390 fprintf(t, "unsigned char common_fallbacks[] = {\n");
... ...
src/selection/actions.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   - #include <lib3270-internals.h>
  30 + #include <internals.h>
31 31 #include <lib3270.h>
32 32 #include <lib3270/actions.h>
33 33 #include <lib3270/session.h>
... ... @@ -63,6 +63,8 @@ LIB3270_EXPORT int lib3270_unselect(H3270 *hSession)
63 63  
64 64 hSession->cbk.set_selection(hSession,0);
65 65 hSession->cbk.update_selection(hSession,-1,-1);
  66 + lib3270_notify_actions(hSession,LIB3270_ACTION_GROUP_UNSELECTED);
  67 +
66 68 }
67 69  
68 70 return 0;
... ...
src/selection/get.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   - #include <lib3270-internals.h>
  30 + #include <internals.h>
31 31 #include <lib3270.h>
32 32 #include <lib3270/session.h>
33 33 #include <lib3270/selection.h>
... ...
src/selection/selection.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   - #include <lib3270-internals.h>
  30 + #include <internals.h>
31 31 #include <lib3270.h>
32 32 #include <lib3270/actions.h>
33 33 #include <lib3270/session.h>
... ... @@ -165,37 +165,38 @@ void toggle_rectselect(H3270 *session, struct lib3270_toggle GNUC_UNUSED(*t), LI
165 165 update_selected_region(session);
166 166 }
167 167  
168   -void do_select(H3270 *h, unsigned int start, unsigned int end, unsigned int rect)
  168 +void do_select(H3270 *hSession, unsigned int start, unsigned int end, unsigned int rect)
169 169 {
170   - if(end > (h->view.rows * h->view.cols))
  170 + if(end > (hSession->view.rows * hSession->view.cols))
171 171 return;
172 172  
173 173 // Do we really need to change selection?
174   - if( ((int) start) == h->select.start && ((int) end) == h->select.end && h->selected)
  174 + if( ((int) start) == hSession->select.start && ((int) end) == hSession->select.end && hSession->selected)
175 175 return;
176 176  
177 177 // Start address is inside the screen?
178   - h->select.start = start;
179   - h->select.end = end;
  178 + hSession->select.start = start;
  179 + hSession->select.end = end;
180 180  
181 181 if(rect)
182 182 {
183   - h->rectsel = 1;
184   - update_selected_rectangle(h);
  183 + hSession->rectsel = 1;
  184 + update_selected_rectangle(hSession);
185 185 }
186 186 else
187 187 {
188   - h->rectsel = 0;
189   - update_selected_region(h);
  188 + hSession->rectsel = 0;
  189 + update_selected_region(hSession);
190 190 }
191 191  
192   - if(!h->selected)
  192 + if(!hSession->selected)
193 193 {
194   - h->selected = 1;
195   - h->cbk.set_selection(h,1);
  194 + hSession->selected = 1;
  195 + hSession->cbk.set_selection(hSession,1);
  196 + lib3270_notify_actions(hSession,LIB3270_ACTION_GROUP_SELECTED);
196 197 }
197 198  
198   - h->cbk.update_selection(h,start,end);
  199 + hSession->cbk.update_selection(hSession,start,end);
199 200  
200 201 }
201 202  
... ...
src/ssl/crl.c
... ... @@ -29,7 +29,7 @@
29 29  
30 30 #include <config.h>
31 31  
32   -#include <lib3270-internals.h>
  32 +#include <internals.h>
33 33 #include <lib3270/log.h>
34 34 #include <lib3270/trace.h>
35 35 #include <lib3270/toggle.h>
... ...
src/ssl/linux/init.c
... ... @@ -50,7 +50,7 @@
50 50 #define SSL_ST_OK 3
51 51 #endif // !SSL_ST_OK
52 52  
53   -#include <lib3270-internals.h>
  53 +#include <internals.h>
54 54 #include <errno.h>
55 55 #include <lib3270.h>
56 56 #include <lib3270/internals.h>
... ...
src/ssl/linux/ldap.c
... ... @@ -34,7 +34,7 @@
34 34 */
35 35  
36 36 #include <config.h>
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38 #include <lib3270/log.h>
39 39 #include <lib3270/trace.h>
40 40 #include <lib3270/toggle.h>
... ...
src/ssl/linux/private.h
... ... @@ -38,7 +38,7 @@
38 38 #include <openssl/x509_vfy.h>
39 39 #include <openssl/x509.h>
40 40  
41   - #include <lib3270-internals.h>
  41 + #include <internals.h>
42 42 #include <trace_dsc.h>
43 43 #include <errno.h>
44 44 #include <lib3270.h>
... ...
src/ssl/negotiate.c
... ... @@ -34,7 +34,7 @@
34 34  
35 35  
36 36 #include <config.h>
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38  
39 39 #if defined(HAVE_LIBSSL)
40 40  
... ... @@ -150,7 +150,7 @@ static int background_ssl_negotiation(H3270 *hSession, void *message)
150 150 }
151 151  
152 152 /* Set up the TLS/SSL connection. */
153   - if(SSL_set_fd(hSession->ssl.con, hSession->sock) != 1)
  153 + if(SSL_set_fd(hSession->ssl.con, hSession->connection.sock) != 1)
154 154 {
155 155 trace_ssl(hSession,"%s","SSL_set_fd failed!\n");
156 156  
... ...
src/ssl/notify.c
... ... @@ -34,7 +34,7 @@
34 34  
35 35  
36 36 #include <config.h>
37   -#include <lib3270-internals.h>
  37 +#include <internals.h>
38 38 #include <lib3270/log.h>
39 39  
40 40 /*--[ Implement ]------------------------------------------------------------------------------------*/
... ...
src/ssl/properties.c
... ... @@ -27,7 +27,7 @@
27 27 *
28 28 */
29 29  
30   -#include <lib3270-internals.h>
  30 +#include <internals.h>
31 31 #include <lib3270/properties.h>
32 32  
33 33 #if defined(HAVE_LIBSSL)
... ...
src/ssl/state.c
... ... @@ -28,7 +28,7 @@
28 28 */
29 29  
30 30 #include <config.h>
31   -#include <lib3270-internals.h>
  31 +#include <internals.h>
32 32 #include <errno.h>
33 33 #include <lib3270.h>
34 34 #include <lib3270/internals.h>
... ...
src/ssl/windows/init.c
... ... @@ -52,7 +52,7 @@
52 52 #define SSL_ST_OK 3
53 53 #endif // !SSL_ST_OK
54 54  
55   -#include <lib3270-internals.h>
  55 +#include <internals.h>
56 56 #include <errno.h>
57 57 #include <lib3270.h>
58 58 #include <lib3270/internals.h>
... ...
src/ssl/windows/private.h
... ... @@ -41,7 +41,7 @@
41 41 #include <openssl/x509_vfy.h>
42 42 #include <openssl/x509.h>
43 43  
44   - #include <lib3270-internals.h>
  44 + #include <internals.h>
45 45 #include <trace_dsc.h>
46 46 #include <errno.h>
47 47 #include <lib3270.h>
... ...
src/testprogram/testprogram.c
... ... @@ -4,7 +4,7 @@
4 4 #include <stdlib.h>
5 5 #include <getopt.h>
6 6  
7   -#include <lib3270-internals.h>
  7 +#include <internals.h>
8 8 #include <lib3270.h>
9 9 #include <lib3270/actions.h>
10 10 #include <lib3270/trace.h>
... ... @@ -24,6 +24,11 @@ static void write_trace(H3270 GNUC_UNUSED(*session), void GNUC_UNUSED(*userdata)
24 24 }
25 25 }
26 26  
  27 +static void online_group_state_changed(H3270 GNUC_UNUSED(*hSession), void GNUC_UNUSED(*dunno))
  28 +{
  29 + printf("\n\n%s\n\n",__FUNCTION__);
  30 +}
  31 +
27 32 int main(int argc, char *argv[])
28 33 {
29 34 // #pragma GCC diagnostic push
... ... @@ -102,6 +107,8 @@ int main(int argc, char *argv[])
102 107  
103 108 printf("\nConnecting to %s\n",lib3270_get_url(h));
104 109  
  110 + const void * online_listener = lib3270_register_action_group_listener(h,LIB3270_ACTION_GROUP_ONLINE,online_group_state_changed,NULL);
  111 +
105 112 rc = lib3270_reconnect(h,120);
106 113 printf("\n\nConnect exits with rc=%d (%s)\n\n",rc,strerror(rc));
107 114  
... ... @@ -139,6 +146,8 @@ int main(int argc, char *argv[])
139 146  
140 147 }
141 148  
  149 + lib3270_unregister_action_group_listener(h,LIB3270_ACTION_GROUP_ONLINE,online_listener);
  150 +
142 151 lib3270_session_free(h);
143 152  
144 153 return 0;
... ...