Commit 694ca33b93aa5e0d3421460af051c58e5314cfa3
1 parent
5fa0fc68
Exists in
master
Mudando nome da lib para pw3270.
Showing
6 changed files
with
465 additions
and
465 deletions
Show diff stats
Makefile.in
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | # |
26 | 26 | |
27 | 27 | GLUELIB=lib3270-mono@DLLEXT@ |
28 | -LIBNAME=tn3270-sharp.dll | |
28 | +LIBNAME=pw3270-sharp.dll | |
29 | 29 | |
30 | 30 | #---[ Configuration values ]------------------------------------------------------------- |
31 | 31 | |
... | ... | @@ -84,9 +84,9 @@ Release: \ |
84 | 84 | $(BINRLS)/$(LIBNAME) |
85 | 85 | |
86 | 86 | zip: \ |
87 | - tn3270-sharp-@PACKAGE_VERSION@.@host@.zip | |
87 | + pw3270-sharp-@PACKAGE_VERSION@.@host@.zip | |
88 | 88 | |
89 | -tn3270-sharp-@PACKAGE_VERSION@.@host@.zip: \ | |
89 | +pw3270-sharp-@PACKAGE_VERSION@.@host@.zip: \ | |
90 | 90 | $(BINRLS)/$(GLUELIB) \ |
91 | 91 | $(BINRLS)/$(LIBNAME) \ |
92 | 92 | $(BINRLS)/sample.exe |
... | ... | @@ -96,7 +96,7 @@ tn3270-sharp-@PACKAGE_VERSION@.@host@.zip: \ |
96 | 96 | $(BINRLS)/$(LIBNAME) \ |
97 | 97 | $(BINRLS)/*.xml \ |
98 | 98 | testprograms/sample.cs \ |
99 | - src/tn3270-sharp/tn3270-sharp.cs \ | |
99 | + src/pw3270-sharp/pw3270-sharp.cs \ | |
100 | 100 | $(BINRLS)/sample.exe |
101 | 101 | |
102 | 102 | |
... | ... | @@ -108,10 +108,10 @@ $(BINRLS)/$(GLUELIB): \ |
108 | 108 | @make -C src/native $@ |
109 | 109 | |
110 | 110 | $(BINRLS)/$(LIBNAME): \ |
111 | - src/tn3270-sharp/*.cs \ | |
111 | + src/pw3270-sharp/*.cs \ | |
112 | 112 | src/include/*.h |
113 | 113 | |
114 | - @make -C src/tn3270-sharp $@ | |
114 | + @make -C src/pw3270-sharp $@ | |
115 | 115 | |
116 | 116 | Debug: \ |
117 | 117 | $(BINDBG)/$(GLUELIB) \ |
... | ... | @@ -134,10 +134,10 @@ $(BINDBG)/$(GLUELIB): \ |
134 | 134 | @make -C src/native $@ |
135 | 135 | |
136 | 136 | $(BINDBG)/$(LIBNAME): \ |
137 | - src/tn3270-sharp/*.cs \ | |
137 | + src/pw3270-sharp/*.cs \ | |
138 | 138 | src/include/*.h |
139 | 139 | |
140 | - @make -C src/tn3270-sharp $@ | |
140 | + @make -C src/pw3270-sharp $@ | |
141 | 141 | |
142 | 142 | clean: |
143 | 143 | @rm -fr $(BINDIR) | ... | ... |
configure.ac
... | ... | @@ -332,7 +332,7 @@ dnl --------------------------------------------------------------------------- |
332 | 332 | |
333 | 333 | AC_CONFIG_FILES(Makefile) |
334 | 334 | AC_CONFIG_FILES(src/native/Makefile) |
335 | -AC_CONFIG_FILES(src/tn3270-sharp/Makefile) | |
335 | +AC_CONFIG_FILES(src/pw3270-sharp/Makefile) | |
336 | 336 | |
337 | 337 | dnl --------------------------------------------------------------------------- |
338 | 338 | dnl Output the generated config.status script. | ... | ... |
... | ... | @@ -0,0 +1,85 @@ |
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 | +# Contatos: | |
22 | +# | |
23 | +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
24 | +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
25 | +# | |
26 | + | |
27 | +SOURCES=pw3270-sharp.cs | |
28 | +LIBNAME=pw3270-sharp.dll | |
29 | + | |
30 | +#---[ Configuration values ]------------------------------------------------------------- | |
31 | + | |
32 | +PACKAGE_NAME=@PACKAGE_NAME@ | |
33 | +PACKAGE_VERSION=@PACKAGE_VERSION@ | |
34 | +PACKAGE_TARNAME=@PACKAGE_TARNAME@ | |
35 | + | |
36 | +prefix=@prefix@ | |
37 | +exec_prefix=@exec_prefix@ | |
38 | +bindir=@bindir@ | |
39 | +sbindir=@sbindir@ | |
40 | +libdir=@libdir@ | |
41 | + | |
42 | +BASEDIR=@BASEDIR@ | |
43 | +SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | |
44 | + | |
45 | +OBJDIR=$(BASEDIR)/.obj | |
46 | +OBJDBG=$(OBJDIR)/Debug | |
47 | +OBJRLS=$(OBJDIR)/Release | |
48 | + | |
49 | +BINDIR=$(BASEDIR)/.bin | |
50 | +BINDBG=$(BINDIR)/Debug | |
51 | +BINRLS=$(BINDIR)/Release | |
52 | + | |
53 | +INSTALL=@INSTALL@ | |
54 | +INSTALL_DATA=@INSTALL_DATA@ | |
55 | +INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
56 | + | |
57 | +LN_S=@LN_S@ | |
58 | + | |
59 | +MCS=@MCS@ | |
60 | +MKDIR=@MKDIR_P@ | |
61 | + | |
62 | +#---[ Targets ]-------------------------------------------------------------------------- | |
63 | + | |
64 | +all: \ | |
65 | + $(BINRLS)/$(LIBNAME) | |
66 | + | |
67 | +Release: \ | |
68 | + $(BINRLS)/$(LIBNAME) | |
69 | + | |
70 | +Debug: \ | |
71 | + $(BINDBG)/$(LIBNAME) | |
72 | + | |
73 | +$(BINDBG)/$(LIBNAME): \ | |
74 | + $(SOURCES) | |
75 | + | |
76 | + @$(MKDIR) `dirname $@` | |
77 | + @$(MCS) -debug -target:library -out:$@ $< | |
78 | + | |
79 | +$(BINRLS)/$(LIBNAME): \ | |
80 | + $(SOURCES) | |
81 | + | |
82 | + @$(MKDIR) `dirname $@` | |
83 | + @$(MCS) -doc:$(basename $@).xml -target:library -out:$@ $< | |
84 | + | |
85 | + | ... | ... |
... | ... | @@ -0,0 +1,371 @@ |
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., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como tn3270-sharp.cs 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 | + * Referências: | |
29 | + * | |
30 | + * https://msdn.microsoft.com/en-us/library/5ast78ax.aspx | |
31 | + * | |
32 | + */ | |
33 | + | |
34 | +using System; | |
35 | +using System.Text; | |
36 | +using System.Runtime.InteropServices; | |
37 | + | |
38 | +namespace tn3270 { | |
39 | + | |
40 | + /// <summary> | |
41 | + /// Session with 3270 HOST. | |
42 | + /// </summary> | |
43 | + public class Session { | |
44 | + | |
45 | + /// <summary> | |
46 | + /// lib3270 session handle | |
47 | + /// </summary> | |
48 | + private IntPtr hSession; | |
49 | + | |
50 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
51 | + extern static IntPtr tn3270_create_session(string name); | |
52 | + | |
53 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
54 | + extern static void tn3270_destroy_session(IntPtr session); | |
55 | + | |
56 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
57 | + extern static void tn3270_get_version(IntPtr session, StringBuilder str, int strlen); | |
58 | + | |
59 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
60 | + extern static void tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); | |
61 | + | |
62 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
63 | + extern static int tn3270_connect(IntPtr Session, string host, int wait); | |
64 | + | |
65 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
66 | + extern static int tn3270_is_connected(IntPtr Session); | |
67 | + | |
68 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
69 | + extern static int tn3270_disconnect(IntPtr Session); | |
70 | + | |
71 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
72 | + extern static int tn3270_wait_for_ready(IntPtr Session, int seconds); | |
73 | + | |
74 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
75 | + extern static int tn3270_wait(IntPtr Session, int seconds); | |
76 | + | |
77 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
78 | + extern static int tn3270_get_cstate(IntPtr Session); | |
79 | + | |
80 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
81 | + extern static int tn3270_get_program_message(IntPtr Session); | |
82 | + | |
83 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
84 | + extern static int tn3270_get_secure(IntPtr Session); | |
85 | + | |
86 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
87 | + extern static void tn3270_get_string(IntPtr Session, int addr, StringBuilder str, int strlen); | |
88 | + | |
89 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
90 | + extern static void tn3270_get_string_at(IntPtr Session, int row, int col, StringBuilder str, int strlen); | |
91 | + | |
92 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
93 | + extern static void tn3270_set_string_at(IntPtr Session, int row, int col, string str); | |
94 | + | |
95 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
96 | + extern static int tn3270_wait_for_string_at(IntPtr Session, int row, int col, string key, int timeout); | |
97 | + | |
98 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
99 | + extern static int tn3270_cmp_string_at(IntPtr Session, int row, int col, string str); | |
100 | + | |
101 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
102 | + extern static void tn3270_set_unlock_delay(IntPtr Session, int ms); | |
103 | + | |
104 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
105 | + extern static void tn3270_set_cursor_position(IntPtr Session, int row, int col); | |
106 | + | |
107 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
108 | + extern static void tn3270_set_cursor_addr(IntPtr Session, int addr); | |
109 | + | |
110 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
111 | + extern static int tn3270_enter(IntPtr Session); | |
112 | + | |
113 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
114 | + extern static int tn3270_pfkey(IntPtr Session, int key); | |
115 | + | |
116 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
117 | + extern static int tn3270_pakey(IntPtr Session, int key); | |
118 | + | |
119 | + /// <summary> | |
120 | + /// Create a new session with lib3270/pw3270 | |
121 | + /// </summary> | |
122 | + /// | |
123 | + /// <param name="name">Session name or empty string for a hidden session</param> | |
124 | + /// | |
125 | + public Session(string name) { | |
126 | + hSession = tn3270_create_session(name); | |
127 | + } | |
128 | + | |
129 | + /// <summary> | |
130 | + /// Disconnect from host, destroy session. | |
131 | + /// </summary> | |
132 | + /// | |
133 | + ~Session() { | |
134 | + tn3270_destroy_session(hSession); | |
135 | + } | |
136 | + | |
137 | + /// <summary> | |
138 | + /// Get lib3270/pw3270 Version identifier | |
139 | + /// </summary> | |
140 | + /// | |
141 | + /// <returns> | |
142 | + /// The version of the active instance. | |
143 | + /// </returns> | |
144 | + /// | |
145 | + public string GetVersion() { | |
146 | + StringBuilder str = new StringBuilder(10); | |
147 | + tn3270_get_version(hSession, str, 10); | |
148 | + return str.ToString(); | |
149 | + } | |
150 | + | |
151 | + /// <summary> | |
152 | + /// Get lib3270/pw3270 Revision number | |
153 | + /// </summary> | |
154 | + /// | |
155 | + /// <returns> | |
156 | + /// The revision of the active instance. | |
157 | + /// </returns> | |
158 | + /// | |
159 | + public string GetRevision() { | |
160 | + StringBuilder str = new StringBuilder(10); | |
161 | + tn3270_get_revision(hSession, str, 10); | |
162 | + return str.ToString(); | |
163 | + } | |
164 | + | |
165 | + /// <summary> | |
166 | + /// Connect to 3270 host. | |
167 | + /// </summary> | |
168 | + /// | |
169 | + /// <param name="host">URL of the target host (tn3270://hostname:port)</param> | |
170 | + /// <param name="wait">How many seconds should the call wait for the connection becomes ready</param> | |
171 | + /// | |
172 | + /// <returns> | |
173 | + /// </returns> | |
174 | + /// | |
175 | + public int Connect(string host, int wait) { | |
176 | + return tn3270_connect(hSession, host, wait); | |
177 | + } | |
178 | + | |
179 | + /// <summary> | |
180 | + /// Get connection state | |
181 | + /// </summary> | |
182 | + /// | |
183 | + /// <returns> | |
184 | + /// true if the session is connected to a remote host. | |
185 | + /// </returns> | |
186 | + /// | |
187 | + public bool IsConnected() { | |
188 | + return tn3270_is_connected(hSession) != 0; | |
189 | + } | |
190 | + | |
191 | + /// <summary> | |
192 | + /// Disconnect from 3270 host. | |
193 | + /// </summary> | |
194 | + /// | |
195 | + public int Disconnect() { | |
196 | + return tn3270_disconnect(hSession); | |
197 | + } | |
198 | + | |
199 | + /// <summary> | |
200 | + /// Wait for network activity | |
201 | + /// </summary> | |
202 | + /// | |
203 | + /// <param name="seconds">Seconds to wait</param> | |
204 | + /// | |
205 | + /// <returns> | |
206 | + /// | |
207 | + /// </returns> | |
208 | + /// | |
209 | + public int WaitForReady(int seconds) { | |
210 | + return tn3270_wait_for_ready(hSession, seconds); | |
211 | + } | |
212 | + | |
213 | + /// <summary> | |
214 | + /// "Sleep" keeping the network activity. | |
215 | + /// </summary> | |
216 | + /// | |
217 | + /// <param name="seconds">Number of seconds to wait</param> | |
218 | + /// | |
219 | + /// <returns> | |
220 | + /// | |
221 | + /// </returns> | |
222 | + /// | |
223 | + public int Wait(int seconds) { | |
224 | + return tn3270_wait(hSession, seconds); | |
225 | + } | |
226 | + | |
227 | + /// <summary> | |
228 | + /// Get contents at address | |
229 | + /// </summary> | |
230 | + /// | |
231 | + /// <param name="addr">Address of text in the screen buffer</param> | |
232 | + /// <param name="strlen">Number of characters to get</param> | |
233 | + /// | |
234 | + /// <returns> | |
235 | + /// Contents from terminal screen. | |
236 | + /// </returns> | |
237 | + /// | |
238 | + public string GetString(int addr, int strlen) { | |
239 | + StringBuilder str = new StringBuilder(strlen+1); | |
240 | + tn3270_get_string(hSession, addr, str, strlen); | |
241 | + return str.ToString(0,strlen); | |
242 | + } | |
243 | + | |
244 | + /// <summary> | |
245 | + /// Get contents at position. | |
246 | + /// </summary> | |
247 | + /// | |
248 | + /// <param name="row">Start row</param> | |
249 | + /// <param name="col">Start col</param> | |
250 | + /// <param name="strlen">Number of characters to get</param> | |
251 | + /// | |
252 | + /// <returns> | |
253 | + /// Contents from terminal screen. | |
254 | + /// </returns> | |
255 | + /// | |
256 | + public string GetStringAt(int row, int col, int strlen) { | |
257 | + StringBuilder str = new StringBuilder(strlen+1); | |
258 | + tn3270_get_string_at(hSession, row, col, str, strlen); | |
259 | + return str.ToString(0,strlen); | |
260 | + } | |
261 | + | |
262 | + /// <summary> | |
263 | + /// Set contents at position | |
264 | + /// </summary> | |
265 | + /// | |
266 | + /// <param name="row">Start row</param> | |
267 | + /// <param name="col">Start col</param> | |
268 | + /// <param name="str">Text to set</param> | |
269 | + /// | |
270 | + public void SetStringAg(int row, int col, string str) { | |
271 | + tn3270_set_string_at(hSession, row, col, str); | |
272 | + } | |
273 | + | |
274 | + /// <summary> | |
275 | + /// Wait for text at position. | |
276 | + /// </summary> | |
277 | + /// | |
278 | + /// <param name="row">Start row</param> | |
279 | + /// <param name="col">Start col</param> | |
280 | + /// <param name="str">Text to wait</param> | |
281 | + /// <param name="timeout">Seconds to wait</param> | |
282 | + /// | |
283 | + /// <returns> | |
284 | + /// | |
285 | + /// </returns> | |
286 | + /// | |
287 | + public int WaitForStringAt(int row, int col, string str, int timeout) { | |
288 | + return tn3270_wait_for_string_at(hSession, row, col, str, timeout); | |
289 | + } | |
290 | + | |
291 | + /// <summary> | |
292 | + /// Compare contents at position | |
293 | + /// </summary> | |
294 | + /// | |
295 | + /// <param name="row">Start row</param> | |
296 | + /// <param name="col">Start col</param> | |
297 | + /// <param name="str">Text to compare</param> | |
298 | + /// | |
299 | + /// <returns> | |
300 | + /// Result (0 = The strings are the same). | |
301 | + /// </returns> | |
302 | + /// | |
303 | + public int CmpStringAt(int row, int col, string str) { | |
304 | + return tn3270_cmp_string_at(hSession, row, col, str); | |
305 | + } | |
306 | + | |
307 | + /// <summary> | |
308 | + /// Set cursor position. | |
309 | + /// </summary> | |
310 | + /// | |
311 | + /// <param name="row">New cursor row</param> | |
312 | + /// <param name="col">New cursor column</param> | |
313 | + /// | |
314 | + public void SetCursorPosition(int row, int col) { | |
315 | + tn3270_set_cursor_position(hSession, row, col); | |
316 | + } | |
317 | + | |
318 | + /// <summary> | |
319 | + /// Set cursor position based on address. | |
320 | + /// </summary> | |
321 | + /// | |
322 | + /// <param name="addr">Address of the new cursor position</param> | |
323 | + /// | |
324 | + public void SetCursorPosition(int addr) { | |
325 | + tn3270_set_cursor_addr(hSession, addr); | |
326 | + } | |
327 | + | |
328 | + /// <summary> | |
329 | + /// Send "Enter" key | |
330 | + /// </summary> | |
331 | + /// | |
332 | + /// <returns> | |
333 | + /// | |
334 | + /// </returns> | |
335 | + /// | |
336 | + public int Enter() { | |
337 | + return tn3270_enter(hSession); | |
338 | + } | |
339 | + | |
340 | + /// <summary> | |
341 | + /// Send "PF" key | |
342 | + /// </summary> | |
343 | + /// | |
344 | + /// <param name="key">Key identifier 1=PF1, 2=PF2, ...</param> | |
345 | + /// | |
346 | + /// <returns> | |
347 | + /// | |
348 | + /// </returns> | |
349 | + /// | |
350 | + public int PfKey(int key) { | |
351 | + return tn3270_pfkey(hSession, key); | |
352 | + } | |
353 | + | |
354 | + /// <summary> | |
355 | + /// Send "PA" key | |
356 | + /// </summary> | |
357 | + /// | |
358 | + /// <param name="key">Key identifier 1=PA1, 2=PA2, ...</param> | |
359 | + /// | |
360 | + /// <returns> | |
361 | + /// | |
362 | + /// </returns> | |
363 | + /// | |
364 | + public int PaKey(int key) { | |
365 | + return tn3270_pakey(hSession, key); | |
366 | + } | |
367 | + | |
368 | + | |
369 | + } | |
370 | + | |
371 | +} | ... | ... |
src/tn3270-sharp/Makefile.in
... | ... | @@ -1,85 +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 | -# Contatos: | |
22 | -# | |
23 | -# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
24 | -# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
25 | -# | |
26 | - | |
27 | -SOURCES=tn3270-sharp.cs | |
28 | -LIBNAME=tn3270-sharp.dll | |
29 | - | |
30 | -#---[ Configuration values ]------------------------------------------------------------- | |
31 | - | |
32 | -PACKAGE_NAME=@PACKAGE_NAME@ | |
33 | -PACKAGE_VERSION=@PACKAGE_VERSION@ | |
34 | -PACKAGE_TARNAME=@PACKAGE_TARNAME@ | |
35 | - | |
36 | -prefix=@prefix@ | |
37 | -exec_prefix=@exec_prefix@ | |
38 | -bindir=@bindir@ | |
39 | -sbindir=@sbindir@ | |
40 | -libdir=@libdir@ | |
41 | - | |
42 | -BASEDIR=@BASEDIR@ | |
43 | -SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | |
44 | - | |
45 | -OBJDIR=$(BASEDIR)/.obj | |
46 | -OBJDBG=$(OBJDIR)/Debug | |
47 | -OBJRLS=$(OBJDIR)/Release | |
48 | - | |
49 | -BINDIR=$(BASEDIR)/.bin | |
50 | -BINDBG=$(BINDIR)/Debug | |
51 | -BINRLS=$(BINDIR)/Release | |
52 | - | |
53 | -INSTALL=@INSTALL@ | |
54 | -INSTALL_DATA=@INSTALL_DATA@ | |
55 | -INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
56 | - | |
57 | -LN_S=@LN_S@ | |
58 | - | |
59 | -MCS=@MCS@ | |
60 | -MKDIR=@MKDIR_P@ | |
61 | - | |
62 | -#---[ Targets ]-------------------------------------------------------------------------- | |
63 | - | |
64 | -all: \ | |
65 | - $(BINRLS)/$(LIBNAME) | |
66 | - | |
67 | -Release: \ | |
68 | - $(BINRLS)/$(LIBNAME) | |
69 | - | |
70 | -Debug: \ | |
71 | - $(BINDBG)/$(LIBNAME) | |
72 | - | |
73 | -$(BINDBG)/$(LIBNAME): \ | |
74 | - $(SOURCES) | |
75 | - | |
76 | - @$(MKDIR) `dirname $@` | |
77 | - @$(MCS) -debug -target:library -out:$@ $< | |
78 | - | |
79 | -$(BINRLS)/$(LIBNAME): \ | |
80 | - $(SOURCES) | |
81 | - | |
82 | - @$(MKDIR) `dirname $@` | |
83 | - @$(MCS) -doc:$(basename $@).xml -target:library -out:$@ $< | |
84 | - | |
85 | - |
src/tn3270-sharp/tn3270-sharp.cs
... | ... | @@ -1,371 +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., 51 Franklin | |
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | - * | |
21 | - * Este programa está nomeado como tn3270-sharp.cs 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 | - * Referências: | |
29 | - * | |
30 | - * https://msdn.microsoft.com/en-us/library/5ast78ax.aspx | |
31 | - * | |
32 | - */ | |
33 | - | |
34 | -using System; | |
35 | -using System.Text; | |
36 | -using System.Runtime.InteropServices; | |
37 | - | |
38 | -namespace tn3270 { | |
39 | - | |
40 | - /// <summary> | |
41 | - /// Session with 3270 HOST. | |
42 | - /// </summary> | |
43 | - public class Session { | |
44 | - | |
45 | - /// <summary> | |
46 | - /// lib3270 session handle | |
47 | - /// </summary> | |
48 | - private IntPtr hSession; | |
49 | - | |
50 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
51 | - extern static IntPtr tn3270_create_session(string name); | |
52 | - | |
53 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
54 | - extern static void tn3270_destroy_session(IntPtr session); | |
55 | - | |
56 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
57 | - extern static void tn3270_get_version(IntPtr session, StringBuilder str, int strlen); | |
58 | - | |
59 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
60 | - extern static void tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); | |
61 | - | |
62 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
63 | - extern static int tn3270_connect(IntPtr Session, string host, int wait); | |
64 | - | |
65 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
66 | - extern static int tn3270_is_connected(IntPtr Session); | |
67 | - | |
68 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
69 | - extern static int tn3270_disconnect(IntPtr Session); | |
70 | - | |
71 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
72 | - extern static int tn3270_wait_for_ready(IntPtr Session, int seconds); | |
73 | - | |
74 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
75 | - extern static int tn3270_wait(IntPtr Session, int seconds); | |
76 | - | |
77 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
78 | - extern static int tn3270_get_cstate(IntPtr Session); | |
79 | - | |
80 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
81 | - extern static int tn3270_get_program_message(IntPtr Session); | |
82 | - | |
83 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
84 | - extern static int tn3270_get_secure(IntPtr Session); | |
85 | - | |
86 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
87 | - extern static void tn3270_get_string(IntPtr Session, int addr, StringBuilder str, int strlen); | |
88 | - | |
89 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
90 | - extern static void tn3270_get_string_at(IntPtr Session, int row, int col, StringBuilder str, int strlen); | |
91 | - | |
92 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
93 | - extern static void tn3270_set_string_at(IntPtr Session, int row, int col, string str); | |
94 | - | |
95 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
96 | - extern static int tn3270_wait_for_string_at(IntPtr Session, int row, int col, string key, int timeout); | |
97 | - | |
98 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
99 | - extern static int tn3270_cmp_string_at(IntPtr Session, int row, int col, string str); | |
100 | - | |
101 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
102 | - extern static void tn3270_set_unlock_delay(IntPtr Session, int ms); | |
103 | - | |
104 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
105 | - extern static void tn3270_set_cursor_position(IntPtr Session, int row, int col); | |
106 | - | |
107 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
108 | - extern static void tn3270_set_cursor_addr(IntPtr Session, int addr); | |
109 | - | |
110 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
111 | - extern static int tn3270_enter(IntPtr Session); | |
112 | - | |
113 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
114 | - extern static int tn3270_pfkey(IntPtr Session, int key); | |
115 | - | |
116 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
117 | - extern static int tn3270_pakey(IntPtr Session, int key); | |
118 | - | |
119 | - /// <summary> | |
120 | - /// Create a new session with lib3270/pw3270 | |
121 | - /// </summary> | |
122 | - /// | |
123 | - /// <param name="name">Session name or empty string for a hidden session</param> | |
124 | - /// | |
125 | - public Session(string name) { | |
126 | - hSession = tn3270_create_session(name); | |
127 | - } | |
128 | - | |
129 | - /// <summary> | |
130 | - /// Disconnect from host, destroy session. | |
131 | - /// </summary> | |
132 | - /// | |
133 | - ~Session() { | |
134 | - tn3270_destroy_session(hSession); | |
135 | - } | |
136 | - | |
137 | - /// <summary> | |
138 | - /// Get lib3270/pw3270 Version identifier | |
139 | - /// </summary> | |
140 | - /// | |
141 | - /// <returns> | |
142 | - /// The version of the active instance. | |
143 | - /// </returns> | |
144 | - /// | |
145 | - public string GetVersion() { | |
146 | - StringBuilder str = new StringBuilder(10); | |
147 | - tn3270_get_version(hSession, str, 10); | |
148 | - return str.ToString(); | |
149 | - } | |
150 | - | |
151 | - /// <summary> | |
152 | - /// Get lib3270/pw3270 Revision number | |
153 | - /// </summary> | |
154 | - /// | |
155 | - /// <returns> | |
156 | - /// The revision of the active instance. | |
157 | - /// </returns> | |
158 | - /// | |
159 | - public string GetRevision() { | |
160 | - StringBuilder str = new StringBuilder(10); | |
161 | - tn3270_get_revision(hSession, str, 10); | |
162 | - return str.ToString(); | |
163 | - } | |
164 | - | |
165 | - /// <summary> | |
166 | - /// Connect to 3270 host. | |
167 | - /// </summary> | |
168 | - /// | |
169 | - /// <param name="host">URL of the target host (tn3270://hostname:port)</param> | |
170 | - /// <param name="wait">How many seconds should the call wait for the connection becomes ready</param> | |
171 | - /// | |
172 | - /// <returns> | |
173 | - /// </returns> | |
174 | - /// | |
175 | - public int Connect(string host, int wait) { | |
176 | - return tn3270_connect(hSession, host, wait); | |
177 | - } | |
178 | - | |
179 | - /// <summary> | |
180 | - /// Get connection state | |
181 | - /// </summary> | |
182 | - /// | |
183 | - /// <returns> | |
184 | - /// true if the session is connected to a remote host. | |
185 | - /// </returns> | |
186 | - /// | |
187 | - public bool IsConnected() { | |
188 | - return tn3270_is_connected(hSession) != 0; | |
189 | - } | |
190 | - | |
191 | - /// <summary> | |
192 | - /// Disconnect from 3270 host. | |
193 | - /// </summary> | |
194 | - /// | |
195 | - public int Disconnect() { | |
196 | - return tn3270_disconnect(hSession); | |
197 | - } | |
198 | - | |
199 | - /// <summary> | |
200 | - /// Wait for network activity | |
201 | - /// </summary> | |
202 | - /// | |
203 | - /// <param name="seconds">Seconds to wait</param> | |
204 | - /// | |
205 | - /// <returns> | |
206 | - /// | |
207 | - /// </returns> | |
208 | - /// | |
209 | - public int WaitForReady(int seconds) { | |
210 | - return tn3270_wait_for_ready(hSession, seconds); | |
211 | - } | |
212 | - | |
213 | - /// <summary> | |
214 | - /// "Sleep" keeping the network activity. | |
215 | - /// </summary> | |
216 | - /// | |
217 | - /// <param name="seconds">Number of seconds to wait</param> | |
218 | - /// | |
219 | - /// <returns> | |
220 | - /// | |
221 | - /// </returns> | |
222 | - /// | |
223 | - public int Wait(int seconds) { | |
224 | - return tn3270_wait(hSession, seconds); | |
225 | - } | |
226 | - | |
227 | - /// <summary> | |
228 | - /// Get contents at address | |
229 | - /// </summary> | |
230 | - /// | |
231 | - /// <param name="addr">Address of text in the screen buffer</param> | |
232 | - /// <param name="strlen">Number of characters to get</param> | |
233 | - /// | |
234 | - /// <returns> | |
235 | - /// Contents from terminal screen. | |
236 | - /// </returns> | |
237 | - /// | |
238 | - public string GetString(int addr, int strlen) { | |
239 | - StringBuilder str = new StringBuilder(strlen+1); | |
240 | - tn3270_get_string(hSession, addr, str, strlen); | |
241 | - return str.ToString(0,strlen); | |
242 | - } | |
243 | - | |
244 | - /// <summary> | |
245 | - /// Get contents at position. | |
246 | - /// </summary> | |
247 | - /// | |
248 | - /// <param name="row">Start row</param> | |
249 | - /// <param name="col">Start col</param> | |
250 | - /// <param name="strlen">Number of characters to get</param> | |
251 | - /// | |
252 | - /// <returns> | |
253 | - /// Contents from terminal screen. | |
254 | - /// </returns> | |
255 | - /// | |
256 | - public string GetStringAt(int row, int col, int strlen) { | |
257 | - StringBuilder str = new StringBuilder(strlen+1); | |
258 | - tn3270_get_string_at(hSession, row, col, str, strlen); | |
259 | - return str.ToString(0,strlen); | |
260 | - } | |
261 | - | |
262 | - /// <summary> | |
263 | - /// Set contents at position | |
264 | - /// </summary> | |
265 | - /// | |
266 | - /// <param name="row">Start row</param> | |
267 | - /// <param name="col">Start col</param> | |
268 | - /// <param name="str">Text to set</param> | |
269 | - /// | |
270 | - public void SetStringAg(int row, int col, string str) { | |
271 | - tn3270_set_string_at(hSession, row, col, str); | |
272 | - } | |
273 | - | |
274 | - /// <summary> | |
275 | - /// Wait for text at position. | |
276 | - /// </summary> | |
277 | - /// | |
278 | - /// <param name="row">Start row</param> | |
279 | - /// <param name="col">Start col</param> | |
280 | - /// <param name="str">Text to wait</param> | |
281 | - /// <param name="timeout">Seconds to wait</param> | |
282 | - /// | |
283 | - /// <returns> | |
284 | - /// | |
285 | - /// </returns> | |
286 | - /// | |
287 | - public int WaitForStringAt(int row, int col, string str, int timeout) { | |
288 | - return tn3270_wait_for_string_at(hSession, row, col, str, timeout); | |
289 | - } | |
290 | - | |
291 | - /// <summary> | |
292 | - /// Compare contents at position | |
293 | - /// </summary> | |
294 | - /// | |
295 | - /// <param name="row">Start row</param> | |
296 | - /// <param name="col">Start col</param> | |
297 | - /// <param name="str">Text to compare</param> | |
298 | - /// | |
299 | - /// <returns> | |
300 | - /// Result (0 = The strings are the same). | |
301 | - /// </returns> | |
302 | - /// | |
303 | - public int CmpStringAt(int row, int col, string str) { | |
304 | - return tn3270_cmp_string_at(hSession, row, col, str); | |
305 | - } | |
306 | - | |
307 | - /// <summary> | |
308 | - /// Set cursor position. | |
309 | - /// </summary> | |
310 | - /// | |
311 | - /// <param name="row">New cursor row</param> | |
312 | - /// <param name="col">New cursor column</param> | |
313 | - /// | |
314 | - public void SetCursorPosition(int row, int col) { | |
315 | - tn3270_set_cursor_position(hSession, row, col); | |
316 | - } | |
317 | - | |
318 | - /// <summary> | |
319 | - /// Set cursor position based on address. | |
320 | - /// </summary> | |
321 | - /// | |
322 | - /// <param name="addr">Address of the new cursor position</param> | |
323 | - /// | |
324 | - public void SetCursorPosition(int addr) { | |
325 | - tn3270_set_cursor_addr(hSession, addr); | |
326 | - } | |
327 | - | |
328 | - /// <summary> | |
329 | - /// Send "Enter" key | |
330 | - /// </summary> | |
331 | - /// | |
332 | - /// <returns> | |
333 | - /// | |
334 | - /// </returns> | |
335 | - /// | |
336 | - public int Enter() { | |
337 | - return tn3270_enter(hSession); | |
338 | - } | |
339 | - | |
340 | - /// <summary> | |
341 | - /// Send "PF" key | |
342 | - /// </summary> | |
343 | - /// | |
344 | - /// <param name="key">Key identifier 1=PF1, 2=PF2, ...</param> | |
345 | - /// | |
346 | - /// <returns> | |
347 | - /// | |
348 | - /// </returns> | |
349 | - /// | |
350 | - public int PfKey(int key) { | |
351 | - return tn3270_pfkey(hSession, key); | |
352 | - } | |
353 | - | |
354 | - /// <summary> | |
355 | - /// Send "PA" key | |
356 | - /// </summary> | |
357 | - /// | |
358 | - /// <param name="key">Key identifier 1=PA1, 2=PA2, ...</param> | |
359 | - /// | |
360 | - /// <returns> | |
361 | - /// | |
362 | - /// </returns> | |
363 | - /// | |
364 | - public int PaKey(int key) { | |
365 | - return tn3270_pakey(hSession, key); | |
366 | - } | |
367 | - | |
368 | - | |
369 | - } | |
370 | - | |
371 | -} |