Commit efbab2e835b494cbb482e40c72ced0533e519558

Authored by Perry Werneck
1 parent 16ffc652
Exists in master

Adicionando método para obter a URL de conexão.

src/native/get.cc
... ... @@ -74,7 +74,7 @@
74 74 return (int) ses->get_length();
75 75 }
76 76  
77   - int tn3270_get_display_charset(h3270::session *ses, char* str, int len) {
78   - strncpy(str,ses->get_display_charset().c_str(),len);
  77 + int tn3270_get_url(h3270::session *ses, char* str, int strlen) {
  78 + strncpy(str,ses->get_url().c_str(),strlen);
79 79 return 0;
80 80 }
... ...
src/native/private.h
... ... @@ -80,6 +80,9 @@
80 80 DLL_PUBLIC int tn3270_is_connected(h3270::session *ses);
81 81 DLL_PUBLIC int tn3270_is_ready(h3270::session *ses);
82 82  
  83 + DLL_PUBLIC int tn3270_set_url(h3270::session *ses, const char *url);
  84 + DLL_PUBLIC int tn3270_get_url(h3270::session *ses, char* str, int strlen);
  85 +
83 86 DLL_PUBLIC int tn3270_set_cursor_addr(h3270::session *ses, int addr);
84 87 DLL_PUBLIC int tn3270_get_cursor_addr(h3270::session *ses);
85 88  
... ... @@ -116,8 +119,7 @@
116 119 DLL_PUBLIC int tn3270_get_height(h3270::session *ses);
117 120 DLL_PUBLIC int tn3270_get_length(h3270::session *ses);
118 121  
119   - DLL_PUBLIC int tn3270_set_display_charset(h3270::session *ses, const char* str);
120   - DLL_PUBLIC int tn3270_get_display_charset(h3270::session *ses, char* str, int strlen);
  122 + DLL_PUBLIC int tn3270_set_charset(h3270::session *ses, const char* str);
121 123  
122 124 }
123 125  
... ...
src/native/set.cc
... ... @@ -46,10 +46,15 @@ int tn3270_set_cursor_addr(h3270::session *ses, int addr) {
46 46 return 0;
47 47 }
48 48  
49   -int tn3270_set_display_charset(h3270::session *ses, const char* str) {
  49 +int tn3270_set_charset(h3270::session *ses, const char* str) {
50 50 debug("%s(%s)",__FUNCTION__,str);
51   - ses->set_display_charset(0,str);
  51 + ses->set_display_charset(NULL, str);
52 52 return 0;
53 53 }
54 54  
  55 +int tn3270_set_url(h3270::session *ses, const char *url) {
  56 + debug("%s(%s)",__FUNCTION__,url);
  57 + ses->set_url(url);
  58 + return 0;
  59 +}
55 60  
... ...
src/pw3270-sharp/pw3270-sharp.cs
... ... @@ -129,10 +129,13 @@ namespace pw3270 {
129 129 extern static int tn3270_get_length(IntPtr Session);
130 130  
131 131 [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
132   - extern static int tn3270_set_display_charset(IntPtr Session, string str);
  132 + extern static int tn3270_set_charset(IntPtr Session, string str);
133 133  
134 134 [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
135   - extern static int tn3270_get_display_charset(IntPtr session, StringBuilder str, int strlen);
  135 + extern static int tn3270_set_url(IntPtr Session, string str);
  136 +
  137 + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)]
  138 + extern static int tn3270_get_url(IntPtr Session, StringBuilder str, int strlen);
136 139  
137 140 /// <summary>
138 141 /// Create a new session with lib3270/pw3270
... ... @@ -142,6 +145,7 @@ namespace pw3270 {
142 145 ///
143 146 public Session(string name) {
144 147 hSession = tn3270_create_session(name);
  148 + tn3270_set_charset(hSession,"UTF-8");
145 149 }
146 150  
147 151 /// <summary>
... ... @@ -442,16 +446,21 @@ namespace pw3270 {
442 446 }
443 447  
444 448 public string CharSet {
445   - get {
446   - StringBuilder str = new StringBuilder(31);
447   - tn3270_get_display_charset(hSession,str,30);
448   - return str.ToString();
449   - }
450 449 set {
451   - tn3270_set_display_charset(hSession,value);
  450 + tn3270_set_charset(hSession,value);
452 451 }
453 452 }
454 453  
  454 + public string Url {
  455 + set {
  456 + tn3270_set_charset(hSession,value);
  457 + }
  458 + get {
  459 + StringBuilder str = new StringBuilder(1025);
  460 + tn3270_get_url(hSession, str, 1024);
  461 + return str.ToString();
  462 + }
  463 + }
455 464  
456 465 }
457 466  
... ...
testprograms/sample.cs
... ... @@ -37,13 +37,12 @@ class sample {
37 37  
38 38 System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision);
39 39 System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")");
40   - System.Console.WriteLine("The Charset is " + host.CharSet);
41 40  
42 41 host.Connect("tn3270://zos.efglobe.com:telnet",10);
43 42  
44 43 if(host.Connected) {
45 44  
46   - System.Console.WriteLine("Connected to host");
  45 + System.Console.WriteLine("Connected to " + host.Url);
47 46  
48 47 System.Console.WriteLine(host.GetStringAt(14,19,38));
49 48  
... ...