Commit 1870de30b5fb1a656c403bccb31100a692f325c9

Authored by Perry Werneck
1 parent 8a1561e6
Exists in master and in 1 other branch develop

Refactoring hllapi module.

@@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
27 #---[ Library configuration ]------------------------------------------------------------ 27 #---[ Library configuration ]------------------------------------------------------------
28 28
29 LIBNAME=libhllapi 29 LIBNAME=libhllapi
  30 +SONAME=@SONAME@
30 31
31 SOURCES= \ 32 SOURCES= \
32 $(wildcard src/core/*.cc) \ 33 $(wildcard src/core/*.cc) \
@@ -82,7 +83,9 @@ BINRLS=$(BINDIR)/Release @@ -82,7 +83,9 @@ BINRLS=$(BINDIR)/Release
82 83
83 DEPENDS= \ 84 DEPENDS= \
84 Makefile \ 85 Makefile \
85 - src/include/*.h 86 + src/include/*.h \
  87 + src/include/lib3270/*.h
  88 +
86 89
87 CFLAGS= \ 90 CFLAGS= \
88 @CFLAGS@ \ 91 @CFLAGS@ \
@@ -98,7 +101,7 @@ LIBS= \ @@ -98,7 +101,7 @@ LIBS= \
98 #---[ Debug Rules ]---------------------------------------------------------------------- 101 #---[ Debug Rules ]----------------------------------------------------------------------
99 102
100 $(OBJDBG)/%.o: \ 103 $(OBJDBG)/%.o: \
101 - %.c \ 104 + %.cc \
102 $(DEPENDS) 105 $(DEPENDS)
103 106
104 @echo $< ... 107 @echo $< ...
@@ -121,7 +124,7 @@ $(OBJDBG)/%.o: \ @@ -121,7 +124,7 @@ $(OBJDBG)/%.o: \
121 #---[ Release Rules ]-------------------------------------------------------------------- 124 #---[ Release Rules ]--------------------------------------------------------------------
122 125
123 $(OBJRLS)/%.o: \ 126 $(OBJRLS)/%.o: \
124 - %.c \ 127 + %.cc \
125 $(DEPENDS) 128 $(DEPENDS)
126 129
127 @echo $< ... 130 @echo $< ...
@@ -120,6 +120,7 @@ dnl --------------------------------------------------------------------------- @@ -120,6 +120,7 @@ dnl ---------------------------------------------------------------------------
120 120
121 AC_PATH_TOOL([AR], [ar], [ar]) 121 AC_PATH_TOOL([AR], [ar], [ar])
122 AC_PATH_TOOL([WINDRES], [windres], [no]) 122 AC_PATH_TOOL([WINDRES], [windres], [no])
  123 +AC_PATH_TOOL([VALGRIND], [valgrind], [no])
123 124
124 PKG_CHECK_EXISTS 125 PKG_CHECK_EXISTS
125 126
@@ -166,6 +167,27 @@ case &quot;$host&quot; in @@ -166,6 +167,27 @@ case &quot;$host&quot; in
166 esac 167 esac
167 168
168 dnl --------------------------------------------------------------------------- 169 dnl ---------------------------------------------------------------------------
  170 +dnl Check for C++ 2011 support
  171 +dnl ---------------------------------------------------------------------------
  172 +AC_DEFUN([AX_CHECK_COMPILE_FLAG],
  173 +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
  174 +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
  175 +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
  176 + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
  177 + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
  178 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  179 + [AS_VAR_SET(CACHEVAR,[yes])],
  180 + [AS_VAR_SET(CACHEVAR,[no])])
  181 + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
  182 +AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
  183 + [m4_default([$2], :)],
  184 + [m4_default([$3], :)])
  185 +AS_VAR_POPDEF([CACHEVAR])dnl
  186 +])dnl AX_CHECK_COMPILE_FLAGS
  187 +
  188 +AX_CHECK_COMPILE_FLAG([-std=gnu++11], [CFLAGS="$CFLAGS -std=gnu++11"])
  189 +
  190 +dnl ---------------------------------------------------------------------------
169 dnl Check for libintl 191 dnl Check for libintl
170 dnl --------------------------------------------------------------------------- 192 dnl ---------------------------------------------------------------------------
171 193
@@ -32,22 +32,13 @@ @@ -32,22 +32,13 @@
32 <Compiler> 32 <Compiler>
33 <Add option="-Wall" /> 33 <Add option="-Wall" />
34 </Compiler> 34 </Compiler>
35 - <Unit filename="src/daemon/linux/daemon.c">  
36 - <Option compilerVar="CC" />  
37 - </Unit>  
38 - <Unit filename="src/daemon/linux/iocallback.c">  
39 - <Option compilerVar="CC" />  
40 - </Unit>  
41 - <Unit filename="src/hllapi/calls.cc" />  
42 - <Unit filename="src/hllapi/client.h" />  
43 - <Unit filename="src/hllapi/hllapi.c">  
44 - <Option compilerVar="CC" />  
45 - </Unit>  
46 - <Unit filename="src/hllapi/remotectl.h" /> 35 + <Unit filename="src/core/calls.cc" />
  36 + <Unit filename="src/core/controller.cc" />
  37 + <Unit filename="src/core/hllapi.cc" />
  38 + <Unit filename="src/core/private.h" />
  39 + <Unit filename="src/core/windows/resources.rc" />
47 <Unit filename="src/include/config.h" /> 40 <Unit filename="src/include/config.h" />
48 - <Unit filename="src/include/dbus-glue.h" />  
49 - <Unit filename="src/ipc3270c/linux/daemon.h" />  
50 - <Unit filename="src/ipc3270c/linux/globals.h" /> 41 + <Unit filename="src/include/lib3270/hllapi.h" />
51 <Unit filename="src/ipc3270c/linux/gobject.c"> 42 <Unit filename="src/ipc3270c/linux/gobject.c">
52 <Option compilerVar="CC" /> 43 <Option compilerVar="CC" />
53 </Unit> 44 </Unit>
@@ -57,20 +48,10 @@ @@ -57,20 +48,10 @@
57 <Unit filename="src/ipc3270c/linux/misc.c"> 48 <Unit filename="src/ipc3270c/linux/misc.c">
58 <Option compilerVar="CC" /> 49 <Option compilerVar="CC" />
59 </Unit> 50 </Unit>
60 - <Unit filename="src/ipc3270c/linux/service.h" />  
61 <Unit filename="src/ipc3270c/windows/main.c"> 51 <Unit filename="src/ipc3270c/windows/main.c">
62 <Option compilerVar="CC" /> 52 <Option compilerVar="CC" />
63 </Unit> 53 </Unit>
64 - <Unit filename="src/ipc3270c/windows/private.h" />  
65 - <Unit filename="src/ipc3270c/windows/resources.rc" />  
66 - <Unit filename="src/plugin/windows/private.h" />  
67 - <Unit filename="src/plugin/windows/resources.rc" />  
68 - <Unit filename="src/testprograms/hllapi.c">  
69 - <Option compilerVar="CC" />  
70 - </Unit>  
71 - <Unit filename="src/testprograms/ipc3270c.c">  
72 - <Option compilerVar="CC" />  
73 - </Unit> 54 + <Unit filename="src/testprogram/testprogram.cc" />
74 <Extensions> 55 <Extensions>
75 <code_completion /> 56 <code_completion />
76 <envvars /> 57 <envvars />
pw3270dbus.xml
@@ -1,251 +0,0 @@ @@ -1,251 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8" ?>  
2 -<node name="/br/com/bb/pw3270">  
3 - <interface name="br.com.bb.pw3270">  
4 - <method name="getRevision">  
5 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
6 - <arg type="s" name="revision" direction="out" />  
7 - </method>  
8 - <method name="quit">  
9 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
10 - <arg type="i" name="result" direction="out" />  
11 - </method>  
12 - <method name="connect">  
13 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
14 - <arg type="s" name="uri" direction="in" />  
15 - <arg type="i" name="result" direction="out" />  
16 - </method>  
17 - <method name="setURL">  
18 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
19 - <arg type="s" name="uri" direction="in" />  
20 - <arg type="i" name="result" direction="out" />  
21 - </method>  
22 - <method name="getURL">  
23 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
24 - <arg type="s" name="uri" direction="out" />  
25 - </method>  
26 - <method name="disconnect">  
27 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
28 - <arg type="i" name="result" direction="out" />  
29 - </method>  
30 - <method name="getMessageID">  
31 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
32 - <arg type="i" name="status" direction="out" />  
33 - </method>  
34 - <method name="getConnectionState">  
35 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
36 - <arg type="i" name="status" direction="out" />  
37 - </method>  
38 - <method name="getSecureState">  
39 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
40 - <arg type="i" name="status" direction="out" />  
41 - </method>  
42 - <method name="getScreenContents">  
43 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
44 - <arg type="s" name="contents" direction="out" />  
45 - </method>  
46 - <method name="enter">  
47 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
48 - <arg type="i" name="result" direction="out" />  
49 - </method>  
50 - <method name="pfKey">  
51 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
52 - <arg type="i" name="key" direction="in" />  
53 - <arg type="i" name="result" direction="out" />  
54 - </method>  
55 - <method name="paKey">  
56 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
57 - <arg type="i" name="key" direction="in" />  
58 - <arg type="i" name="result" direction="out" />  
59 - </method>  
60 - <method name="input">  
61 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
62 - <arg type="s" name="text" direction="in" />  
63 - </method>  
64 - <method name="setTextAt">  
65 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
66 - <arg type="i" name="row" direction="in" />  
67 - <arg type="i" name="col" direction="in" />  
68 - <arg type="s" name="text" direction="in" />  
69 - <arg type="i" name="result" direction="out" />  
70 - </method>  
71 - <method name="getTextAt">  
72 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
73 - <arg type="i" name="row" direction="in" />  
74 - <arg type="i" name="col" direction="in" />  
75 - <arg type="i" name="len" direction="in" />  
76 - <arg type="y" name="lf" direction="in" />  
77 - <arg type="s" name="text" direction="out" />  
78 - </method>  
79 - <method name="getText">  
80 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
81 - <arg type="i" name="addr" direction="in" />  
82 - <arg type="i" name="len" direction="in" />  
83 - <arg type="y" name="lf" direction="in" />  
84 - <arg type="s" name="text" direction="out" />  
85 - </method>  
86 - <method name="setClipboard">  
87 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
88 - <arg type="s" name="text" direction="in" />  
89 - <arg type="i" name="result" direction="out" />  
90 - </method>  
91 - <method name="getClipboard">  
92 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
93 - <arg type="s" name="text" direction="out" />  
94 - </method>  
95 - <method name="isConnected">  
96 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
97 - <arg type="i" name="result" direction="out" />  
98 - </method>  
99 - <method name="isReady">  
100 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
101 - <arg type="i" name="result" direction="out" />  
102 - </method>  
103 - <method name="inTN3270E">  
104 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
105 - <arg type="i" name="result" direction="out" />  
106 - </method>  
107 - <method name="waitForReady">  
108 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
109 - <arg type="i" name="timeout" direction="in" />  
110 - <arg type="i" name="result" direction="out" />  
111 - </method>  
112 - <method name="setCursorAt">  
113 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
114 - <arg type="i" name="row" direction="in" />  
115 - <arg type="i" name="col" direction="in" />  
116 - <arg type="i" name="result" direction="out" />  
117 - </method>  
118 - <method name="setCursorAddress">  
119 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
120 - <arg type="i" name="addr" direction="in" />  
121 - <arg type="i" name="result" direction="out" />  
122 - </method>  
123 - <method name="getCursorAddress">  
124 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
125 - <arg type="i" name="addr" direction="out" />  
126 - </method>  
127 - <method name="getScreenWidth">  
128 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
129 - <arg type="i" name="width" direction="out" />  
130 - </method>  
131 - <method name="getScreenHeight">  
132 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
133 - <arg type="i" name="height" direction="out" />  
134 - </method>  
135 - <method name="getScreenLength">  
136 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
137 - <arg type="i" name="len" direction="out" />  
138 - </method>  
139 - <method name="getNextUnprotected">  
140 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
141 - <arg type="i" name="addr" direction="in" />  
142 - <arg type="i" name="result" direction="out" />  
143 - </method>  
144 - <method name="getIsProtected">  
145 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
146 - <arg type="i" name="addr" direction="in" />  
147 - <arg type="i" name="result" direction="out" />  
148 - </method>  
149 - <method name="getIsProtectedAt">  
150 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
151 - <arg type="i" name="row" direction="in" />  
152 - <arg type="i" name="col" direction="in" />  
153 - <arg type="i" name="result" direction="out" />  
154 - </method>  
155 - <method name="setToggle">  
156 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
157 - <arg type="i" name="id" direction="in" />  
158 - <arg type="i" name="value" direction="in" />  
159 - <arg type="i" name="result" direction="out" />  
160 - </method>  
161 - <method name="cmpTextAt">  
162 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
163 - <arg type="i" name="row" direction="in" />  
164 - <arg type="i" name="col" direction="in" />  
165 - <arg type="s" name="text" direction="in" />  
166 - <arg type="y" name="lf" direction="in" />  
167 - <arg type="i" name="result" direction="out" />  
168 - </method>  
169 - <method name="getFieldStart">  
170 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
171 - <arg type="i" name="addr" direction="in" />  
172 - <arg type="i" name="result" direction="out" />  
173 - </method>  
174 - <method name="getFieldLength">  
175 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
176 - <arg type="i" name="addr" direction="in" />  
177 - <arg type="i" name="result" direction="out" />  
178 - </method>  
179 - <method name="setScript">  
180 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
181 - <arg type="s" name="id" direction="in" />  
182 - <arg type="i" name="status" direction="in" />  
183 - <arg type="i" name="result" direction="out" />  
184 - </method>  
185 - <method name="showPopup">  
186 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
187 - <arg type="i" name="id" direction="in" />  
188 - <arg type="s" name="title" direction="in" />  
189 - <arg type="s" name="msg" direction="in" />  
190 - <arg type="s" name="text" direction="in" />  
191 - </method>  
192 - <method name="getHostCharset">  
193 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
194 - <arg type="s" name="charset" direction="out" />  
195 - </method>  
196 - <method name="getDisplayCharset">  
197 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
198 - <arg type="s" name="charset" direction="out" />  
199 - </method>  
200 - <method name="setHostCharset">  
201 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
202 - <arg type="s" name="charset" direction="in" />  
203 - <arg type="i" name="result" direction="out" />  
204 - </method>  
205 - <method name="eraseEof">  
206 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
207 - <arg type="i" name="result" direction="out" />  
208 - </method>  
209 - <method name="print">  
210 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
211 - <arg type="i" name="result" direction="out" />  
212 - </method>  
213 - <method name="ebc2asc">  
214 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
215 - <arg type="s" name="from" direction="in" />  
216 - <arg type="s" name="to" direction="out" />  
217 - </method>  
218 - <method name="asc2ebc">  
219 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
220 - <arg type="s" name="from" direction="in" />  
221 - <arg type="s" name="to" direction="out" />  
222 - </method>  
223 -  
224 - <method name="action">  
225 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
226 - <arg type="s" name="name" direction="in" />  
227 - <arg type="i" name="result" direction="out" />  
228 - </method>  
229 -  
230 - <method name="filetransfer">  
231 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
232 - <arg type="s" name="local" direction="in" />  
233 - <arg type="s" name="remote" direction="in" />  
234 - <arg type="i" name="flags" direction="in" />  
235 - <arg type="i" name="lrecl" direction="in" />  
236 - <arg type="i" name="blksize" direction="in" />  
237 - <arg type="i" name="primspace" direction="in" />  
238 - <arg type="i" name="secspace" direction="in" />  
239 - <arg type="i" name="dft" direction="in" />  
240 - <arg type="i" name="result" direction="out" />  
241 - </method>  
242 -  
243 - <method name="setUnlockDelay">  
244 - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>  
245 - <arg type="i" name="value" direction="in" />  
246 - <arg type="i" name="result" direction="out" />  
247 - </method>  
248 -  
249 - </interface>  
250 -  
251 -</node>  
src/core/calls.cc
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple 18 * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA, 02111-1307, USA 19 * Place, Suite 330, Boston, MA, 02111-1307, USA
20 * 20 *
21 - * Este programa está nomeado como calls.cc e possui - linhas de código. 21 + * Este programa está nomeado como - e possui - linhas de código.
22 * 22 *
23 * Contatos: 23 * Contatos:
24 * 24 *
@@ -27,145 +27,136 @@ @@ -27,145 +27,136 @@
27 * 27 *
28 */ 28 */
29 29
30 - #include <exception>  
31 - #include <cstdlib>  
32 - #include <cstring>  
33 -  
34 - #include <pw3270/hllapi.h>  
35 - #include <pw3270/pw3270cpp.h>  
36 - #include "client.h"  
37 -  
38 - using namespace std;  
39 - using namespace PW3270_NAMESPACE;  
40 -  
41 -/*--[ Globals ]--------------------------------------------------------------------------------------*/  
42 -  
43 - static session * hSession = NULL;  
44 - static time_t hllapi_timeout = 120; 30 + #include "private.h"
45 31
46 /*--[ Implement ]------------------------------------------------------------------------------------*/ 32 /*--[ Implement ]------------------------------------------------------------------------------------*/
47 33
48 - HLLAPI_API_CALL hllapi_init(LPSTR mode) 34 + HLLAPI_API_CALL hllapi_get_revision(void)
49 { 35 {
50 - trace("%s(%s)",__FUNCTION__,mode); 36 + try {
51 37
52 - try  
53 - {  
54 - if(hSession)  
55 - delete hSession;  
56 - hSession = session::create(mode); 38 + return atoi(getSession().getRevision().c_str());
57 39
58 - if(!hSession) {  
59 - return HLLAPI_STATUS_UNAVAILABLE;  
60 - } 40 + } catch(std::exception &e) {
61 41
62 - hSession->set_display_charset(); 42 + hllapi_lasterror = e.what();
63 43
64 - trace("hSession=%p",hSession);  
65 - }  
66 - catch(std::exception &e)  
67 - {  
68 - trace("Error \"%s\"",e.what());  
69 - return HLLAPI_STATUS_SYSTEM_ERROR;  
70 } 44 }
71 45
72 - return HLLAPI_STATUS_SUCCESS;  
73 - 46 + return (DWORD) -1;
74 } 47 }
75 48
76 - HLLAPI_API_CALL hllapi_deinit(void) 49 + HLLAPI_API_CALL hllapi_connect(const LPSTR uri, WORD wait)
77 { 50 {
78 - trace("%s()",__FUNCTION__); 51 + try {
79 52
80 - try  
81 - {  
82 - if(hSession)  
83 - {  
84 - delete hSession;  
85 - hSession = NULL;  
86 - }  
87 - }  
88 - catch(std::exception &e)  
89 - { 53 + getSession().connect((const char *) uri, wait);
  54 +
  55 + } catch(std::exception &e) {
  56 +
  57 + hllapi_lasterror = e.what();
90 return HLLAPI_STATUS_SYSTEM_ERROR; 58 return HLLAPI_STATUS_SYSTEM_ERROR;
91 } 59 }
92 60
93 - return HLLAPI_STATUS_SUCCESS; 61 + return hllapi_get_state();
  62 +
94 } 63 }
95 64
96 - HLLAPI_API_CALL hllapi_get_revision(void)  
97 - {  
98 - try  
99 - {  
100 - return atoi(session::get_default()->get_revision().c_str());  
101 - }  
102 - catch(std::exception &e)  
103 - {  
104 - return -1; 65 + HLLAPI_API_CALL hllapi_is_connected(void) {
  66 +
  67 + try {
  68 +
  69 + return getSession().isConnected();
  70 +
  71 + } catch(std::exception &e) {
  72 +
  73 + hllapi_lasterror = e.what();
105 } 74 }
106 - return (DWORD) -1; 75 +
  76 + return 0;
107 } 77 }
108 78
109 - HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait)  
110 - {  
111 - try  
112 - {  
113 - session::get_default()->connect(uri,hllapi_timeout);  
114 - }  
115 - catch(std::exception &e)  
116 - { 79 + HLLAPI_API_CALL hllapi_get_state(void) {
  80 +
  81 + try {
  82 +
  83 + switch(hllapi_get_message_id()) {
  84 + case LIB3270_MESSAGE_NONE: // 0 - No message
  85 + return HLLAPI_STATUS_SUCCESS; // keyboard was unlocked and ready for input.
  86 +
  87 + case LIB3270_MESSAGE_DISCONNECTED: // 4 - Disconnected from host
  88 + return HLLAPI_STATUS_DISCONNECTED; // Your application program was not connected to a valid session.
  89 +
  90 + case LIB3270_MESSAGE_MINUS:
  91 + case LIB3270_MESSAGE_PROTECTED:
  92 + case LIB3270_MESSAGE_NUMERIC:
  93 + case LIB3270_MESSAGE_OVERFLOW:
  94 + case LIB3270_MESSAGE_INHIBIT:
  95 + case LIB3270_MESSAGE_KYBDLOCK:
  96 + return HLLAPI_STATUS_KEYBOARD_LOCKED; // keyboard is locked.
  97 +
  98 + case LIB3270_MESSAGE_SYSWAIT:
  99 + case LIB3270_MESSAGE_TWAIT:
  100 + case LIB3270_MESSAGE_AWAITING_FIRST:
  101 + case LIB3270_MESSAGE_X:
  102 + case LIB3270_MESSAGE_RESOLVING:
  103 + case LIB3270_MESSAGE_CONNECTING:
  104 + return HLLAPI_STATUS_WAITING; // time-out while still busy (in XCLOCK or XSYSTEM in X) for the 3270 terminal emulation.
  105 + }
  106 +
  107 + } catch(std::exception &e) {
  108 +
  109 + hllapi_lasterror = e.what();
117 return HLLAPI_STATUS_SYSTEM_ERROR; 110 return HLLAPI_STATUS_SYSTEM_ERROR;
118 } 111 }
119 112
120 - return hllapi_get_state(); 113 + hllapi_lasterror = "Unexpected message id";
  114 + return HLLAPI_STATUS_SYSTEM_ERROR;
121 } 115 }
122 116
123 - HLLAPI_API_CALL hllapi_is_connected(void)  
124 - {  
125 - if(!session::has_default())  
126 - {  
127 - return 0;  
128 - } 117 + HLLAPI_API_CALL hllapi_get_message_id(void) {
129 118
130 - return session::get_default()->is_connected();  
131 - } 119 + try {
132 120
133 - HLLAPI_API_CALL hllapi_get_state(void)  
134 - {  
135 - switch(hllapi_get_message_id())  
136 - {  
137 - case LIB3270_MESSAGE_NONE: // 0 - No message  
138 - return HLLAPI_STATUS_SUCCESS; // keyboard was unlocked and ready for input. 121 + TN3270::Host & session = getSession();
139 122
140 - case LIB3270_MESSAGE_DISCONNECTED: // 4 - Disconnected from host  
141 - return HLLAPI_STATUS_DISCONNECTED; // Your application program was not connected to a valid session. 123 + if(!session.isConnected()) {
  124 + hllapi_lasterror = strerror(ENOTCONN);
  125 + return HLLAPI_STATUS_DISCONNECTED;
  126 + }
142 127
143 - case LIB3270_MESSAGE_MINUS:  
144 - case LIB3270_MESSAGE_PROTECTED:  
145 - case LIB3270_MESSAGE_NUMERIC:  
146 - case LIB3270_MESSAGE_OVERFLOW:  
147 - case LIB3270_MESSAGE_INHIBIT:  
148 - case LIB3270_MESSAGE_KYBDLOCK:  
149 - return HLLAPI_STATUS_KEYBOARD_LOCKED; // keyboard is locked. 128 + return (DWORD) session.getProgramMessage();
  129 +
  130 + } catch(std::exception &e) {
  131 +
  132 + hllapi_lasterror = e.what();
  133 + return HLLAPI_STATUS_SYSTEM_ERROR;
150 134
151 - case LIB3270_MESSAGE_SYSWAIT:  
152 - case LIB3270_MESSAGE_TWAIT:  
153 - case LIB3270_MESSAGE_AWAITING_FIRST:  
154 - case LIB3270_MESSAGE_X:  
155 - case LIB3270_MESSAGE_RESOLVING:  
156 - case LIB3270_MESSAGE_CONNECTING:  
157 - return HLLAPI_STATUS_WAITING; // time-out while still busy (in XCLOCK or XSYSTEM in X) for the 3270 terminal emulation.  
158 } 135 }
159 136
160 - return HLLAPI_STATUS_SYSTEM_ERROR; 137 + return 0;
  138 +
161 } 139 }
162 140
163 - HLLAPI_API_CALL hllapi_disconnect(void)  
164 - {  
165 - session::get_default()->disconnect(); 141 + HLLAPI_API_CALL hllapi_disconnect(void) {
  142 +
  143 + try {
  144 +
  145 + getSession().disconnect();
  146 +
  147 + } catch(std::exception &e) {
  148 +
  149 + hllapi_lasterror = e.what();
  150 + return HLLAPI_STATUS_SYSTEM_ERROR;
  151 +
  152 + }
  153 +
166 return HLLAPI_STATUS_SUCCESS; 154 return HLLAPI_STATUS_SUCCESS;
167 } 155 }
168 156
  157 +
  158 + /*
  159 +
169 HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds) 160 HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds)
170 { 161 {
171 if(!hllapi_is_connected()) 162 if(!hllapi_is_connected())
@@ -186,14 +177,6 @@ @@ -186,14 +177,6 @@
186 return hllapi_get_state(); 177 return hllapi_get_state();
187 } 178 }
188 179
189 - HLLAPI_API_CALL hllapi_get_message_id(void)  
190 - {  
191 - if(!hllapi_is_connected())  
192 - return HLLAPI_STATUS_DISCONNECTED;  
193 -  
194 - return session::get_default()->get_program_message();  
195 - }  
196 -  
197 HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer) 180 HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer)
198 { 181 {
199 if(!hllapi_is_connected()) 182 if(!hllapi_is_connected())
@@ -765,44 +748,40 @@ @@ -765,44 +748,40 @@
765 break; 748 break;
766 749
767 750
768 -/*  
769 -  
770 -Global Const PC_TEST = "@A@C"  
771 -Global Const PC_WORDDELETE = "@A@D"  
772 -Global Const PC_FIELDEXIT = "@A@E"  
773 -Global Const PC_ERASEINPUT = "@A@F"  
774 -Global Const PC_SYSTEMREQUEST = "@A@H"  
775 -Global Const PC_INSERTTOGGLE = "@A@I"  
776 -Global Const PC_CURSORSELECT = "@A@J"  
777 -Global Const PC_CURSLEFTFAST = "@A@L"  
778 -Global Const PC_GETCURSOR = "@A@N"  
779 -Global Const PC_LOCATECURSOR = "@A@O"  
780 -Global Const PC_ATTENTION = "@A@Q"  
781 -Global Const PC_DEVICECANCEL = "@A@R"  
782 -Global Const PC_PRINTPS = "@A@T"  
783 -Global Const PC_CURSUPFAST = "@A@U"  
784 -Global Const PC_CURSDOWNFAST = "@A@V"  
785 -Global Const PC_HEX = "@A@X"  
786 -Global Const PC_FUNCTIONKEY = "@A@Y"  
787 -Global Const PC_CURSRIGHTFAST = "@A@Z"  
788 -  
789 -Global Const PC_REVERSEVIDEO = "@A@9"  
790 -Global Const PC_UNDERSCORE = "@A@b"  
791 -Global Const PC_BLINK = "@A@c"  
792 -Global Const PC_RED = "@A@d"  
793 -Global Const PC_PINK = "@A@e"  
794 -Global Const PC_GREEN = "@A@f"  
795 -Global Const PC_YELLOW = "@A@g"  
796 -Global Const PC_BLUE = "@A@h"  
797 -Global Const PC_TURQOISE = "@A@i"  
798 -Global Const PC_WHITE = "@A@j"  
799 -Global Const PC_RSTHOSTCOLORS = "@A@l"  
800 -Global Const PC_PRINTPC = "@A@t"  
801 -  
802 -Global Const PC_FIELDMINUS = "@A@-"  
803 -Global Const PC_FIELDPLUS = "@A@+"  
804 -  
805 -*/ 751 +// Global Const PC_TEST = "@A@C"
  752 +// Global Const PC_WORDDELETE = "@A@D"
  753 +// Global Const PC_FIELDEXIT = "@A@E"
  754 +// Global Const PC_ERASEINPUT = "@A@F"
  755 +// Global Const PC_SYSTEMREQUEST = "@A@H"
  756 +// Global Const PC_INSERTTOGGLE = "@A@I"
  757 +// Global Const PC_CURSORSELECT = "@A@J"
  758 +// Global Const PC_CURSLEFTFAST = "@A@L"
  759 +// Global Const PC_GETCURSOR = "@A@N"
  760 +// Global Const PC_LOCATECURSOR = "@A@O"
  761 +// Global Const PC_ATTENTION = "@A@Q"
  762 +// Global Const PC_DEVICECANCEL = "@A@R"
  763 +// Global Const PC_PRINTPS = "@A@T"
  764 +// Global Const PC_CURSUPFAST = "@A@U"
  765 +// Global Const PC_CURSDOWNFAST = "@A@V"
  766 +// Global Const PC_HEX = "@A@X"
  767 +// Global Const PC_FUNCTIONKEY = "@A@Y"
  768 +// Global Const PC_CURSRIGHTFAST = "@A@Z"
  769 +
  770 +// Global Const PC_REVERSEVIDEO = "@A@9"
  771 +// Global Const PC_UNDERSCORE = "@A@b"
  772 +// Global Const PC_BLINK = "@A@c"
  773 +// Global Const PC_RED = "@A@d"
  774 +// Global Const PC_PINK = "@A@e"
  775 +// Global Const PC_GREEN = "@A@f"
  776 +// Global Const PC_YELLOW = "@A@g"
  777 +// Global Const PC_BLUE = "@A@h"
  778 +// Global Const PC_TURQOISE = "@A@i"
  779 +// Global Const PC_WHITE = "@A@j"
  780 +// Global Const PC_RSTHOSTCOLORS = "@A@l"
  781 +// Global Const PC_PRINTPC = "@A@t"
  782 +
  783 +// Global Const PC_FIELDMINUS = "@A@-"
  784 +// Global Const PC_FIELDPLUS = "@A@+"
