Commit b90fd42bc8d993f140ffbd077487c9b48309b215

Authored by Perry Werneck
1 parent 224bbafc
Exists in master

Renaming files.

@@ -328,7 +328,7 @@ dnl --------------------------------------------------------------------------- @@ -328,7 +328,7 @@ dnl ---------------------------------------------------------------------------
328 AC_CONFIG_FILES(Makefile) 328 AC_CONFIG_FILES(Makefile)
329 AC_CONFIG_FILES(src/native/Makefile) 329 AC_CONFIG_FILES(src/native/Makefile)
330 AC_CONFIG_FILES(src/core/Makefile) 330 AC_CONFIG_FILES(src/core/Makefile)
331 -AC_CONFIG_FILES(src/core/tn3270-sharp.pc) 331 +AC_CONFIG_FILES(src/core/mono-tn3270.pc)
332 332
333 dnl --------------------------------------------------------------------------- 333 dnl ---------------------------------------------------------------------------
334 dnl Output the generated config.status script. 334 dnl Output the generated config.status script.
src/core/mono-tn3270.pc.in 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +prefix=${pcfiledir}/../..
  2 +exec_prefix=${prefix}
  3 +libdir=${exec_prefix}/lib
  4 +gapidir=${prefix}/share/tn3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@
  5 +
  6 +
  7 +Name: tn3270-sharp
  8 +Description: .NET Bindings for pw3270
  9 +Version: @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@
  10 +Cflags: -I:${gapidir}/tn3270-sharp.xml
  11 +Libs: -r:${libdir}/mono/tn3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@/tn3270-sharp.dll
