diff --git a/configure.ac b/configure.ac index 1db259f..e9e58c7 100644 --- a/configure.ac +++ b/configure.ac @@ -403,8 +403,6 @@ dnl --------------------------------------------------------------------------- dnl Lib3270 flags dnl --------------------------------------------------------------------------- -dnl AC_ARG_WITH([libname], [AS_HELP_STRING([--with-libname], [Setup library name])], [ app_cv_libname="$withval" ],[ app_cv_libname="3270" ]) - PKG_CHECK_MODULES( [LIB3270], [lib3270], app_cv_3270="yes", app_cv_3270="no" ) if test "$app_cv_3270" == "yes"; then @@ -433,8 +431,10 @@ dnl AX_SUBDIRS_CONFIGURE([modules/libv3270],[[LIB3270_CFLAGS=-I$ac_pwd/modules/l dnl AC_SUBST(LIBV3270_INCLUDEPATH,$ac_pwd/modules/libv3270/src/include) fi -dnl AC_DEFINE(LIB3270_NAME,$app_cv_libname) -dnl AC_SUBST(LIB3270_NAME,$app_cv_libname) +AC_ARG_WITH([libname], [AS_HELP_STRING([--with-libname], [Setup library name])], [ app_cv_libname="$withval" ],[ app_cv_libname=`$PKG_CONFIG --variable=library_name lib3270` ]) + +AC_DEFINE_UNQUOTED(LIB3270_NAME,$app_cv_libname) +AC_SUBST(LIB3270_NAME,$app_cv_libname) AC_SUBST(PW3270_CFLAGS,-I$ac_pwd/src/include) AC_SUBST(PW3270_LIBS,-l$PACKAGE_TARNAME) diff --git a/src/libpw3270cpp/Makefile.in b/src/libpw3270cpp/Makefile.in index f972ad9..f4b3322 100644 --- a/src/libpw3270cpp/Makefile.in +++ b/src/libpw3270cpp/Makefile.in @@ -65,6 +65,7 @@ CFLAGS= \ @CFLAGS@ \ -Wno-deprecated-declarations \ -I$(BASEDIR)/src/include \ + -DLIB3270_NAME="lib@LIB3270_NAME@" \ @LIB3270_CFLAGS@ \ @DBUS_CFLAGS@ \ @GTK_CFLAGS@ diff --git a/src/libpw3270cpp/local.cc b/src/libpw3270cpp/local.cc index 10c835b..a14c161 100644 --- a/src/libpw3270cpp/local.cc +++ b/src/libpw3270cpp/local.cc @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -71,7 +72,7 @@ #endif // HAVE_SYSLOG } - static void tracehandler(H3270 *session, const char *fmt, va_list args) + static void tracehandler(H3270 *session, void *dunno, const char *fmt, va_list args) { #ifdef HAVE_SYSLOG @@ -179,7 +180,7 @@ void load_methods() { void (*set_log_handler)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list)); - void (*set_trace_handler)( void (*handler)(H3270 *session, const char *fmt, va_list args) ); + void (*set_trace_handler)(H3270 *hSession, LIB3270_TRACE_HANDLER handler, void *userdata); struct _call { @@ -207,9 +208,11 @@ { (void **) & _pakey, "lib3270_pakey" }, { (void **) & _wait_for_ready, "lib3270_wait_for_ready" }, { (void **) & _get_text, "lib3270_get_string_at_address" }, - { (void **) & _get_text_at, "lib3270_get_text_at" }, + + { (void **) & _get_text_at, "lib3270_get_string_at" }, { (void **) & _cmp_text_at, "lib3270_cmp_text_at" }, { (void **) & _set_text_at, "lib3270_set_string_at" }, + { (void **) & _is_ready, "lib3270_is_ready" }, { (void **) & _set_cursor_position, "lib3270_set_cursor_position" }, { (void **) & _set_toggle, "lib3270_set_toggle" }, @@ -254,7 +257,7 @@ // Get Session handle, setup base callbacks set_log_handler(loghandler); - set_trace_handler(tracehandler); + set_trace_handler(this->hSession, tracehandler, NULL); set_display_charset(); @@ -262,7 +265,7 @@ public: - local() : module("lib3270",PACKAGE_VERSION) + local() : module(LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME),PACKAGE_VERSION) { } diff --git a/src/libpw3270cpp/module.cc b/src/libpw3270cpp/module.cc index f821ac5..0517ffe 100644 --- a/src/libpw3270cpp/module.cc +++ b/src/libpw3270cpp/module.cc @@ -172,6 +172,7 @@ namespace PW3270_NAMESPACE dlerror(); + trace("Loading %s",dllname.c_str()); hModule = dlopen(dllname.c_str(), RTLD_NOW); if(!hModule) throw exception("Can't load lib3270: %s",dllname.c_str()); diff --git a/src/libpw3270cpp/remote.cc b/src/libpw3270cpp/remote.cc index fdb3ea1..cc8c2ba 100644 --- a/src/libpw3270cpp/remote.cc +++ b/src/libpw3270cpp/remote.cc @@ -611,120 +611,123 @@ char * ptr; string busName; + + this->path = nullptr; + this->intf = nullptr; this->sequence = (++sq) + time(0); - trace("%s str=%p sequence=%d",__FUNCTION__,str,sequence); + try { - for(ptr=str;*ptr;ptr++) - *ptr = tolower(*ptr); + trace("%s str=%p sequence=%d",__FUNCTION__,str,sequence); - ptr = strchr(str,':'); + for(ptr=str;*ptr;ptr++) + *ptr = tolower(*ptr); - if(ptr) - { - size_t sz; - - *(ptr++) = 0; - - // Build destination - sz = strlen(ptr)+strlen(str)+strlen(prefix_dest)+2; - dest = (char *) malloc(sz+1); - strncpy(dest,prefix_dest,sz); - strncat(dest,str,sz); - strncat(dest,".",sz); - strncat(dest,ptr,sz); - - // Path and interface always use the same name. - path = strdup("/br/com/bb/pw3270"); - intf = strdup("br.com.bb.pw3270"); - - /* - // Build path - sz = strlen(str)+strlen(prefix_path); - path = (char *) malloc(sz+1); - strncpy(path,prefix_path,sz); - strncat(path,str,sz); - - // Build intf - sz = strlen(str)+strlen(prefix_dest)+1; - intf = (char *) malloc(sz+1); - strncpy(intf,prefix_dest,sz); - strncat(intf,str,sz); - */ + ptr = strchr(str,':'); - } - else - { - size_t sz; - - // Build destination - sz = strlen(str)+strlen(prefix_dest)+2; - dest = (char *) malloc(sz+1); - strncpy(dest,prefix_dest,sz); - strncat(dest,str,sz); - - // Build path - sz = strlen(str)+strlen(prefix_path); - path = (char *) malloc(sz+1); - strncpy(path,prefix_path,sz); - strncat(path,str,sz); - - // Build intf - sz = strlen(str)+strlen(prefix_dest)+1; - intf = (char *) malloc(sz+1); - strncpy(intf,prefix_dest,sz); - strncat(intf,str,sz); + if(ptr) + { + size_t sz; - } + *(ptr++) = 0; - trace("DBUS:\nDestination:\t[%s]\nPath:\t\t[%s]\nInterface:\t[%s]",dest,path,intf); + // Build destination + sz = strlen(ptr)+strlen(str)+strlen(prefix_dest)+2; + dest = (char *) malloc(sz+1); + strncpy(dest,prefix_dest,sz); + strncat(dest,str,sz); + strncat(dest,".",sz); + strncat(dest,ptr,sz); - free(str); + // Path and interface always use the same name. + path = strdup("/br/com/bb/pw3270"); + intf = strdup("br.com.bb.pw3270"); - dbus_error_init(&err); + } + else + { + size_t sz; + + // Build destination + sz = strlen(str)+strlen(prefix_dest)+2; + dest = (char *) malloc(sz+1); + strncpy(dest,prefix_dest,sz); + strncat(dest,str,sz); + + // Build path + sz = strlen(str)+strlen(prefix_path); + path = (char *) malloc(sz+1); + strncpy(path,prefix_path,sz); + strncat(path,str,sz); + + // Build intf + sz = strlen(str)+strlen(prefix_dest)+1; + intf = (char *) malloc(sz+1); + strncpy(intf,prefix_dest,sz); + strncat(intf,str,sz); - conn = dbus_bus_get(DBUS_BUS_SESSION, &err); - trace("dbus_bus_get conn=%p",conn); + } - if (dbus_error_is_set(&err)) - { - exception e = exception("DBUS Connection Error (%s)", err.message); - dbus_error_free(&err); - throw e; - return; - } + trace("DBUS:\nDestination:\t[%s]\nPath:\t\t[%s]\nInterface:\t[%s]",dest,path,intf); - if(!conn) - { - throw exception("%s", "DBUS Connection failed"); - return; - } + free(str); + dbus_error_init(&err); - rc = dbus_bus_request_name(conn, makeBusName(busName), DBUS_NAME_FLAG_REPLACE_EXISTING , &err); - trace("dbus_bus_request_name(%s) rc=%d",busName.c_str(),rc); + conn = dbus_bus_get(DBUS_BUS_SESSION, &err); + trace("dbus_bus_get conn=%p",conn); - if (dbus_error_is_set(&err)) - { - exception e = exception("Name Error (%s)", err.message); - dbus_error_free(&err); - throw e; - return; - } + if (dbus_error_is_set(&err)) + { + exception e = exception("DBUS Connection Error (%s)", err.message); + dbus_error_free(&err); + throw e; + return; + } - if(rc != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) - { - trace("%s: DBUS request for name %s failed",__FUNCTION__, busName.c_str()); - throw exception("DBUS request for \"%s\" failed",session); - return; - } + if(!conn) + { + throw exception("%s", "DBUS Connection failed"); + return; + } + + + rc = dbus_bus_request_name(conn, makeBusName(busName), DBUS_NAME_FLAG_REPLACE_EXISTING , &err); + trace("dbus_bus_request_name(%s) rc=%d",busName.c_str(),rc); + + if (dbus_error_is_set(&err)) + { + exception e = exception("Name Error (%s)", err.message); + dbus_error_free(&err); + throw e; + return; + } - trace("%s: Using DBUS name %s",__FUNCTION__,busName.c_str()); + if(rc != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) + { + trace("%s: DBUS request for name %s failed",__FUNCTION__, busName.c_str()); + throw exception("DBUS request for \"%s\" failed",session); + } - const char * id = "r"; - static const dbus_int32_t flag = 1; - query_intval("setScript", DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID); + trace("%s: Using DBUS name %s",__FUNCTION__,busName.c_str()); + + const char * id = "r"; + static const dbus_int32_t flag = 1; + query_intval("setScript", DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID); + } catch(...) { + + if(path) { + free(path); + path = nullptr; + } + + if(intf) { + free(intf); + intf = nullptr; + } + + } #else diff --git a/src/libpw3270cpp/testprogram.cc b/src/libpw3270cpp/testprogram.cc index a9d5c5f..4adba0f 100644 --- a/src/libpw3270cpp/testprogram.cc +++ b/src/libpw3270cpp/testprogram.cc @@ -43,8 +43,8 @@ { string s; // session *session = session::start("service://?"); - // session *session = session::start(""); - session *session = session::start("pw3270:A"); + session *session = session::start(""); + // session *session = session::start("pw3270:A"); string name = session->get_session_name(); diff --git a/win/pw3270.nsi.in b/win/pw3270.nsi.in index c65f67f..ae6b158 100644 --- a/win/pw3270.nsi.in +++ b/win/pw3270.nsi.in @@ -140,10 +140,9 @@ SubSection "@PACKAGE@" SecMain ${DisableX64FSRedirection} CreateDirectory "$INSTDIR\plugins" - file "/oname=$INSTDIR\plugins\ipc3270c.dll" "bin\ipc3270c.dll" - ${EnableX64FSRedirection} - file "/oname=$SYSDIR\libhllapi.dll" "bin\libhllapi.dll" + file "/oname=$INSTDIR\plugins\ipc3270c.dll" "bin\ipc3270c.dll" + file "/oname=$SYSDIR\libhllapi.dll" "bin\libhllapi.dll" sectionEnd -- libgit2 0.21.2