806 785
807 } 786 }
808 787
@@ -824,3 +803,4 @@ Global Const PC_FIELDPLUS = &quot;@A@+&quot; @@ -824,3 +803,4 @@ Global Const PC_FIELDPLUS = &quot;@A@+&quot;
824 return rc; 803 return rc;
825 } 804 }
826 805
  806 +*/
src/core/controller.cc 0 → 100644
@@ -0,0 +1,97 @@ @@ -0,0 +1,97 @@
  1 +/*
  2 + * "Software pw3270, 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 GNU, 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., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como - 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 Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include "private.h"
  31 +
  32 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  33 +
  34 + static TN3270::Host * hllapi_host = nullptr;
  35 + static time_t hllapi_timeout = 120;
  36 + std::string hllapi_lasterror = "";
  37 +
  38 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  39 +
  40 + HLLAPI_API_CALL hllapi_init(LPSTR id)
  41 + {
  42 + trace("%s(%s)",__FUNCTION__,id);
  43 +
  44 + try
  45 + {
  46 + if(hllapi_host)
  47 + delete hllapi_host;
  48 +
  49 + hllapi_host = new TN3270::Host(*id ? id : nullptr,nullptr,hllapi_timeout);
  50 +
  51 + }
  52 + catch(std::exception &e)
  53 + {
  54 + hllapi_lasterror = e.what();
  55 + return HLLAPI_STATUS_SYSTEM_ERROR;
  56 + }
  57 +
  58 + return HLLAPI_STATUS_SUCCESS;
  59 +
  60 + }
  61 +
  62 + HLLAPI_API_CALL hllapi_deinit(void)
  63 + {
  64 + trace("%s()",__FUNCTION__);
  65 +
  66 + try
  67 + {
  68 + if(hllapi_host)
  69 + {
  70 + delete hllapi_host;
  71 + hllapi_host = NULL;
  72 + }
  73 +
  74 + }
  75 + catch(std::exception &e)
  76 + {
  77 + hllapi_lasterror = e.what();
  78 + return HLLAPI_STATUS_SYSTEM_ERROR;
  79 + }
  80 +
  81 + return HLLAPI_STATUS_SUCCESS;
  82 + }
  83 +
  84 + TN3270::Host & getSession() {
  85 +
  86 + if(!hllapi_host) {
  87 + throw runtime_error("Not initialized");
  88 + }
  89 +
  90 + return *hllapi_host;
  91 +
  92 + }
  93 +
  94 + HLLAPI_API_CSTR hllapi_get_last_error() {
  95 + return hllapi_lasterror.c_str();
  96 + }
  97 +
src/core/environ.bat
@@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
1 -@echo off  
2 -  
3 -set VC=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC  
4 -set WINSDK=C:\Program Files (x86)\Windows Kits\8.1  
5 -set PATH=%PATH%;"%VC%\bin";"%WINSDK%\bin\x86\"  
6 -  
src/core/hllapi.cbp
@@ -1,89 +0,0 @@ @@ -1,89 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>  
2 -<CodeBlocks_project_file>  
3 - <FileVersion major="1" minor="6" />  
4 - <Project>  
5 - <Option title="pw3270 HLLAPI" />  
6 - <Option makefile_is_custom="1" />  
7 - <Option pch_mode="2" />  
8 - <Option compiler="gcc" />  
9 - <Build>  
10 - <Target title="Debug">  
11 - <Option output=".bin/Debug/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />  
12 - <Option object_output=".obj/Debug/" />  
13 - <Option type="1" />  
14 - <Option compiler="gcc" />  
15 - <Compiler>  
16 - <Add option="-g" />  
17 - </Compiler>  
18 - <MakeCommands>  
19 - <Build command="$make LIB3270_MODE=Debug -f $makefile $target" />  
20 - <CompileFile command="$make -f $makefile $file" />  
21 - <Clean command="$make -f $makefile clean$target" />  
22 - <DistClean command="$make -f $makefile distclean$target" />  
23 - <AskRebuildNeeded command="$make -q -f $makefile $target" />  
24 - <SilentBuild command="$make LIB3270_MODE=Debug -f $makefile $target &gt; $(CMD_NULL)" />  
25 - </MakeCommands>  
26 - </Target>  
27 - <Target title="Release">  
28 - <Option output=".bin/Release/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />  
29 - <Option object_output=".obj/Release/" />  
30 - <Option type="1" />  
31 - <Option compiler="gcc" />  
32 - <Compiler>  
33 - <Add option="-O2" />  
34 - </Compiler>  
35 - <Linker>  
36 - <Add option="-s" />  
37 - </Linker>  
38 - </Target>  
39 - <Target title="test">  
40 - <Option output=".bin/Debug/test" prefix_auto="1" extension_auto="1" />  
41 - <Option object_output=".obj/Debug/" />  
42 - <Option type="1" />  
43 - <Option compiler="gcc" />  
44 - <Compiler>  
45 - <Add option="-g" />  
46 - </Compiler>  
47 - <Environment>  
48 - <Variable name="LIB3270_CFLAGS" value='&quot;-I../../../src/include&quot;' />  
49 - <Variable name="LIB3270_LIBS" value='&quot;-L../../../.bin/Debug -l3270&quot;' />  
50 - <Variable name="PW3270_LIBS" value='&quot;-L../../../.bin/Debug -lpw3270 -l3270&quot;' />  
51 - </Environment>  
52 - <MakeCommands>  
53 - <Build command="$make LIB3270_MODE=Debug -f $makefile $target" />  
54 - <CompileFile command="$make -f $makefile $file" />  
55 - <Clean command="$make -f $makefile clean$target" />  
56 - <DistClean command="$make -f $makefile distclean$target" />  
57 - <AskRebuildNeeded command="$make -q -f $makefile $target" />  
58 - <SilentBuild command="$make LIB3270_MODE=Debug -f $makefile $target &gt; $(CMD_NULL)" />  
59 - </MakeCommands>  
60 - </Target>  
61 - </Build>  
62 - <Compiler>  
63 - <Add option="-Wall" />  
64 - </Compiler>  
65 - <Unit filename="../../include/lib3270.h" />  
66 - <Unit filename="../../include/pw3270/hllapi.h" />  
67 - <Unit filename="../../include/pw3270cpp.h" />  
68 - <Unit filename="Makefile.in" />  
69 - <Unit filename="calls.cc" />  
70 - <Unit filename="client.h" />  
71 - <Unit filename="hllapi.c">  
72 - <Option compilerVar="CC" />  
73 - </Unit>  
74 - <Unit filename="pluginmain.c">  
75 - <Option compilerVar="CC" />  
76 - </Unit>  
77 - <Unit filename="remotectl.h" />  
78 - <Unit filename="server.h" />  
79 - <Unit filename="testprogram.c">  
80 - <Option compilerVar="CC" />  
81 - </Unit>  
82 - <Extensions>  
83 - <code_completion />  
84 - <envvars />  
85 - <debugger />  
86 - <lib_finder disable_auto="1" />  
87 - </Extensions>  
88 - </Project>  
89 -</CodeBlocks_project_file>  
src/core/hllapi.cc
@@ -27,15 +27,7 @@ @@ -27,15 +27,7 @@
27 * 27 *
28 */ 28 */
29 29
30 - #include <lib3270.h>  
31 - #include <malloc.h>  
32 - #include <string.h>  
33 - #include <errno.h>  
34 - #include <pw3270/hllapi.h>  
35 - #include <stdio.h>  
36 - #include <time.h>  
37 - #include <lib3270/log.h>  
38 - #include "client.h" 30 + #include <lib3270/hllapi.h>
39 31
40 /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ 32 /*--[ Prototipes ]-----------------------------------------------------------------------------------*/
41 33
@@ -92,6 +84,7 @@ @@ -92,6 +84,7 @@
92 84
93 /*--[ Implement ]------------------------------------------------------------------------------------*/ 85 /*--[ Implement ]------------------------------------------------------------------------------------*/
94 86
  87 +/*
95 HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc) 88 HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)
96 { 89 {
97 unsigned int f; 90 unsigned int f;
@@ -200,27 +193,27 @@ static int input_string(char *buffer, unsigned short *length, unsigned short *rc @@ -200,27 +193,27 @@ static int input_string(char *buffer, unsigned short *length, unsigned short *rc
200 193
201 static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) 194 static int search_ps(char *buffer, unsigned short *length, unsigned short *ps)
202 { 195 {
203 - /*  
204 - * Data String Target string for search.  
205 - * Length Length of the target data string. Overridden in EOT mode.  
206 - * PS Position Position within the host presentation space where the search is to begin (SRCHFRWD option) or to end  
207 - * (SRCHBKWD option). Overridden in SRCHALL (default) mode.  
208 - *  
209 - * Return in *ps:  
210 - *  
211 - * = 0 The string was not found.  
212 - * > 0 The string was found at the indicated host presentation space position.  
213 - *  
214 - * Return code:  
215 - *  
216 - * 0 The Search Presentation Space function was successful.  
217 - * 1 Your program is not connected to a host session.  
218 - * 2 An error was made in specifying parameters.  
219 - * 7 The host presentation space position is not valid.  
220 - * 9 A system error was encountered.  
221 - * 24 The search string was not found.  
222 - *  
223 - */ 196 + //
  197 + // Data String Target string for search.
  198 + // Length Length of the target data string. Overridden in EOT mode.
  199 + // PS Position Position within the host presentation space where the search is to begin (SRCHFRWD option) or to end
  200 + // (SRCHBKWD option). Overridden in SRCHALL (default) mode.
  201 + //
  202 + // Return in *ps:
  203 + //
  204 + // = 0 The string was not found.
  205 + // > 0 The string was found at the indicated host presentation space position.
  206 + //
  207 + // Return code:
  208 + //
  209 + // 0 The Search Presentation Space function was successful.
  210 + // 1 Your program is not connected to a host session.
  211 + // 2 An error was made in specifying parameters.
  212 + // 7 The host presentation space position is not valid.
  213 + // 9 A system error was encountered.
  214 + // 24 The search string was not found.
  215 + //
  216 + //