src/core/tn3270-sharp.cs
@@ -1,618 +0,0 @@ @@ -1,618 +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 pw3270 {  
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 int tn3270_destroy_session(IntPtr session);  
55 -  
56 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
57 - extern static int tn3270_get_version(IntPtr session, StringBuilder str, int strlen);  
58 -  
59 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
60 - extern static int 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_is_ready(IntPtr Session);  
70 -  
71 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
72 - extern static int tn3270_disconnect(IntPtr Session);  
73 -  
74 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
75 - extern static int tn3270_wait_for_ready(IntPtr Session, int seconds);  
76 -  
77 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
78 - extern static int tn3270_wait(IntPtr Session, int seconds);  
79 -  
80 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
81 - extern static int tn3270_get_cstate(IntPtr Session);  
82 -  
83 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
84 - extern static int tn3270_get_program_message(IntPtr Session);  
85 -  
86 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
87 - extern static int tn3270_get_secure(IntPtr Session);  
88 -  
89 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
90 - extern static int tn3270_get_contents(IntPtr Session, StringBuilder str, int strlen);  
91 -  
92 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
93 - extern static int tn3270_get_string(IntPtr Session, int addr, StringBuilder str, int strlen);  
94 -  
95 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
96 - extern static int tn3270_get_string_at(IntPtr Session, int row, int col, StringBuilder str, int strlen);  
97 -  
98 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
99 - extern static int tn3270_set_string_at(IntPtr Session, int row, int col, string str);  
100 -  
101 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
102 - extern static int tn3270_wait_for_string_at(IntPtr Session, int row, int col, string key, int timeout);  
103 -  
104 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
105 - extern static int tn3270_cmp_string_at(IntPtr Session, int row, int col, string str);  
106 -  
107 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
108 - extern static int tn3270_set_unlock_delay(IntPtr Session, int ms);  
109 -  
110 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
111 - extern static int tn3270_set_cursor_position(IntPtr Session, int row, int col);  
112 -  
113 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
114 - extern static int tn3270_set_cursor_addr(IntPtr Session, int addr);  
115 -  
116 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
117 - extern static int tn3270_get_cursor_addr(IntPtr Session);  
118 -  
119 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
120 - extern static int tn3270_enter(IntPtr Session);  
121 -  
122 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
123 - extern static int tn3270_pfkey(IntPtr Session, int key);  
124 -  
125 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
126 - extern static int tn3270_pakey(IntPtr Session, int key);  
127 -  
128 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
129 - extern static int tn3270_get_width(IntPtr Session);  
130 -  
131 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
132 - extern static int tn3270_get_height(IntPtr Session);  
133 -  
134 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
135 - extern static int tn3270_get_length(IntPtr Session);  
136 -  
137 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
138 - extern static int tn3270_set_charset(IntPtr Session, string str);  
139 -  
140 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
141 - extern static int tn3270_set_url(IntPtr Session, string str);  
142 -  
143 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
144 - extern static int tn3270_get_url(IntPtr Session, StringBuilder str, int strlen);  
145 -  
146 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
147 - extern static int tn3270_set_error_message(IntPtr Session, string str);  
148 -  
149 - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]  
150 - extern static int tn3270_get_error_message(IntPtr Session, StringBuilder str, int strlen);  
151 -  
152 - /// <summary>  
153 - /// Create a new session with lib3270/pw3270  
154 - /// </summary>  
155 - ///  
156 - /// <param name="name">Session name or empty string for a hidden session</param>  
157 - ///  
158 - public Session(string name) {  
159 - hSession = tn3270_create_session(name);  
160 - tn3270_set_charset(hSession,"UTF-8");  
161 - }  
162 -  
163 - /// <summary>  
164 - /// Disconnect from host, destroy session.  
165 - /// </summary>  
166 - ///  
167 - ~Session() {  
168 - tn3270_destroy_session(hSession);  
169 - }  
170 -  
171 - /// <summary>  
172 - /// Get lib3270/pw3270 Version identifier  
173 - /// </summary>  
174 - ///  
175 - /// <returns>  
176 - /// The version of the active instance.  
177 - /// </returns>  
178 - ///  
179 - public string GetVersion() {  
180 - StringBuilder str = new StringBuilder(10);  
181 - tn3270_get_version(hSession, str, 10);  
182 - return str.ToString();  
183 - }  
184 -  
185 - /// <summary>  
186 - /// Lib3270 version.  
187 - /// </summary>  
188 - ///  
189 - /// <returns>  
190 - /// Lib3270 version string  
191 - /// </returns>  
192 - ///  
193 - public string Version {  
194 - get {  
195 - return GetVersion();  
196 - }  
197 - }  
198 -  
199 - /// <summary>  
200 - /// Get lib3270/pw3270 Revision number  
201 - /// </summary>  
202 - ///  
203 - /// <returns>  
204 - /// The revision of the active instance.  
205 - /// </returns>  
206 - ///  
207 - public string GetRevision() {  
208 - StringBuilder str = new StringBuilder(10);  
209 - tn3270_get_revision(hSession, str, 10);  
210 - return str.ToString();  
211 - }  
212 -  
213 - public string Revision {  
214 - get {  
215 - return GetRevision();  
216 - }  
217 - }  
218 -  
219 - /// <summary>  
220 - /// Connect to 3270 host.  
221 - /// </summary>  
222 - ///  
223 - /// <param name="host">URL of the target host (tn3270://hostname:port)</param>  
224 - /// <param name="wait">How many seconds should the call wait for the connection becomes ready</param>  
225 - ///  
226 - /// <returns>  
227 - /// </returns>  
228 - ///  
229 - public int Connect(string host, int wait) {  
230 - return tn3270_connect(hSession, host, wait);  
231 - }  
232 -  
233 - /// <summary>  
234 - /// Get connection state  
235 - /// </summary>  
236 - ///  
237 - /// <returns>  
238 - /// true if the session is connected to a remote host.  
239 - /// </returns>  
240 - ///  
241 - public bool IsConnected() {  
242 - return tn3270_is_connected(hSession) != 0;  
243 - }  
244 -  
245 - public bool Connected {  
246 - get {  
247 - return tn3270_is_connected(hSession) != 0;  
248 - }  
249 - }  
250 -  
251 - public bool IsReady() {  
252 - return tn3270_is_ready(hSession) != 0;  
253 - }  
254 -  
255 - public bool Ready {  
256 - get {  
257 - return tn3270_is_ready(hSession) != 0;  
258 - }  
259 - }  
260 -  
261 - /// <summary>  
262 - /// Disconnect from 3270 host.  
263 - /// </summary>  
264 - ///  
265 - public int Disconnect() {  
266 - return tn3270_disconnect(hSession);  
267 - }  
268 -  
269 - /// <summary>  
270 - /// Wait for network activity  
271 - /// </summary>  
272 - ///  
273 - /// <param name="seconds">Seconds to wait</param>  
274 - ///  
275 - /// <returns>  
276 - ///  
277 - /// </returns>  
278 - ///  
279 - public int WaitForReady(int seconds) {  
280 - return tn3270_wait_for_ready(hSession, seconds);  
281 - }  
282 -  
283 - /// <summary>  
284 - /// "Sleep" keeping the network activity.  
285 - /// </summary>  
286 - ///  
287 - /// <param name="seconds">Number of seconds to wait</param>  
288 - ///  
289 - /// <returns>  
290 - ///  
291 - /// </returns>  
292 - ///  
293 - public int Wait(int seconds) {  
294 - return tn3270_wait(hSession, seconds);  
295 - }  
296 -  
297 - /// <summary>  
298 - /// Get contents  
299 - /// </summary>  
300 - ///  
301 - /// <returns>  
302 - /// Contents from terminal screen.  
303 - /// </returns>  
304 - ///  
305 - public override string ToString() {  
306 - int strlen = (tn3270_get_width(hSession)+1) * (tn3270_get_height(hSession)+1);  
307 - StringBuilder str = new StringBuilder(strlen+1);  
308 - strlen = tn3270_get_contents(hSession, str, strlen);  
309 - return str.ToString();  
310 - }  
311 -  
312 -  
313 - /// <summary>  
314 - /// Get contents at address  
315 - /// </summary>  
316 - ///  
317 - /// <param name="addr">Address of text in the screen buffer</param>  
318 - /// <param name="strlen">Number of characters to get</param>  
319 - ///  
320 - /// <returns>  
321 - /// Contents from terminal screen.  
322 - /// </returns>  
323 - ///  
324 - public string GetString(int addr, int strlen) {  
325 - StringBuilder str = new StringBuilder(strlen+1);  
326 - tn3270_get_string(hSession, addr, str, strlen);  
327 - return str.ToString();  
328 - }  
329 -  
330 - /// <summary>  
331 - /// Get contents at position.  
332 - /// </summary>  
333 - ///  
334 - /// <param name="row">Start row</param>  
335 - /// <param name="col">Start col</param>  
336 - /// <param name="strlen">Number of characters to get</param>  
337 - ///  
338 - /// <returns>  
339 - /// Contents from terminal screen.  
340 - /// </returns>  
341 - ///  
342 - public string GetStringAt(int row, int col, int strlen) {  
343 - StringBuilder str = new StringBuilder(strlen+1);  
344 - tn3270_get_string_at(hSession, row, col, str, strlen);  
345 - return str.ToString();  
346 - }  
347 -  
348 - /// <summary>  
349 - /// Set contents at position  
350 - /// </summary>  
351 - ///  
352 - /// <param name="row">Start row</param>  
353 - /// <param name="col">Start col</param>  
354 - /// <param name="str">Text to set</param>  
355 - ///  
356 - public void SetStringAt(int row, int col, string str) {  
357 - tn3270_set_string_at(hSession, row, col, str);  
358 - }  
359 -  
360 - /// <summary>  
361 - /// Wait for text at position.  
362 - /// </summary>  
363 - ///  
364 - /// <param name="row">Start row</param>  
365 - /// <param name="col">Start col</param>  
366 - /// <param name="str">Text to wait</param>  
367 - /// <param name="timeout">Seconds to wait</param>  
368 - ///  
369 - /// <returns>  
370 - ///  
371 - /// </returns>  
372 - ///  
373 - public int WaitForStringAt(int row, int col, string str, int timeout) {  
374 - return tn3270_wait_for_string_at(hSession, row, col, str, timeout);  
375 - }  
376 -  
377 - /// <summary>  
378 - /// Compare contents at position  
379 - /// </summary>  
380 - ///  
381 - /// <param name="row">Start row</param>  
382 - /// <param name="col">Start col</param>  
383 - /// <param name="str">Text to compare</param>  
384 - ///  
385 - /// <returns>  
386 - /// Result (0 = The strings are the same).  
387 - /// </returns>  
388 - ///  
389 - public int CmpStringAt(int row, int col, string str) {  
390 - return tn3270_cmp_string_at(hSession, row, col, str);  
391 - }  
392 -  
393 - /// <summary>  
394 - /// Set cursor position.  
395 - /// </summary>  
396 - ///  
397 - /// <param name="row">New cursor row</param>  
398 - /// <param name="col">New cursor column</param>  
399 - ///  
400 - public void SetCursorPosition(int row, int col) {  
401 - tn3270_set_cursor_position(hSession, row, col);  
402 - }  
403 -  
404 - /// <summary>  
405 - /// Set cursor position based on address.  
406 - /// </summary>  
407 - ///  
408 - /// <param name="addr">Address of the new cursor position</param>  
409 - ///  
410 - public void SetCursorPosition(int addr) {  
411 - tn3270_set_cursor_addr(hSession, addr);  
412 - }  
413 -  
414 - /// <summary>  
415 - /// Get cursor address  
416 - /// </summary>  
417 - ///  
418 - public int GetCursorPosition() {  
419 - return tn3270_get_cursor_addr(hSession);  
420 - }  
421 -  
422 - /// <summary>  
423 - /// Cursor address  
424 - /// </summary>  
425 - ///  
426 - public int CursorPosition {  
427 - set {  
428 - tn3270_set_cursor_addr(hSession, value);  
429 - }  
430 - get {  
431 - return tn3270_get_cursor_addr(hSession);  
432 - }  
433 - }  
434 -  
435 - /// <summary>  
436 - /// Set the "screen ready" delay  
437 - /// </summary>  
438 - ///  
439 - public int SetUnlockDelay(int ms) {  
440 - return tn3270_set_unlock_delay(hSession, ms);  
441 - }  
442 -  
443 - /// <summary>  
444 - /// Set the "screen ready" delay  
445 - /// </summary>  
446 - ///  
447 - public int UnlockDelay {  
448 - set {  
449 - tn3270_set_unlock_delay(hSession, value);  
450 - }  
451 - }  
452 -  
453 -  
454 - /// <summary>  
455 - /// Send "Enter" key  
456 - /// </summary>  
457 - ///  
458 - /// <returns>  
459 - ///  
460 - /// </returns>  
461 - ///  
462 - public int Enter() {  
463 - return tn3270_enter(hSession);  
464 - }  
465 -  
466 - /// <summary>  
467 - /// Send "PF" key  
468 - /// </summary>  
469 - ///  
470 - /// <param name="key">Key identifier 1=PF1, 2=PF2, ...</param>  
471 - ///  
472 - /// <returns>  
473 - ///  
474 - /// </returns>  
475 - ///  
476 - public int PfKey(int key) {  
477 - return tn3270_pfkey(hSession, key);  
478 - }  
479 -  
480 - /// <summary>  
481 - /// Send "PA" key  
482 - /// </summary>  
483 - ///  
484 - /// <param name="key">Key identifier 1=PA1, 2=PA2, ...</param>  
485 - ///  
486 - /// <returns>  
487 - ///  
488 - /// </returns>  
489 - ///  
490 - public int PaKey(int key) {  
491 - return tn3270_pakey(hSession, key);  
492 - }  
493 -  
494 - /// <summary>  
495 - /// Get screen width  
496 - /// </summary>  
497 - ///  
498 - /// <returns>  
499 - /// Screen width in characters (negative on error)  
500 - /// </returns>  
501 - ///  
502 - public int GetWidth() {  
503 - return tn3270_get_width(hSession);  
504 - }  
505 -  
506 - /// <summary>  
507 - /// Screen width in characters  
508 - /// </summary>  
509 - ///  
510 - /// <returns>  
511 - /// Screen width in characters (negative on error)  
512 - /// </returns>  
513 - ///  
514 - public int Width {  
515 - get {  
516 - return tn3270_get_width(hSession);  
517 - }  
518 - }  
519 -  
520 - /// <summary>  
521 - /// Get screen height  
522 - /// </summary>  
523 - ///  
524 - /// <returns>  
525 - /// Screen width in characters (negative on error)  
526 - /// </returns>  
527 - ///  
528 - public int GetHeight() {  
529 - return tn3270_get_height(hSession);  
530 - }  
531 -  
532 - /// <summary>  
533 - /// Screen height in characters  
534 - /// </summary>  
535 - ///  
536 - /// <returns>  
537 - /// Screen height in characters (negative on error)  
538 - /// </returns>  
539 - ///  
540 - public int Height {  
541 - get {  
542 - return tn3270_get_height(hSession);  
543 - }  
544 - }  
545 -  
546 - /// <summary>  
547 - /// Get length of terminal buffer (width * height)  
548 - /// </summary>  
549 - ///  
550 - /// <returns>  
551 - /// Terminal length in characters (negative on error)  
552 - /// </returns>  
553 - ///  
554 - public int GetLength() {  
555 - return tn3270_get_length(hSession);  
556 - }  
557 -  
558 - /// <summary>  
559 - /// Length of terminal buffer (width * height)  
560 - /// </summary>  
561 - ///  
562 - /// <returns>  
563 - /// Terminal length in characters (negative on error)  
564 - /// </returns>  
565 - ///  
566 - public int Length {  
567 - get {  
568 - return tn3270_get_length(hSession);  
569 - }  
570 - }  
571 -  
572 - public string CharSet {  
573 - set {  
574 - tn3270_set_charset(hSession,value);  
575 - }  
576 - }  
577 -  
578 - /// <summary>  
579 - /// 3270 host URL  
580 - /// </summary>  
581 - ///  
582 - /// <returns>  
583 - /// 3270 host URL  
584 - /// </returns>  
585 - ///  
586 - public string Url {  
587 - set {  
588 - tn3270_set_url(hSession,value);  
589 - }  
590 - get {  
591 - StringBuilder str = new StringBuilder(1025);  
592 - tn3270_get_url(hSession, str, 1024);  
593 - return str.ToString();  
594 - }  
595 - }  
596 -  
597 - /// <summary>  
598 - /// Last lib3270 error message  
599 - /// </summary>  
600 - ///  
601 - /// <returns>  
602 - /// Last lib3270 error message  
603 - /// </returns>  
604 - ///  
605 - public string Error {  
606 - set {  
607 - tn3270_set_error_message(hSession,value);  
608 - }  
609 - get {  
610 - StringBuilder str = new StringBuilder(1025);  
611 - tn3270_get_error_message(hSession, str, 1024);  
612 - return str.ToString();  
613 - }  
614 - }  
615 -  
616 - }  
617 -  
618 -}  
src/core/tn3270-sharp.pc.in
@@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
1 -prefix=${pcfiledir}/../..  
2 -exec_prefix=${prefix}  
3 -libdir=${exec_prefix}/lib  
4 -gapidir=${prefix}/share/tn3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@  
5 -  
6 -  
7 -Name: tn3270-sharp  
8 -Description: .NET Bindings for pw3270  
9 -Version: @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@  
10 -Cflags: -I:${gapidir}/tn3270-sharp.xml  
11 -Libs: -r:${libdir}/mono/tn3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@/tn3270-sharp.dll  
src/core/tn3270.cs 0 → 100644
@@ -0,0 +1,618 @@ @@ -0,0 +1,618 @@
  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 int tn3270_destroy_session(IntPtr session);
  55 +
  56 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  57 + extern static int tn3270_get_version(IntPtr session, StringBuilder str, int strlen);
  58 +
  59 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  60 + extern static int 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_is_ready(IntPtr Session);
  70 +
  71 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  72 + extern static int tn3270_disconnect(IntPtr Session);
  73 +
  74 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  75 + extern static int tn3270_wait_for_ready(IntPtr Session, int seconds);
  76 +
  77 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  78 + extern static int tn3270_wait(IntPtr Session, int seconds);
  79 +
  80 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  81 + extern static int tn3270_get_cstate(IntPtr Session);
  82 +
  83 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  84 + extern static int tn3270_get_program_message(IntPtr Session);
  85 +
  86 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  87 + extern static int tn3270_get_secure(IntPtr Session);
  88 +
  89 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  90 + extern static int tn3270_get_contents(IntPtr Session, StringBuilder str, int strlen);
  91 +
  92 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  93 + extern static int tn3270_get_string(IntPtr Session, int addr, StringBuilder str, int strlen);
  94 +
  95 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  96 + extern static int tn3270_get_string_at(IntPtr Session, int row, int col, StringBuilder str, int strlen);
  97 +
  98 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  99 + extern static int tn3270_set_string_at(IntPtr Session, int row, int col, string str);
  100 +
  101 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  102 + extern static int tn3270_wait_for_string_at(IntPtr Session, int row, int col, string key, int timeout);
  103 +
  104 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  105 + extern static int tn3270_cmp_string_at(IntPtr Session, int row, int col, string str);
  106 +
  107 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  108 + extern static int tn3270_set_unlock_delay(IntPtr Session, int ms);
  109 +
  110 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  111 + extern static int tn3270_set_cursor_position(IntPtr Session, int row, int col);
  112 +
  113 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  114 + extern static int tn3270_set_cursor_addr(IntPtr Session, int addr);
  115 +
  116 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  117 + extern static int tn3270_get_cursor_addr(IntPtr Session);
  118 +
  119 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  120 + extern static int tn3270_enter(IntPtr Session);
  121 +
  122 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  123 + extern static int tn3270_pfkey(IntPtr Session, int key);
  124 +
  125 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  126 + extern static int tn3270_pakey(IntPtr Session, int key);
  127 +
  128 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  129 + extern static int tn3270_get_width(IntPtr Session);
  130 +
  131 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  132 + extern static int tn3270_get_height(IntPtr Session);
  133 +
  134 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  135 + extern static int tn3270_get_length(IntPtr Session);
  136 +
  137 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  138 + extern static int tn3270_set_charset(IntPtr Session, string str);
  139 +
  140 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  141 + extern static int tn3270_set_url(IntPtr Session, string str);
  142 +
  143 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  144 + extern static int tn3270_get_url(IntPtr Session, StringBuilder str, int strlen);
  145 +
  146 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  147 + extern static int tn3270_set_error_message(IntPtr Session, string str);
  148 +
  149 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  150 + extern static int tn3270_get_error_message(IntPtr Session, StringBuilder str, int strlen);
  151 +
  152 + /// <summary>
  153 + /// Create a new session with lib3270/pw3270
  154 + /// </summary>
  155 + ///
  156 + /// <param name="name">Session name or empty string for a hidden session</param>
  157 + ///
  158 + public Session(string name) {
  159 + hSession = tn3270_create_session(name);
  160 + tn3270_set_charset(hSession,"UTF-8");
  161 + }
  162 +
  163 + /// <summary>
  164 + /// Disconnect from host, destroy session.
  165 + /// </summary>
  166 + ///
  167 + ~Session() {
  168 + tn3270_destroy_session(hSession);
  169 + }
  170 +
  171 + /// <summary>
  172 + /// Get lib3270/pw3270 Version identifier
  173 + /// </summary>
  174 + ///
  175 + /// <returns>
  176 + /// The version of the active instance.
  177 + /// </returns>
  178 + ///
  179 + public string GetVersion() {
  180 + StringBuilder str = new StringBuilder(10);
  181 + tn3270_get_version(hSession, str, 10);
  182 + return str.ToString();
  183 + }
  184 +
  185 + /// <summary>
  186 + /// Lib3270 version.
  187 + /// </summary>
  188 + ///
  189 + /// <returns>
  190 + /// Lib3270 version string
  191 + /// </returns>
  192 + ///
  193 + public string Version {
  194 + get {
  195 + return GetVersion();
  196 + }
  197 + }
  198 +
  199 + /// <summary>
  200 + /// Get lib3270/pw3270 Revision number
  201 + /// </summary>
  202 + ///
  203 + /// <returns>
  204 + /// The revision of the active instance.
  205 + /// </returns>
  206 + ///
  207 + public string GetRevision() {
  208 + StringBuilder str = new StringBuilder(10);
  209 + tn3270_get_revision(hSession, str, 10);
  210 + return str.ToString();
  211 + }
  212 +
  213 + public string Revision {
  214 + get {
  215 + return GetRevision();
  216 + }
  217 + }
  218 +
  219 + /// <summary>
  220 + /// Connect to 3270 host.
  221 + /// </summary>
  222 + ///
  223 + /// <param name="host">URL of the target host (tn3270://hostname:port)</param>
  224 + /// <param name="wait">How many seconds should the call wait for the connection becomes ready</param>
  225 + ///
  226 + /// <returns>
  227 + /// </returns>
  228 + ///
  229 + public int Connect(string host, int wait) {
  230 + return tn3270_connect(hSession, host, wait);
  231 + }
  232 +
  233 + /// <summary>
  234 + /// Get connection state
  235 + /// </summary>
  236 + ///
  237 + /// <returns>
  238 + /// true if the session is connected to a remote host.
  239 + /// </returns>
  240 + ///
  241 + public bool IsConnected() {
  242 + return tn3270_is_connected(hSession) != 0;
  243 + }
  244 +
  245 + public bool Connected {
  246 + get {
  247 + return tn3270_is_connected(hSession) != 0;
  248 + }
  249 + }
  250 +
  251 + public bool IsReady() {
  252 + return tn3270_is_ready(hSession) != 0;
  253 + }
  254 +
  255 + public bool Ready {
  256 + get {
  257 + return tn3270_is_ready(hSession) != 0;
  258 + }
  259 + }
  260 +
  261 + /// <summary>
  262 + /// Disconnect from 3270 host.
  263 + /// </summary>
  264 + ///
  265 + public int Disconnect() {
  266 + return tn3270_disconnect(hSession);
  267 + }
  268 +
  269 + /// <summary>
  270 + /// Wait for network activity
  271 + /// </summary>
  272 + ///
  273 + /// <param name="seconds">Seconds to wait</param>
  274 + ///
  275 + /// <returns>
  276 + ///
  277 + /// </returns>
  278 + ///
  279 + public int WaitForReady(int seconds) {
  280 + return tn3270_wait_for_ready(hSession, seconds);
  281 + }
  282 +
  283 + /// <summary>
  284 + /// "Sleep" keeping the network activity.
  285 + /// </summary>
  286 + ///
  287 + /// <param name="seconds">Number of seconds to wait</param>
  288 + ///
  289 + /// <returns>
  290 + ///
  291 + /// </returns>
  292 + ///
  293 + public int Wait(int seconds) {
  294 + return tn3270_wait(hSession, seconds);
  295 + }
  296 +
  297 + /// <summary>
  298 + /// Get contents
  299 + /// </summary>
  300 + ///
  301 + /// <returns>
  302 + /// Contents from terminal screen.
  303 + /// </returns>
  304 + ///
  305 + public override string ToString() {
  306 + int strlen = (tn3270_get_width(hSession)+1) * (tn3270_get_height(hSession)+1);
  307 + StringBuilder str = new StringBuilder(strlen+1);
  308 + strlen = tn3270_get_contents(hSession, str, strlen);
  309 + return str.ToString();
  310 + }
  311 +
  312 +
  313 + /// <summary>
  314 + /// Get contents at address
  315 + /// </summary>
  316 + ///
  317 + /// <param name="addr">Address of text in the screen buffer</param>
  318 + /// <param name="strlen">Number of characters to get</param>
  319 + ///
  320 + /// <returns>
  321 + /// Contents from terminal screen.
  322 + /// </returns>
  323 + ///
  324 + public string GetString(int addr, int strlen) {
  325 + StringBuilder str = new StringBuilder(strlen+1);
  326 + tn3270_get_string(hSession, addr, str, strlen);
  327 + return str.ToString();
  328 + }
  329 +
  330 + /// <summary>
  331 + /// Get contents at position.
  332 + /// </summary>
  333 + ///
  334 + /// <param name="row">Start row</param>
  335 + /// <param name="col">Start col</param>
  336 + /// <param name="strlen">Number of characters to get</param>
  337 + ///
  338 + /// <returns>
  339 + /// Contents from terminal screen.
  340 + /// </returns>
  341 + ///
  342 + public string GetStringAt(int row, int col, int strlen) {
  343 + StringBuilder str = new StringBuilder(strlen+1);
  344 + tn3270_get_string_at(hSession, row, col, str, strlen);
  345 + return str.ToString();
  346 + }
  347 +
  348 + /// <summary>
  349 + /// Set contents at position
  350 + /// </summary>
  351 + ///
  352 + /// <param name="row">Start row</param>
  353 + /// <param name="col">Start col</param>
  354 + /// <param name="str">Text to set</param>
  355 + ///
  356 + public void SetStringAt(int row, int col, string str) {
  357 + tn3270_set_string_at(hSession, row, col, str);
  358 + }
  359 +
  360 + /// <summary>
  361 + /// Wait for text at position.
  362 + /// </summary>
  363 + ///
  364 + /// <param name="row">Start row</param>
  365 + /// <param name="col">Start col</param>
  366 + /// <param name="str">Text to wait</param>
  367 + /// <param name="timeout">Seconds to wait</param>
  368 + ///
  369 + /// <returns>
  370 + ///
  371 + /// </returns>
  372 + ///
  373 + public int WaitForStringAt(int row, int col, string str, int timeout) {
  374 + return tn3270_wait_for_string_at(hSession, row, col, str, timeout);
  375 + }
  376 +
  377 + /// <summary>
  378 + /// Compare contents at position
  379 + /// </summary>
  380 + ///
  381 + /// <param name="row">Start row</param>
  382 + /// <param name="col">Start col</param>
  383 + /// <param name="str">Text to compare</param>
  384 + ///
  385 + /// <returns>
  386 + /// Result (0 = The strings are the same).
  387 + /// </returns>
  388 + ///
  389 + public int CmpStringAt(int row, int col, string str) {
  390 + return tn3270_cmp_string_at(hSession, row, col, str);
  391 + }
  392 +
  393 + /// <summary>
  394 + /// Set cursor position.
  395 + /// </summary>
  396 + ///
  397 + /// <param name="row">New cursor row</param>
  398 + /// <param name="col">New cursor column</param>
  399 + ///
  400 + public void SetCursorPosition(int row, int col) {
  401 + tn3270_set_cursor_position(hSession, row, col);
  402 + }
  403 +
  404 + /// <summary>
  405 + /// Set cursor position based on address.
  406 + /// </summary>
  407 + ///
  408 + /// <param name="addr">Address of the new cursor position</param>
  409 + ///
  410 + public void SetCursorPosition(int addr) {
  411 + tn3270_set_cursor_addr(hSession, addr);
  412 + }
  413 +
  414 + /// <summary>
  415 + /// Get cursor address
  416 + /// </summary>
  417 + ///
  418 + public int GetCursorPosition() {
  419 + return tn3270_get_cursor_addr(hSession);
  420 + }
  421 +
  422 + /// <summary>
  423 + /// Cursor address
  424 + /// </summary>
  425 + ///
  426 + public int CursorPosition {
  427 + set {
  428 + tn3270_set_cursor_addr(hSession, value);
  429 + }
  430 + get {
  431 + return tn3270_get_cursor_addr(hSession);
  432 + }
  433 + }
  434 +
  435 + /// <summary>
  436 + /// Set the "screen ready" delay
  437 + /// </summary>
  438 + ///
  439 + public int SetUnlockDelay(int ms) {
  440 + return tn3270_set_unlock_delay(hSession, ms);
  441 + }
  442 +
  443 + /// <summary>
  444 + /// Set the "screen ready" delay
  445 + /// </summary>
  446 + ///
  447 + public int UnlockDelay {
  448 + set {
  449 + tn3270_set_unlock_delay(hSession, value);
  450 + }
  451 + }
  452 +
  453 +
  454 + /// <summary>
  455 + /// Send "Enter" key
  456 + /// </summary>
  457 + ///
  458 + /// <returns>
  459 + ///
  460 + /// </returns>
  461 + ///
  462 + public int Enter() {
  463 + return tn3270_enter(hSession);
  464 + }
  465 +
  466 + /// <summary>
  467 + /// Send "PF" key
  468 + /// </summary>
  469 + ///
  470 + /// <param name="key">Key identifier 1=PF1, 2=PF2, ...</param>
  471 + ///
  472 + /// <returns>
  473 + ///
  474 + /// </returns>
  475 + ///
  476 + public int PfKey(int key) {
  477 + return tn3270_pfkey(hSession, key);
  478 + }
  479 +
  480 + /// <summary>
  481 + /// Send "PA" key
  482 + /// </summary>
  483 + ///
  484 + /// <param name="key">Key identifier 1=PA1, 2=PA2, ...</param>
  485 + ///
  486 + /// <returns>
  487 + ///
  488 + /// </returns>
  489 + ///
  490 + public int PaKey(int key) {
  491 + return tn3270_pakey(hSession, key);
  492 + }
  493 +
  494 + /// <summary>
  495 + /// Get screen width
  496 + /// </summary>
  497 + ///
  498 + /// <returns>
  499 + /// Screen width in characters (negative on error)
  500 + /// </returns>
  501 + ///
  502 + public int GetWidth() {
  503 + return tn3270_get_width(hSession);
  504 + }
  505 +
  506 + /// <summary>
  507 + /// Screen width in characters
  508 + /// </summary>
  509 + ///
  510 + /// <returns>
  511 + /// Screen width in characters (negative on error)
  512 + /// </returns>
  513 + ///
  514 + public int Width {
  515 + get {
  516 + return tn3270_get_width(hSession);
  517 + }
  518 + }
  519 +
  520 + /// <summary>
  521 + /// Get screen height
  522 + /// </summary>
  523 + ///
  524 + /// <returns>
  525 + /// Screen width in characters (negative on error)
  526 + /// </returns>
  527 + ///
  528 + public int GetHeight() {
  529 + return tn3270_get_height(hSession);
  530 + }
  531 +
  532 + /// <summary>
  533 + /// Screen height in characters
  534 + /// </summary>
  535 + ///
  536 + /// <returns>
  537 + /// Screen height in characters (negative on error)
  538 + /// </returns>
  539 + ///
  540 + public int Height {
  541 + get {
  542 + return tn3270_get_height(hSession);
  543 + }
  544 + }
  545 +
  546 + /// <summary>
  547 + /// Get length of terminal buffer (width * height)
  548 + /// </summary>
  549 + ///
  550 + /// <returns>
  551 + /// Terminal length in characters (negative on error)
  552 + /// </returns>
  553 + ///
  554 + public int GetLength() {
  555 + return tn3270_get_length(hSession);
  556 + }
  557 +
  558 + /// <summary>
  559 + /// Length of terminal buffer (width * height)
  560 + /// </summary>
  561 + ///
  562 + /// <returns>
  563 + /// Terminal length in characters (negative on error)
  564 + /// </returns>
  565 + ///
  566 + public int Length {
  567 + get {
  568 + return tn3270_get_length(hSession);
  569 + }
  570 + }
  571 +
  572 + public string CharSet {
  573 + set {
  574 + tn3270_set_charset(hSession,value);
  575 + }
  576 + }
  577 +
  578 + /// <summary>
  579 + /// 3270 host URL
  580 + /// </summary>
  581 + ///
  582 + /// <returns>
  583 + /// 3270 host URL
  584 + /// </returns>
  585 + ///
  586 + public string Url {
  587 + set {
  588 + tn3270_set_url(hSession,value);
  589 + }
  590 + get {
  591 + StringBuilder str = new StringBuilder(1025);
  592 + tn3270_get_url(hSession, str, 1024);
  593 + return str.ToString();
  594 + }
  595 + }
  596 +
  597 + /// <summary>
  598 + /// Last lib3270 error message
  599 + /// </summary>
  600 + ///
  601 + /// <returns>
  602 + /// Last lib3270 error message
  603 + /// </returns>
  604 + ///
  605 + public string Error {
  606 + set {
  607 + tn3270_set_error_message(hSession,value);
  608 + }
  609 + get {
  610 + StringBuilder str = new StringBuilder(1025);
  611 + tn3270_get_error_message(hSession, str, 1024);
  612 + return str.ToString();
  613 + }
  614 + }
  615 +
  616 + }
  617 +
  618 +}
src/testprograms/sample.cs
@@ -27,13 +27,13 @@ @@ -27,13 +27,13 @@
27 * 27 *
28 */ 28 */
29 29
30 -using pw3270; 30 +using tn3270;
31 31
32 class sample { 32 class sample {
33 33
34 static void Main(string[] args) { 34 static void Main(string[] args) {
35 35
36 - pw3270.Session host = new pw3270.Session(""); 36 + tn3270.Session host = new tn3270.Session("");
37 37
38 System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); 38 System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision);
39 System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); 39 System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")");