From efbab2e835b494cbb482e40c72ced0533e519558 Mon Sep 17 00:00:00 2001 From: PerryWerneck Date: Sun, 11 Dec 2016 05:17:05 -0200 Subject: [PATCH] Adicionando método para obter a URL de conexão. --- src/native/get.cc | 4 ++-- src/native/private.h | 6 ++++-- src/native/set.cc | 9 +++++++-- src/pw3270-sharp/pw3270-sharp.cs | 25 +++++++++++++++++-------- testprograms/sample.cs | 3 +-- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/native/get.cc b/src/native/get.cc index 1dfce9b..66ef118 100644 --- a/src/native/get.cc +++ b/src/native/get.cc @@ -74,7 +74,7 @@ return (int) ses->get_length(); } - int tn3270_get_display_charset(h3270::session *ses, char* str, int len) { - strncpy(str,ses->get_display_charset().c_str(),len); + int tn3270_get_url(h3270::session *ses, char* str, int strlen) { + strncpy(str,ses->get_url().c_str(),strlen); return 0; } diff --git a/src/native/private.h b/src/native/private.h index b2e46c9..4c35b26 100644 --- a/src/native/private.h +++ b/src/native/private.h @@ -80,6 +80,9 @@ DLL_PUBLIC int tn3270_is_connected(h3270::session *ses); DLL_PUBLIC int tn3270_is_ready(h3270::session *ses); + DLL_PUBLIC int tn3270_set_url(h3270::session *ses, const char *url); + DLL_PUBLIC int tn3270_get_url(h3270::session *ses, char* str, int strlen); + DLL_PUBLIC int tn3270_set_cursor_addr(h3270::session *ses, int addr); DLL_PUBLIC int tn3270_get_cursor_addr(h3270::session *ses); @@ -116,8 +119,7 @@ DLL_PUBLIC int tn3270_get_height(h3270::session *ses); DLL_PUBLIC int tn3270_get_length(h3270::session *ses); - DLL_PUBLIC int tn3270_set_display_charset(h3270::session *ses, const char* str); - DLL_PUBLIC int tn3270_get_display_charset(h3270::session *ses, char* str, int strlen); + DLL_PUBLIC int tn3270_set_charset(h3270::session *ses, const char* str); } diff --git a/src/native/set.cc b/src/native/set.cc index ea4e914..c0c2cad 100644 --- a/src/native/set.cc +++ b/src/native/set.cc @@ -46,10 +46,15 @@ int tn3270_set_cursor_addr(h3270::session *ses, int addr) { return 0; } -int tn3270_set_display_charset(h3270::session *ses, const char* str) { +int tn3270_set_charset(h3270::session *ses, const char* str) { debug("%s(%s)",__FUNCTION__,str); - ses->set_display_charset(0,str); + ses->set_display_charset(NULL, str); return 0; } +int tn3270_set_url(h3270::session *ses, const char *url) { + debug("%s(%s)",__FUNCTION__,url); + ses->set_url(url); + return 0; +} diff --git a/src/pw3270-sharp/pw3270-sharp.cs b/src/pw3270-sharp/pw3270-sharp.cs index 77080cd..6132b97 100644 --- a/src/pw3270-sharp/pw3270-sharp.cs +++ b/src/pw3270-sharp/pw3270-sharp.cs @@ -129,10 +129,13 @@ namespace pw3270 { extern static int tn3270_get_length(IntPtr Session); [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_set_display_charset(IntPtr Session, string str); + extern static int tn3270_set_charset(IntPtr Session, string str); [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_display_charset(IntPtr session, StringBuilder str, int strlen); + extern static int tn3270_set_url(IntPtr Session, string str); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_url(IntPtr Session, StringBuilder str, int strlen); /// /// Create a new session with lib3270/pw3270 @@ -142,6 +145,7 @@ namespace pw3270 { /// public Session(string name) { hSession = tn3270_create_session(name); + tn3270_set_charset(hSession,"UTF-8"); } /// @@ -442,16 +446,21 @@ namespace pw3270 { } public string CharSet { - get { - StringBuilder str = new StringBuilder(31); - tn3270_get_display_charset(hSession,str,30); - return str.ToString(); - } set { - tn3270_set_display_charset(hSession,value); + tn3270_set_charset(hSession,value); } } + public string Url { + set { + tn3270_set_charset(hSession,value); + } + get { + StringBuilder str = new StringBuilder(1025); + tn3270_get_url(hSession, str, 1024); + return str.ToString(); + } + } } diff --git a/testprograms/sample.cs b/testprograms/sample.cs index 5ab23bd..10daf2d 100644 --- a/testprograms/sample.cs +++ b/testprograms/sample.cs @@ -37,13 +37,12 @@ class sample { System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); - System.Console.WriteLine("The Charset is " + host.CharSet); host.Connect("tn3270://zos.efglobe.com:telnet",10); if(host.Connected) { - System.Console.WriteLine("Connected to host"); + System.Console.WriteLine("Connected to " + host.Url); System.Console.WriteLine(host.GetStringAt(14,19,38)); -- libgit2 0.21.2