224 size_t szBuffer = strlen(buffer); 217 size_t szBuffer = strlen(buffer);
225 char * text; 218 char * text;
226 int rc = HLLAPI_STATUS_SYSTEM_ERROR; 219 int rc = HLLAPI_STATUS_SYSTEM_ERROR;
@@ -256,22 +249,22 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) @@ -256,22 +249,22 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps)
256 249
257 static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) 250 static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc)
258 { 251 {
259 - /*  
260 - * Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space is configured. When the Set Session Parameters (9) function with the EAB option is issued, the length of the data string must be at least twice the length of the presentation space.  
261 - * DBCS Only: When the EAD option is specified, the length of the data string must be at least three times the length of the presentation space. When both the EAB and EAD options are specified, the length of the data string must be at least four times the length of the presentation space.  
262 - *  
263 - * Length NA (the length of the host presentation space is implied).  
264 - * PS Position NA.  
265 - *  
266 - * Return values:  
267 - *  
268 - * 0 The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.  
269 - * 1 Your program is not connected to a host session.  
270 - * 4 The host presentation space contents were copied. The connected host presentation space was waiting for host response.  
271 - * 5 The host presentation space was copied. The keyboard was locked.  
272 - * 9 A system error was encountered.  
273 - *  
274 - */ 252 + //
  253 + // Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space is configured. When the Set Session Parameters (9) function with the EAB option is issued, the length of the data string must be at least twice the length of the presentation space.
  254 + // DBCS Only: When the EAD option is specified, the length of the data string must be at least three times the length of the presentation space. When both the EAB and EAD options are specified, the length of the data string must be at least four times the length of the presentation space.
  255 + //
  256 + // Length NA (the length of the host presentation space is implied).
  257 + // PS Position NA.
  258 + //
  259 + // Return values:
  260 + //
  261 + // 0 The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.
  262 + // 1 Your program is not connected to a host session.
  263 + // 4 The host presentation space contents were copied. The connected host presentation space was waiting for host response.
  264 + // 5 The host presentation space was copied. The keyboard was locked.
  265 + // 9 A system error was encountered.
  266 + //
  267 + //
275 size_t szBuffer = strlen(buffer); 268 size_t szBuffer = strlen(buffer);
276 char * text; 269 char * text;
277 270
@@ -292,40 +285,23 @@ static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) @@ -292,40 +285,23 @@ static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc)
292 285
293 static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) 286 static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)
294 { 287 {
295 - /*  
296 - * Checks the status of the host-connected presentation space. If the session is  
297 - * waiting for a host response (indicated by XCLOCK (X []) or XSYSTEM), the Wait  
298 - * function causes HLLAPI to wait up to 1 minute to see if the condition clears.  
299 - *  
300 - */  
301 -  
302 - /*  
303 - * Return Code Definition  
304 - *  
305 - * HLLAPI_STATUS_SUCCESS 0 The keyboard is unlocked and ready for input.  
306 - * HLLAPI_STATUS_DISCONNECTED 1 Your application program is not connected to a valid session.  
307 - * HLLAPI_STATUS_TIMEOUT 4 Timeout while still in XCLOCK (X []) or XSYSTEM.  
308 - * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The keyboard is locked.  
309 - * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.  
310 - *  
311 - */  
312 -  
313 - /*  
314 - time_t end = time(0) + 60;  
315 -  
316 - while(time(0) < end)  
317 - {  
318 - int state = hllapi_get_state();  
319 -  
320 - if(state != HLLAPI_STATUS_WAITING)  
321 - return state;  
322 -  
323 - hllapi_wait(1);  
324 -  
325 - }  
326 -  
327 - return HLLAPI_STATUS_TIMEOUT;  
328 - */ 288 + //
  289 + // Checks the status of the host-connected presentation space. If the session is
  290 + // waiting for a host response (indicated by XCLOCK (X []) or XSYSTEM), the Wait
  291 + // function causes HLLAPI to wait up to 1 minute to see if the condition clears.
  292 + //
  293 + //
  294 +
  295 + //
  296 + // Return Code Definition
  297 + //
  298 + // HLLAPI_STATUS_SUCCESS 0 The keyboard is unlocked and ready for input.
  299 + // HLLAPI_STATUS_DISCONNECTED 1 Your application program is not connected to a valid session.
  300 + // HLLAPI_STATUS_TIMEOUT 4 Timeout while still in XCLOCK (X []) or XSYSTEM.
  301 + // HLLAPI_STATUS_KEYBOARD_LOCKED 5 The keyboard is locked.
  302 + // HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.
  303 + //
  304 + //
329 305
330 int state = hllapi_wait_for_ready(60); 306 int state = hllapi_wait_for_ready(60);
331 return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state); 307 return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state);
@@ -334,24 +310,24 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) @@ -334,24 +310,24 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)
334 310
335 static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps) 311 static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps)
336 { 312 {
337 - /*  
338 - * Call Parameters  
339 - *  
340 - * Data String of ASCII data to be copied into the host presentation space.  
341 - * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode.  
342 - * PS Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space.  
343 - *  
344 - * Return Parameters  
345 - *  
346 - * HLLAPI_STATUS_SUCCESS 0 The Copy String to Presentation Space function was successful.  
347 - * HLLAPI_STATUS_DISCONNECTED 1 Your program is not connected to a host session.  
348 - * HLLAPI_STATUS_BAD_PARAMETER 2 Parameter error or zero length for copy.  
349 - * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte).  
350 - * 6 The copy was completed, but the data was truncated.  
351 - * 7 The host presentation space position is not valid.  
352 - * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.  
353 - *  
354 - */ 313 + //
  314 + // Call Parameters
  315 + //
  316 + // Data String of ASCII data to be copied into the host presentation space.
  317 + // Length Length, in number of bytes, of the source data string. Overridden if in EOT mode.
  318 + // PS Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space.
  319 + //
  320 + // Return Parameters
  321 + //
  322 + // HLLAPI_STATUS_SUCCESS 0 The Copy String to Presentation Space function was successful.
  323 + // HLLAPI_STATUS_DISCONNECTED 1 Your program is not connected to a host session.
  324 + // HLLAPI_STATUS_BAD_PARAMETER 2 Parameter error or zero length for copy.
  325 + // HLLAPI_STATUS_KEYBOARD_LOCKED 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte).
  326 + // 6 The copy was completed, but the data was truncated.
  327 + // 7 The host presentation space position is not valid.
  328 + // HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.
  329 + //
  330 + //
355 size_t szText = strlen(text); 331 size_t szText = strlen(text);
356 332
357 if(*length < szText) 333 if(*length < szText)
@@ -464,3 +440,4 @@ HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value) @@ -464,3 +440,4 @@ HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value)
464 440
465 return HLLAPI_STATUS_SUCCESS; 441 return HLLAPI_STATUS_SUCCESS;
466 } 442 }
  443 +*/
src/core/idlcomp.bat
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -@echo off  
2 -  
3 -midl.exe /I "%WINSDK%\Include\um" /I "%WINSDK%\Include\shared" /cpp_cmd "cl.exe" pw3270.idl  
src/core/private.h 0 → 100644
@@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
  1 +/*
  2 + * "Software pw3270, 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 GNU, 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., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como - 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 Mendonça)
  27 + *
  28 + */
  29 +
  30 +#ifndef PRIVATE_H_INCLUDED
  31 +
  32 + #define PRIVATE_H_INCLUDED 1
  33 +
  34 + #include <exception>
  35 + #include <stdexcept>
  36 + #include <string>
  37 + #include <cerrno>
  38 + #include <cstring>
  39 + #include <lib3270/ipc.h>
  40 + #include <lib3270/log.h>
  41 + #include <lib3270/hllapi.h>
  42 +
  43 + using std::runtime_error;
  44 + using std::string;
  45 +
  46 + extern string hllapi_lasterror;
  47 +
  48 + TN3270::Host & getSession();
  49 +
  50 +#endif // PRIVATE_H_INCLUDED
src/core/remotectl.h
@@ -1,84 +0,0 @@ @@ -1,84 +0,0 @@
1 -/*  
2 - * "Software pw3270, 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. 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 GNU, 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 remotectl.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 Mendonça)  
27 - *  
28 - * Agradecimento:  
29 - *  
30 - * Hélio Passos  
31 - *  
32 - */  
33 -  
34 - #define ENABLE_NLS  
35 - #define GETTEXT_PACKAGE PACKAGE_NAME  
36 -  
37 - #include <libintl.h>  
38 - #include <glib/gi18n.h>  
39 - #include <gtk/gtk.h>  
40 -  
41 - #include <lib3270.h>  
42 - #include <lib3270/log.h>  
43 - #include <pw3270/hllapi.h>  
44 -  
45 - typedef struct _remotequery  
46 - {  
47 -#ifdef _WIN32  
48 - HANDLE hPipe; /**< Pipe handle (for response) */  
49 -#endif // _WIN32  
50 -  
51 - H3270 * hSession; /**< 3270 Session */  
52 - int cmd; /**< Command */  
53 - int rc; /**< Response status */  
54 -  
55 - int pos;  
56 - unsigned short length; /**< Query string length */  
57 - const gchar * text; /**< Query string */  
58 -  
59 - } QUERY;  
60 -  
61 - G_GNUC_INTERNAL void enqueue_request(QUERY *qry);  
62 - G_GNUC_INTERNAL void request_complete(QUERY *qry, int rc, const gchar *text);  
63 -  
64 - G_GNUC_INTERNAL void request_status(QUERY *qry, int rc);  
65 - G_GNUC_INTERNAL void request_value(QUERY *qry, int rc, unsigned int value);  
66 - G_GNUC_INTERNAL void request_buffer(QUERY *qry, int rc, size_t sz, const gpointer buffer);  
67 -  
68 -// int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc);  
69 -  
70 -  
71 -#ifdef _WIN32  
72 -  
73 - #define PIPE_BUFFER_LENGTH 8192  
74 -  
75 - void init_source_pipe(HANDLE hPipe);  
76 - void popup_lasterror(const gchar *fmt, ...);  
77 -  
78 -#endif // _WIN32  
79 -  
80 -  
81 -  
82 -  
83 -  
84 -  
src/include/lib3270/hllapi.h
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple 18 * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA, 02111-1307, USA 19 * Place, Suite 330, Boston, MA, 02111-1307, USA
20 * 20 *
21 - * Este programa está nomeado como private.h e possui - linhas de código. 21 + * Este programa está nomeado como - e possui - linhas de código.
22 * 22 *
23 * Contatos: 23 * Contatos:
24 * 24 *
@@ -27,27 +27,186 @@ @@ -27,27 +27,186 @@
27 * 27 *
28 */ 28 */
29 29
30 - #include <pw3270/hllapi.h> 30 + #ifdef __cplusplus
  31 + extern "C" {
  32 + #endif
31 33
32 - #ifndef ETIMEDOUT  
33 - #define ETIMEDOUT 1238  
34 - #endif // ETIMEDOUT 34 + #define HLLAPI_MAXLENGTH 4096
35 35
36 - #define PIPE_BUFFER_LENGTH 8192 36 + /**
  37 + * @brief Function codes
  38 + *
  39 + * Reference http://www.ibm.com/support/knowledgecenter/SSEQ5Y_6.0.0/com.ibm.pcomm.doc/books/html/emulator_programming08.htm
  40 + *
  41 + */
  42 + typedef enum hllapi_cmd {
  43 + HLLAPI_CMD_CONNECTPS = 1, /// @brief connect presentation space
  44 + HLLAPI_CMD_DISCONNECTPS = 2, /// @brief disconnect presentation space
  45 + HLLAPI_CMD_INPUTSTRING = 3, /// @brief send string
  46 + HLLAPI_CMD_WAIT = 4, /// @brief Wait if the session is waiting for a host response
  47 + HLLAPI_CMD_COPYPS = 5, /// @brief Copies the contents of the presentation space into a string buffer.
  48 + HLLAPI_CMD_SEARCHPS = 6, /// @brief Search the presentation space for a specified string.
  49 + HLLAPI_CMD_QUERYCURSOR = 7, /// @brief Determines the location of the cursor in the presentation space.
  50 + HLLAPI_CMD_COPYPSTOSTR = 8, /// @brief Copy presentation space to string
  51 + HLLAPI_SET_SESSION_PARAMETERS = 9, /// @brief Lets you change certain default session options in EHLLAPI for all sessions.
  52 + HLLAPI_CMD_COPYSTRTOPS = 15, /// @brief Copies an ASCII string directly to a specified position in the presentation space.
  53 + HLLAPI_CMD_PAUSE = 18, /// @brief Waits for a specified amount of time.
  54 + HLLAPI_RESET_SYSTEM = 21, /// @brief Reinitializes EHLLAPI to its starting state.
  55 + HLLAPI_CMD_SETCURSOR = 40, /// @brief Places the cursor at a specified position in presentation space.
  56 + HLLAPI_CMD_SENDFILE = 90, /// @brief Send file to the host
  57 + HLLAPI_CMD_RECEIVEFILE = 91, /// @brief Receive a file from the host
37 58
38 - #define set_active(x) /* x */ 59 + HLLAPI_CMD_GETREVISION = 2000 /// @brief Get lib3270 revision
  60 + } HLLAPI_CMD;
39 61
40 - #if defined(DEBUG) && defined(_WIN32)  
41 - #undef trace  
42 - #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);  
43 - #endif // DEBUG  
44 62
45 - #ifdef __cplusplus  
46 - extern "C" {  
47 - #endif 63 + /**
  64 + * @brief Standard Return Codes
  65 + *
  66 + * http://ps-2.kev009.com/tl/techlib/manuals/adoclib/3270hcon/hconugd/retrncod.htm#C20819C058kmar
  67 + */
  68 + typedef enum hllapi_status {
  69 +
  70 + /// @brief Good return code.
  71 + ///
  72 + /// Either the function was successfully executed, or there were no host updates since the last call was issued.
  73 + HLLAPI_STATUS_SUCCESS = 0,
  74 +
  75 + /// @brief The presentation space was not valid or not connected.
  76 + ///
  77 + /// Either the presentation space short session ID was invalid, or the application is not connected.
  78 + HLLAPI_STATUS_DISCONNECTED = 1,
  79 +
  80 + /// @brief An incorrect option was specified.
  81 + HLLAPI_STATUS_BAD_PARAMETER = 2,
  82 +
  83 + /// @brief The execution of the function was inhibited because the target presentation space was busy.
  84 + ///
  85 + /// For example, X or XSYSTEM is displayed in the OIA for the 3270 terminal emulation.
  86 + HLLAPI_STATUS_TIMEOUT = 4,
  87 +
  88 + /// @brief The execution of the function was inhibited for some reason other than the reasons stated in return code 4.
  89 + HLLAPI_STATUS_KEYBOARD_LOCKED = 5,
  90 +
  91 + // 06 A data error occurred due to specification of an invalid parameter (for example, a length error causing truncation).
  92 + // 07 The specified presentation space position was invalid.
  93 + // 08 No prerequisite function was issued.
  94 +
  95 + /// @brief A system error occurred.
  96 + HLLAPI_STATUS_SYSTEM_ERROR = 9,
  97 +
  98 + /// @brief The function number is not supported by the emulation program.
  99 + HLLAPI_STATUS_UNSUPPORTED = 10,
  100 +
  101 + /// @brief Resource unavailable at this time.
  102 + ///
  103 + /// The resource that you requested is unavailable (for example, too many attempts have been made to connect to the same presentation space (PS) or another application is connected to the PS).
  104 + HLLAPI_STATUS_UNAVAILABLE = 11,
  105 +
  106 + // 20 Invalid keystroke caused by ESC= option.
  107 + // 21 OIA was updated.
  108 + // 22 PS was updated.
  109 + // 23 Both OIA and PS were updated.
  110 +
  111 + /// @brief Either the string was not found, or the presentation space is unformatted.
  112 + HLLAPI_STATUS_NOT_FOUND = 24,
  113 +
  114 + // 25 Keystrokes were not available on input queue.
  115 + // 26 A host event occurred. See QUERY HOST UPDATE (24) for details.
  116 + // 28 Field length was 0.
  117 + // 31 Keystroke queue overflow. Keystrokes were lost.
  118 +
  119 + } HLLAPI_STATUS;
  120 +
  121 + #define HLLAPI_STATUS_WAITING HLLAPI_STATUS_TIMEOUT
  122 +
  123 + #if defined(_WIN32)
  124 +
  125 + #include <windows.h>
  126 +
  127 + // http://www.mingw.org/wiki/Visual_Basic_DLL
  128 + #define HLLAPI_API_CALL __declspec (dllexport) DWORD __stdcall
  129 + #define HLLAPI_API_CSTR __declspec (dllexport) const char * __stdcall
  130 +
  131 + #else
  132 +
  133 + #include <cstdint>
  134 +
  135 + // From wtypesbase.h
  136 + typedef uint8_t BYTE;
  137 + typedef uint16_t WORD;
  138 + typedef unsigned int UINT;
  139 + typedef int INT;
  140 + typedef uint32_t LONG;
  141 + typedef LONG WINBOOL;
  142 + typedef uint32_t DWORD;
  143 + typedef void *HANDLE;
  144 + typedef WORD *LPWORD;
  145 + typedef DWORD *LPDWORD;
  146 + typedef char CHAR;
  147 + typedef CHAR *LPSTR;
  148 + typedef const CHAR *LPCSTR;
  149 + typedef char WCHAR;
  150 + typedef WCHAR TCHAR;
  151 + typedef WCHAR *LPWSTR;
  152 + typedef TCHAR *LPTSTR;
  153 + typedef const WCHAR *LPCWSTR;
  154 + typedef const TCHAR *LPCTSTR;
  155 + typedef HANDLE *LPHANDLE;
  156 +
  157 + #define LPWORD uint16_t *
  158 +
  159 + #define LPSTR char *
  160 + #define HANDLE int
  161 +
  162 + #define HLLAPI_API_CALL __attribute__((visibility("default"))) extern DWORD
  163 + #define HLLAPI_API_CSTR __attribute__((visibility("default"))) extern const char *
  164 +
  165 + #endif // _WIN32
  166 +
  167 + HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc);
  168 +
  169 + HLLAPI_API_CALL hllapi_init(LPSTR mode);
  170 + HLLAPI_API_CALL hllapi_deinit(void);
  171 + HLLAPI_API_CALL hllapi_get_revision(void);
  172 +
  173 + HLLAPI_API_CALL hllapi_reset(void);
  174 +
  175 + HLLAPI_API_CALL hllapi_connect(const LPSTR uri, WORD wait);
  176 + HLLAPI_API_CALL hllapi_disconnect(void);
  177 +
  178 + HLLAPI_API_CALL hllapi_get_message_id(void);
  179 + HLLAPI_API_CALL hllapi_is_connected(void);
  180 + HLLAPI_API_CALL hllapi_get_state(void);
  181 + HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer);
  182 + HLLAPI_API_CALL hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
  183 + HLLAPI_API_CALL hllapi_enter(void);
  184 + HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text);
  185 + HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
  186 + HLLAPI_API_CALL hllapi_find_text(LPSTR text);
  187 + HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting);
  188 + HLLAPI_API_CALL hllapi_input_string(LPSTR buffer, WORD len);
  189 + HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds);
  190 + HLLAPI_API_CALL hllapi_wait_for_change(WORD seconds);
  191 + HLLAPI_API_CALL hllapi_wait(WORD seconds);
  192 + HLLAPI_API_CALL hllapi_pfkey(WORD key);
  193 + HLLAPI_API_CALL hllapi_pakey(WORD key);
  194 +
  195 + HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value);
  196 +
  197 + HLLAPI_API_CALL hllapi_erase(void);
  198 + HLLAPI_API_CALL hllapi_erase_eof(void);
  199 + HLLAPI_API_CALL hllapi_erase_eol(void);
  200 + HLLAPI_API_CALL hllapi_erase_input(void);
  201 +
  202 + HLLAPI_API_CALL hllapi_action(LPSTR buffer);
  203 +
  204 + HLLAPI_API_CALL hllapi_print(void);
  205 +
  206 + HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir);
  207 + HLLAPI_API_CALL hllapi_set_charset(LPSTR datadir);
48 208
49 - char * hllapi_get_string(int offset, size_t len);  
50 - void hllapi_free(void *p); 209 + HLLAPI_API_CSTR hllapi_get_last_error();
51 210
52 #ifdef __cplusplus 211 #ifdef __cplusplus
53 } /* end of extern "C" */ 212 } /* end of extern "C" */
src/testprogram/hllapi.c
@@ -1,185 +0,0 @@ @@ -1,185 +0,0 @@
1 -/*  
2 - * "Software pw3270, 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 GNU, 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., 59 Temple  
19 - * Place, Suite 330, Boston, MA, 02111-1307, USA  
20 - *  
21 - * Este programa está nomeado como testprogram.c 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 Mendonça)  
27 - *  
28 - */  
29 -  
30 - #include <stdio.h>  
31 - #include <string.h>  
32 - #include <time.h>  
33 - #include <getopt.h>  
34 - #include <pw3270/hllapi.h>  
35 -  
36 - #if defined(DEBUG) && defined(_WIN32)  
37 - #undef trace  
38 - #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } }  
39 - #endif // DEBUG  
40 -  
41 - #define MAX_DATA_SIZE 8000 //< Maximum data size for this application.  
42 -  
43 -// static CHAR hllapi_data[MAX_DATA_SIZE];  
44 -  
45 -/*---[ Implement ]--------------------------------------------------------------------------------*/  
46 -  
47 - /*  
48 - static void connect_ps(const char *session)  
49 - {  
50 - WORD len;  
51 - WORD fn = HLLAPI_CMD_CONNECTPS;  
52 - WORD rc = 0;  
53 -  
54 - strncpy(hllapi_data,session,MAX_DATA_SIZE);  
55 -  
56 - len = strlen(session);  
57 - hllapi(&fn,hllapi_data,&len,&rc);  
58 -  
59 - }  
60 - */  
61 -  
62 - int main(int argc, char **argv)  
63 - {  
64 - const char *host = NULL;  
65 - const char *session = "pw3270:A";  
66 -  
67 - #pragma GCC diagnostic push  
68 - static struct option options[] =  
69 - {  
70 - { "host", required_argument, 0, 'h' },  
71 - { "session-name", required_argument, 0, 'S' },  
72 - { 0, 0, 0, 0}  
73 - };  
74 - #pragma GCC diagnostic pop  
75 -  
76 - int long_index =0;  
77 - int opt;  
78 - while((opt = getopt_long(argc, argv, "h:S:", options, &long_index )) != -1)  
79 - {  
80 -  
81 - switch(opt)  
82 - {  
83 - case 'h':  
84 - host = optarg;  
85 - break;  
86 -  
87 - case 'S':  
88 - session = optarg;  
89 - break;  
90 -  
91 - }  
92 -  
93 - }  
94 -  
95 - int rc = hllapi_init((char *) session);  
96 - if(rc)  
97 - {  
98 - printf("hllapi_init returns with rc=%d\n",rc);  
99 - return rc;  
100 - }  
101 -  
102 - printf("Library revision is %d\n",(int) hllapi_get_revision());  
103 -  
104 - if(host) {  
105 -  
106 - printf("connect=%d\n",(int) hllapi_connect((char *) host,1));  
107 - printf("wait_for_ready=%d\n",(int) hllapi_wait_for_ready(10));  
108 - printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");  
109 -  
110 - printf("disconnect=%d\n",(int) hllapi_disconnect());  
111 - }  
112 -  
113 - printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");  
114 -  
115 - rc = hllapi_deinit();  
116 - printf("hllapi_deinit exits with rc=%d\n",rc);  
117 -  
118 - return 0;  
119 - }  
120 -  
121 -/*  
122 - int main(int numpar, char *param[])  
123 - {  
124 - char buffer[BUFFER_LENGTH];  
125 - unsigned short rc;  
126 - unsigned short len;  
127 - unsigned long fn;  
128 -  
129 - static const struct _cmd  
130 - {  
131 - const char * name;  
132 - unsigned short fn;  
133 - const char * arg;  
134 - } cmd[] =  
135 - {  
136 - { "GetRevision", HLLAPI_CMD_GETREVISION, " " },  
137 - { "ConnectPS", HLLAPI_CMD_CONNECTPS, "pw3270A" },  
138 - { "InputString", HLLAPI_CMD_INPUTSTRING, "test" },  
139 -  
140 - };  
141 -  
142 - int f;  
143 -  
144 -  
145 - for(f=0;f< (sizeof(cmd)/sizeof(struct _cmd)); f++)  
146 - {  
147 - len = strlen(cmd[f].arg);  
148 - memcpy(buffer,cmd[f].arg,len);  
149 - hllapi((LPWORD) &cmd[f].fn,buffer,&len,&rc);  
150 - printf("%s exits with rc=%d\n[%s]\n",cmd[f].name,rc,buffer);  
151 - }  
152 -  
153 - len = 80;  
154 - rc = 1040;  
155 - fn = HLLAPI_CMD_COPYPSTOSTR;  
156 - hllapi((LPWORD) &fn,buffer,&len,&rc);  
157 - printf("%s exits with rc=%d\n%s\n","HLLAPI_CMD_COPYPSTOSTR",rc,buffer);  
158 -  
159 - // Performance  
160 - len = strlen(cmd[0].arg);  
161 - memcpy(buffer,cmd[0].arg,len);  
162 - if(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0)  
163 - {  
164 - time_t end = time(0) + 5;  
165 - int qtd = 0;  
166 - do  
167 - {  
168 - qtd++;  
169 - } while(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0 && time(0)<end);  
170 - printf("%d interacoes em 5 segundos (rc=%d)\n",qtd,rc);  
171 -  
172 - }  
173 -  
174 - // Disconnect  
175 - len = 10;  
176 - rc = 1;  
177 - fn = HLLAPI_CMD_DISCONNECTPS;  
178 - *buffer = 0;  
179 - hllapi((LPWORD) &fn,buffer,&len,&rc);  
180 - printf("%s exits with rc=%d\n[%s]\n","HLLAPI_CMD_DISCONNECTPS",rc,buffer);  
181 -  
182 -  
183 - return 0;  
184 - }  
185 -*/  
src/testprogram/ipc3270c.c
@@ -1,236 +0,0 @@ @@ -1,236 +0,0 @@
1 -/*  
2 - * "Software pw3270, 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. Registro no INPI sob  
5 - * o nome G3270.  
6 - *  
7 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
8 - *  
9 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
10 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
11 - * Free Software Foundation.  
12 - *  
13 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
14 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
15 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
16 - * obter mais detalhes.  
17 - *  
18 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
19 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
20 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
21 - *  
22 - * Este programa está nomeado como testprogram.c e possui - linhas de código.  
23 - *  
24 - * Contatos:  
25 - *  
26 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
27 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
28 - *  
29 - */  
30 -  
31 -  
32 - /**  
33 - * @brief Test program for pw3270 HLLAPI compatibility plugin.  
34 - *  
35 - */  
36 -  
37 - #include <config.h>  
38 - #include <v3270.h>  
39 - #include <v3270/trace.h>  
40 - #include <pw3270/plugin.h>  
41 - #include <string.h>  
42 - #include <stdlib.h>  
43 - #include <pw3270.h>  
44 -  
45 - /*---[ Globals ]------------------------------------------------------------------------------------*/  
46 -  
47 - const gchar * plugin_path = ".bin/Debug";  
48 - const gchar * session_name = "pw3270";  
49 - const gchar * plugin_name = "ipc3270c." G_MODULE_SUFFIX;  
50 -  
51 - /*---[ Implement ]----------------------------------------------------------------------------------*/  
52 -  
53 - static void close_module(GtkWidget *widget, GModule *module)  
54 - {  
55 - g_message("Closing module %p",module);  
56 -  
57 - static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL;  
58 - if(!g_module_symbol(module,"pw3270_plugin_stop",(void **) &stop))  
59 - {  
60 - g_message("Can't get stop method from plugin: %s",g_module_error());  
61 - }  
62 - else  
63 - {  
64 - stop(gtk_widget_get_toplevel(widget),widget);  
65 - }  
66 -  
67 - g_module_close(module);  
68 - g_message("Module %p was closed",module);  
69 - }  
70 -  
71 - static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
72 - {  
73 - v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button));  
74 - }  
75 -  
76 - static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
77 - {  
78 - v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button));  
79 - }  
80 -  
81 - static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
82 - {  
83 - v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button));  
84 - }  
85 -  
86 - static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
87 - {  
88 - v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button));  
89 - }  
90 -  
91 - static void toggle_started_trace(GtkToggleToolButton *button, GModule *module)  
92 - {  
93 - if(!module)  
94 - return;  
95 -  
96 - GtkWidget * terminal = GTK_WIDGET(g_object_get_data(G_OBJECT(button),"terminal"));  
97 -  
98 - const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop");  
99 -  
100 - static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL;  
101 - if(!g_module_symbol(module,method_name,(void **) &call))  
102 - {  
103 - g_message("Can't get method \"%s\": %s",method_name,g_module_error());  
104 - return;  
105 - }  
106 -  
107 - g_message("Calling %s",method_name);  
108 - call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal));  
109 -  
110 - }  
111 -  
112 - static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback)  
113 - {  
114 - GtkToolItem * item = gtk_toggle_tool_button_new();  
115 - gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label);  
116 -  
117 - g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal);  
118 -  
119 - if(tooltip)  
120 - gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip);  
121 -  
122 - return item;  
123 - }  
124 -  
125 - static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {  
126 -  
127 - GtkWidget * window = gtk_application_window_new(app);  
128 - GtkWidget * terminal = v3270_new();  
129 - GtkWidget * notebook = gtk_notebook_new();  
130 - GModule * module = NULL;  
131 -  
132 - gtk_widget_set_name(window,session_name);  
133 - v3270_set_session_name(terminal, session_name);  
134 -  
135 - // Setup tabs  
136 - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal)));  
137 -  
138 - // Load plugin  
139 - {  
140 - g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL);  
141 -  
142 - g_message("Loading %s",plugin);  
143 -  
144 - module = g_module_open(plugin,G_MODULE_BIND_LOCAL);  
145 -  
146 - if(module)  
147 - {  
148 - g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module);  
149 - }  
150 - else  
151 - {  
152 - g_message("Can't open \"%s\": %s",plugin,g_module_error());  
153 - gtk_main_quit();  
154 - }  
155 -  
156 - }  
157 - // Create trace window  
158 - {  
159 - GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);  
160 - GtkWidget * trace = v3270_trace_new(terminal);  
161 - GtkWidget * toolbar = gtk_toolbar_new();  
162 - GtkToolItem * start = gtk_toggle_tool_button_new();  
163 -  
164 - gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL);  
165 -  
166 - g_object_set_data(G_OBJECT(start),"terminal",terminal);  
167 -  
168 - gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable");  
169 - g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module);  
170 - gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module");  
171 -  
172 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1);  
173 -  
174 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1);  
175 -  
176 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1);  
177 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1);  
178 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1);  
179 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1);  
180 -  
181 - gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0);  
182 - gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0);  
183 - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace"));  
184 - }  
185 -  
186 - // Setup and show main window  
187 - gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);  
188 - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500);  
189 - gtk_container_add(GTK_CONTAINER(window),notebook);  
190 - gtk_widget_show_all (window);  
191 -  
192 - // Setup title.  
193 - const gchar *url = lib3270_get_url(v3270_get_session(terminal));  
194 - if(url) {  
195 -  
196 - v3270_set_url(terminal,url);  
197 - v3270_reconnect(terminal);  
198 -  
199 - gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url);  
200 - gtk_window_set_title(GTK_WINDOW(window), title);  
201 - g_free(title);  
202 -  
203 - } else {  
204 -  
205 - gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal));  
206 -  
207 - }  
208 -  
209 -}  
210 -  
211 -int main (int argc, char **argv) {  
212 -  
213 - static const GOptionEntry app_options[] = {  
214 - { "plugin-path", 'P', 0, G_OPTION_ARG_STRING, &plugin_path, "Path for plugin search", NULL },  
215 - { "session-name", 'S', 0, G_OPTION_ARG_STRING, &session_name, "Session name", "pw3270" },  
216 - { "module", 'm', 0, G_OPTION_ARG_STRING, &plugin_name, "Module name", "ipc3270c." G_MODULE_SUFFIX },  
217 -  
218 - { NULL }  
219 - };  
220 -  
221 - GtkApplication *app;  
222 - int status;  
223 -  
224 - app = gtk_application_new("br.com.bb.ipc3270c",G_APPLICATION_FLAGS_NONE);  
225 -  
226 - g_application_add_main_option_entries(G_APPLICATION(app),app_options);  
227 - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL);  
228 -  
229 - status = g_application_run (G_APPLICATION (app), argc, argv);  
230 - g_object_unref (app);  
231 -  
232 - g_message("rc=%d",status);  
233 - return status;  
234 -  
235 -}  
236 -  
src/testprogram/testprogram.cc 0 → 100644
@@ -0,0 +1,107 @@ @@ -0,0 +1,107 @@
  1 +/*
  2 + * "Software pw3270, 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 GNU, 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., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como testprogram.cc 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 Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include <iostream>
  31 + #include <getopt.h>
  32 + #include <lib3270/hllapi.h>
  33 +
  34 + using namespace std;
  35 +
  36 +/*---[ Implement ]--------------------------------------------------------------------------------*/
  37 +
  38 + int main(int argc, char **argv) {
  39 +
  40 + const char *host = "";
  41 + const char *session = ""; // "pw3270:A";
  42 +
  43 + #pragma GCC diagnostic push
  44 + static struct option options[] =
  45 + {
  46 + { "host", required_argument, 0, 'h' },
  47 + { "session-name", required_argument, 0, 'S' },
  48 + { 0, 0, 0, 0}
  49 + };
  50 + #pragma GCC diagnostic pop
  51 +
  52 + int long_index =0;
  53 + int opt;
  54 + while((opt = getopt_long(argc, argv, "h:S:", options, &long_index )) != -1)
  55 + {
  56 +
  57 + switch(opt)
  58 + {
  59 + case 'h':
  60 + host = optarg;
  61 + break;
  62 +
  63 + case 'S':
  64 + session = optarg;
  65 + break;
  66 +
  67 + }
  68 +
  69 + }
  70 +
  71 + int rc = hllapi_init((char *) session);
  72 + if(rc) {
  73 + cout << "hllapi_init returns with rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl;
  74 + return rc;
  75 + }
  76 +
  77 + cout << "TN3270 library revision is " << ((int) hllapi_get_revision()) << endl;
  78 +
  79 + rc = hllapi_connect(host,1);
  80 + if(rc) {
  81 + cout << "hllapi_connect returns with rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl;
  82 + return rc;
  83 + }
  84 +
  85 + cout << "HLLAPI Last error was \"" << hllapi_get_last_error() << "\"" << endl;
  86 +
  87 + /*
  88 + printf("Library revision is %d\n",(int) hllapi_get_revision());
  89 +
  90 + if(host) {
  91 +
  92 + printf("connect=%d\n",(int) hllapi_connect((char *) host,1));
  93 + printf("wait_for_ready=%d\n",(int) hllapi_wait_for_ready(10));
  94 + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");
  95 +
  96 + printf("disconnect=%d\n",(int) hllapi_disconnect());
  97 + }
  98 +
  99 + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");
  100 + */
  101 +
  102 + rc = hllapi_deinit();
  103 + cout << "hllapi_deinit exits with rc=" << rc << endl;
  104 +
  105 + return 0;
  106 + }
  107 +
valgrind.suppression 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +{
  2 + libcrypt_FIPS_selftest
  3 + Memcheck:Cond
  4 + ...
  5 + fun:FIPS_selftest
  6 +}
  7 +
  8 +{
  9 + libcrypt_FIPS_mode_set
  10 + Memcheck:Cond
  11 + ...
  12 + fun:FIPS_mode_set
  13 +}
  14 +