Commit 0c602dc52a05ff0c4deec979c4ef6ba6f3cec624
1 parent
1086160d
Exists in
master
and in
5 other branches
Updating compatibility IPC library.
Showing
7 changed files
with
115 additions
and
108 deletions
Show diff stats
configure.ac
| @@ -403,8 +403,6 @@ dnl --------------------------------------------------------------------------- | @@ -403,8 +403,6 @@ dnl --------------------------------------------------------------------------- | ||
| 403 | dnl Lib3270 flags | 403 | dnl Lib3270 flags |
| 404 | dnl --------------------------------------------------------------------------- | 404 | dnl --------------------------------------------------------------------------- |
| 405 | 405 | ||
| 406 | -dnl AC_ARG_WITH([libname], [AS_HELP_STRING([--with-libname], [Setup library name])], [ app_cv_libname="$withval" ],[ app_cv_libname="3270" ]) | ||
| 407 | - | ||
| 408 | PKG_CHECK_MODULES( [LIB3270], [lib3270], app_cv_3270="yes", app_cv_3270="no" ) | 406 | PKG_CHECK_MODULES( [LIB3270], [lib3270], app_cv_3270="yes", app_cv_3270="no" ) |
| 409 | 407 | ||
| 410 | if test "$app_cv_3270" == "yes"; then | 408 | if test "$app_cv_3270" == "yes"; then |
| @@ -433,8 +431,10 @@ dnl AX_SUBDIRS_CONFIGURE([modules/libv3270],[[LIB3270_CFLAGS=-I$ac_pwd/modules/l | @@ -433,8 +431,10 @@ dnl AX_SUBDIRS_CONFIGURE([modules/libv3270],[[LIB3270_CFLAGS=-I$ac_pwd/modules/l | ||
| 433 | dnl AC_SUBST(LIBV3270_INCLUDEPATH,$ac_pwd/modules/libv3270/src/include) | 431 | dnl AC_SUBST(LIBV3270_INCLUDEPATH,$ac_pwd/modules/libv3270/src/include) |
| 434 | fi | 432 | fi |
| 435 | 433 | ||
| 436 | -dnl AC_DEFINE(LIB3270_NAME,$app_cv_libname) | ||
| 437 | -dnl AC_SUBST(LIB3270_NAME,$app_cv_libname) | 434 | +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` ]) |
| 435 | + | ||
| 436 | +AC_DEFINE_UNQUOTED(LIB3270_NAME,$app_cv_libname) | ||
| 437 | +AC_SUBST(LIB3270_NAME,$app_cv_libname) | ||
| 438 | 438 | ||
| 439 | AC_SUBST(PW3270_CFLAGS,-I$ac_pwd/src/include) | 439 | AC_SUBST(PW3270_CFLAGS,-I$ac_pwd/src/include) |
| 440 | AC_SUBST(PW3270_LIBS,-l$PACKAGE_TARNAME) | 440 | AC_SUBST(PW3270_LIBS,-l$PACKAGE_TARNAME) |
src/libpw3270cpp/Makefile.in
| @@ -65,6 +65,7 @@ CFLAGS= \ | @@ -65,6 +65,7 @@ CFLAGS= \ | ||
| 65 | @CFLAGS@ \ | 65 | @CFLAGS@ \ |
| 66 | -Wno-deprecated-declarations \ | 66 | -Wno-deprecated-declarations \ |
| 67 | -I$(BASEDIR)/src/include \ | 67 | -I$(BASEDIR)/src/include \ |
| 68 | + -DLIB3270_NAME="lib@LIB3270_NAME@" \ | ||
| 68 | @LIB3270_CFLAGS@ \ | 69 | @LIB3270_CFLAGS@ \ |
| 69 | @DBUS_CFLAGS@ \ | 70 | @DBUS_CFLAGS@ \ |
| 70 | @GTK_CFLAGS@ | 71 | @GTK_CFLAGS@ |
src/libpw3270cpp/local.cc
| @@ -50,6 +50,7 @@ | @@ -50,6 +50,7 @@ | ||
| 50 | 50 | ||
| 51 | #include <lib3270/log.h> | 51 | #include <lib3270/log.h> |
| 52 | #include <lib3270/popup.h> | 52 | #include <lib3270/popup.h> |
| 53 | +#include <lib3270/trace.h> | ||
| 53 | #include <string.h> | 54 | #include <string.h> |
| 54 | #include <stdio.h> | 55 | #include <stdio.h> |
| 55 | 56 | ||
| @@ -71,7 +72,7 @@ | @@ -71,7 +72,7 @@ | ||
| 71 | #endif // HAVE_SYSLOG | 72 | #endif // HAVE_SYSLOG |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | - static void tracehandler(H3270 *session, const char *fmt, va_list args) | 75 | + static void tracehandler(H3270 *session, void *dunno, const char *fmt, va_list args) |
| 75 | { | 76 | { |
| 76 | #ifdef HAVE_SYSLOG | 77 | #ifdef HAVE_SYSLOG |
| 77 | 78 | ||
| @@ -179,7 +180,7 @@ | @@ -179,7 +180,7 @@ | ||
| 179 | void load_methods() { | 180 | void load_methods() { |
| 180 | 181 | ||
| 181 | void (*set_log_handler)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list)); | 182 | void (*set_log_handler)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list)); |
| 182 | - void (*set_trace_handler)( void (*handler)(H3270 *session, const char *fmt, va_list args) ); | 183 | + void (*set_trace_handler)(H3270 *hSession, LIB3270_TRACE_HANDLER handler, void *userdata); |
| 183 | 184 | ||
| 184 | struct _call | 185 | struct _call |
| 185 | { | 186 | { |
| @@ -207,9 +208,11 @@ | @@ -207,9 +208,11 @@ | ||
| 207 | { (void **) & _pakey, "lib3270_pakey" }, | 208 | { (void **) & _pakey, "lib3270_pakey" }, |
| 208 | { (void **) & _wait_for_ready, "lib3270_wait_for_ready" }, | 209 | { (void **) & _wait_for_ready, "lib3270_wait_for_ready" }, |
| 209 | { (void **) & _get_text, "lib3270_get_string_at_address" }, | 210 | { (void **) & _get_text, "lib3270_get_string_at_address" }, |
| 210 | - { (void **) & _get_text_at, "lib3270_get_text_at" }, | 211 | + |
| 212 | + { (void **) & _get_text_at, "lib3270_get_string_at" }, | ||
| 211 | { (void **) & _cmp_text_at, "lib3270_cmp_text_at" }, | 213 | { (void **) & _cmp_text_at, "lib3270_cmp_text_at" }, |
| 212 | { (void **) & _set_text_at, "lib3270_set_string_at" }, | 214 | { (void **) & _set_text_at, "lib3270_set_string_at" }, |
| 215 | + | ||
| 213 | { (void **) & _is_ready, "lib3270_is_ready" }, | 216 | { (void **) & _is_ready, "lib3270_is_ready" }, |
| 214 | { (void **) & _set_cursor_position, "lib3270_set_cursor_position" }, | 217 | { (void **) & _set_cursor_position, "lib3270_set_cursor_position" }, |
| 215 | { (void **) & _set_toggle, "lib3270_set_toggle" }, | 218 | { (void **) & _set_toggle, "lib3270_set_toggle" }, |
| @@ -254,7 +257,7 @@ | @@ -254,7 +257,7 @@ | ||
| 254 | 257 | ||
| 255 | // Get Session handle, setup base callbacks | 258 | // Get Session handle, setup base callbacks |
| 256 | set_log_handler(loghandler); | 259 | set_log_handler(loghandler); |
| 257 | - set_trace_handler(tracehandler); | 260 | + set_trace_handler(this->hSession, tracehandler, NULL); |
| 258 | 261 | ||
| 259 | set_display_charset(); | 262 | set_display_charset(); |
| 260 | 263 | ||
| @@ -262,7 +265,7 @@ | @@ -262,7 +265,7 @@ | ||
| 262 | 265 | ||
| 263 | public: | 266 | public: |
| 264 | 267 | ||
| 265 | - local() : module("lib3270",PACKAGE_VERSION) | 268 | + local() : module(LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME),PACKAGE_VERSION) |
| 266 | { | 269 | { |
| 267 | } | 270 | } |
| 268 | 271 |
src/libpw3270cpp/module.cc
| @@ -172,6 +172,7 @@ namespace PW3270_NAMESPACE | @@ -172,6 +172,7 @@ namespace PW3270_NAMESPACE | ||
| 172 | 172 | ||
| 173 | dlerror(); | 173 | dlerror(); |
| 174 | 174 | ||
| 175 | + trace("Loading %s",dllname.c_str()); | ||
| 175 | hModule = dlopen(dllname.c_str(), RTLD_NOW); | 176 | hModule = dlopen(dllname.c_str(), RTLD_NOW); |
| 176 | if(!hModule) | 177 | if(!hModule) |
| 177 | throw exception("Can't load lib3270: %s",dllname.c_str()); | 178 | throw exception("Can't load lib3270: %s",dllname.c_str()); |
src/libpw3270cpp/remote.cc
| @@ -611,120 +611,123 @@ | @@ -611,120 +611,123 @@ | ||
| 611 | char * ptr; | 611 | char * ptr; |
| 612 | string busName; | 612 | string busName; |
| 613 | 613 | ||
| 614 | + | ||
| 615 | + this->path = nullptr; | ||
| 616 | + this->intf = nullptr; | ||
| 614 | this->sequence = (++sq) + time(0); | 617 | this->sequence = (++sq) + time(0); |
| 615 | 618 | ||
| 616 | - trace("%s str=%p sequence=%d",__FUNCTION__,str,sequence); | 619 | + try { |
| 617 | 620 | ||
| 618 | - for(ptr=str;*ptr;ptr++) | ||
| 619 | - *ptr = tolower(*ptr); | 621 | + trace("%s str=%p sequence=%d",__FUNCTION__,str,sequence); |
| 620 | 622 | ||
| 621 | - ptr = strchr(str,':'); | 623 | + for(ptr=str;*ptr;ptr++) |
| 624 | + *ptr = tolower(*ptr); | ||
| 622 | 625 | ||
| 623 | - if(ptr) | ||
| 624 | - { | ||
| 625 | - size_t sz; | ||
| 626 | - | ||
| 627 | - *(ptr++) = 0; | ||
| 628 | - | ||
| 629 | - // Build destination | ||
| 630 | - sz = strlen(ptr)+strlen(str)+strlen(prefix_dest)+2; | ||
| 631 | - dest = (char *) malloc(sz+1); | ||
| 632 | - strncpy(dest,prefix_dest,sz); | ||
| 633 | - strncat(dest,str,sz); | ||
| 634 | - strncat(dest,".",sz); | ||
| 635 | - strncat(dest,ptr,sz); | ||
| 636 | - | ||
| 637 | - // Path and interface always use the same name. | ||
| 638 | - path = strdup("/br/com/bb/pw3270"); | ||
| 639 | - intf = strdup("br.com.bb.pw3270"); | ||
| 640 | - | ||
| 641 | - /* | ||
| 642 | - // Build path | ||
| 643 | - sz = strlen(str)+strlen(prefix_path); | ||
| 644 | - path = (char *) malloc(sz+1); | ||
| 645 | - strncpy(path,prefix_path,sz); | ||
| 646 | - strncat(path,str,sz); | ||
| 647 | - | ||
| 648 | - // Build intf | ||
| 649 | - sz = strlen(str)+strlen(prefix_dest)+1; | ||
| 650 | - intf = (char *) malloc(sz+1); | ||
| 651 | - strncpy(intf,prefix_dest,sz); | ||
| 652 | - strncat(intf,str,sz); | ||
| 653 | - */ | 626 | + ptr = strchr(str,':'); |
| 654 | 627 | ||
| 655 | - } | ||
| 656 | - else | ||
| 657 | - { | ||
| 658 | - size_t sz; | ||
| 659 | - | ||
| 660 | - // Build destination | ||
| 661 | - sz = strlen(str)+strlen(prefix_dest)+2; | ||
| 662 | - dest = (char *) malloc(sz+1); | ||
| 663 | - strncpy(dest,prefix_dest,sz); | ||
| 664 | - strncat(dest,str,sz); | ||
| 665 | - | ||
| 666 | - // Build path | ||
| 667 | - sz = strlen(str)+strlen(prefix_path); | ||
| 668 | - path = (char *) malloc(sz+1); | ||
| 669 | - strncpy(path,prefix_path,sz); | ||
| 670 | - strncat(path,str,sz); | ||
| 671 | - | ||
| 672 | - // Build intf | ||
| 673 | - sz = strlen(str)+strlen(prefix_dest)+1; | ||
| 674 | - intf = (char *) malloc(sz+1); | ||
| 675 | - strncpy(intf,prefix_dest,sz); | ||
| 676 | - strncat(intf,str,sz); | 628 | + if(ptr) |
| 629 | + { | ||
| 630 | + size_t sz; | ||
| 677 | 631 | ||
| 678 | - } | 632 | + *(ptr++) = 0; |
| 679 | 633 | ||
| 680 | - trace("DBUS:\nDestination:\t[%s]\nPath:\t\t[%s]\nInterface:\t[%s]",dest,path,intf); | 634 | + // Build destination |
| 635 | + sz = strlen(ptr)+strlen(str)+strlen(prefix_dest)+2; | ||
| 636 | + dest = (char *) malloc(sz+1); | ||
| 637 | + strncpy(dest,prefix_dest,sz); | ||
| 638 | + strncat(dest,str,sz); | ||
| 639 | + strncat(dest,".",sz); | ||
| 640 | + strncat(dest,ptr,sz); | ||
| 681 | 641 | ||
| 682 | - free(str); | 642 | + // Path and interface always use the same name. |
| 643 | + path = strdup("/br/com/bb/pw3270"); | ||
| 644 | + intf = strdup("br.com.bb.pw3270"); | ||
| 683 | 645 | ||
| 684 | - dbus_error_init(&err); | 646 | + } |
| 647 | + else | ||
| 648 | + { | ||
| 649 | + size_t sz; | ||
| 650 | + | ||
| 651 | + // Build destination | ||
| 652 | + sz = strlen(str)+strlen(prefix_dest)+2; | ||
| 653 | + dest = (char *) malloc(sz+1); | ||
| 654 | + strncpy(dest,prefix_dest,sz); | ||
| 655 | + strncat(dest,str,sz); | ||
| 656 | + | ||
| 657 | + // Build path | ||
| 658 | + sz = strlen(str)+strlen(prefix_path); | ||
| 659 | + path = (char *) malloc(sz+1); | ||
| 660 | + strncpy(path,prefix_path,sz); | ||
| 661 | + strncat(path,str,sz); | ||
| 662 | + | ||
| 663 | + // Build intf | ||
| 664 | + sz = strlen(str)+strlen(prefix_dest)+1; | ||
| 665 | + intf = (char *) malloc(sz+1); | ||
| 666 | + strncpy(intf,prefix_dest,sz); | ||
| 667 | + strncat(intf,str,sz); | ||
| 685 | 668 | ||
| 686 | - conn = dbus_bus_get(DBUS_BUS_SESSION, &err); | ||
| 687 | - trace("dbus_bus_get conn=%p",conn); | 669 | + } |
| 688 | 670 | ||
| 689 | - if (dbus_error_is_set(&err)) | ||
| 690 | - { | ||
| 691 | - exception e = exception("DBUS Connection Error (%s)", err.message); | ||
| 692 | - dbus_error_free(&err); | ||
| 693 | - throw e; | ||
| 694 | - return; | ||
| 695 | - } | 671 | + trace("DBUS:\nDestination:\t[%s]\nPath:\t\t[%s]\nInterface:\t[%s]",dest,path,intf); |
| 696 | 672 | ||
| 697 | - if(!conn) | ||
| 698 | - { | ||
| 699 | - throw exception("%s", "DBUS Connection failed"); | ||
| 700 | - return; | ||
| 701 | - } | 673 | + free(str); |
| 702 | 674 | ||
| 675 | + dbus_error_init(&err); | ||
| 703 | 676 | ||
| 704 | - rc = dbus_bus_request_name(conn, makeBusName(busName), DBUS_NAME_FLAG_REPLACE_EXISTING , &err); | ||
| 705 | - trace("dbus_bus_request_name(%s) rc=%d",busName.c_str(),rc); | 677 | + conn = dbus_bus_get(DBUS_BUS_SESSION, &err); |
| 678 | + trace("dbus_bus_get conn=%p",conn); | ||
| 706 | 679 | ||
| 707 | - if (dbus_error_is_set(&err)) | ||
| 708 | - { | ||
| 709 | - exception e = exception("Name Error (%s)", err.message); | ||
| 710 | - dbus_error_free(&err); | ||
| 711 | - throw e; | ||
| 712 | - return; | ||
| 713 | - } | 680 | + if (dbus_error_is_set(&err)) |
| 681 | + { | ||
| 682 | + exception e = exception("DBUS Connection Error (%s)", err.message); | ||
| 683 | + dbus_error_free(&err); | ||
| 684 | + throw e; | ||
| 685 | + return; | ||
| 686 | + } | ||
| 714 | 687 | ||
| 715 | - if(rc != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) | ||
| 716 | - { | ||
| 717 | - trace("%s: DBUS request for name %s failed",__FUNCTION__, busName.c_str()); | ||
| 718 | - throw exception("DBUS request for \"%s\" failed",session); | ||
| 719 | - return; | ||
| 720 | - } | 688 | + if(!conn) |
| 689 | + { | ||
| 690 | + throw exception("%s", "DBUS Connection failed"); | ||
| 691 | + return; | ||
| 692 | + } | ||
| 693 | + | ||
| 694 | + | ||
| 695 | + rc = dbus_bus_request_name(conn, makeBusName(busName), DBUS_NAME_FLAG_REPLACE_EXISTING , &err); | ||
| 696 | + trace("dbus_bus_request_name(%s) rc=%d",busName.c_str(),rc); | ||
| 697 | + | ||
| 698 | + if (dbus_error_is_set(&err)) | ||
| 699 | + { | ||
| 700 | + exception e = exception("Name Error (%s)", err.message); | ||
| 701 | + dbus_error_free(&err); | ||
| 702 | + throw e; | ||
| 703 | + return; | ||
| 704 | + } | ||
| 721 | 705 | ||
| 722 | - trace("%s: Using DBUS name %s",__FUNCTION__,busName.c_str()); | 706 | + if(rc != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) |
| 707 | + { | ||
| 708 | + trace("%s: DBUS request for name %s failed",__FUNCTION__, busName.c_str()); | ||
| 709 | + throw exception("DBUS request for \"%s\" failed",session); | ||
| 710 | + } | ||
| 723 | 711 | ||
| 724 | - const char * id = "r"; | ||
| 725 | - static const dbus_int32_t flag = 1; | ||
| 726 | - query_intval("setScript", DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID); | 712 | + trace("%s: Using DBUS name %s",__FUNCTION__,busName.c_str()); |
| 713 | + | ||
| 714 | + const char * id = "r"; | ||
| 715 | + static const dbus_int32_t flag = 1; | ||
| 716 | + query_intval("setScript", DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID); | ||
| 727 | 717 | ||
| 718 | + } catch(...) { | ||
| 719 | + | ||
| 720 | + if(path) { | ||
| 721 | + free(path); | ||
| 722 | + path = nullptr; | ||
| 723 | + } | ||
| 724 | + | ||
| 725 | + if(intf) { | ||
| 726 | + free(intf); | ||
| 727 | + intf = nullptr; | ||
| 728 | + } | ||
| 729 | + | ||
| 730 | + } | ||
| 728 | 731 | ||
| 729 | #else | 732 | #else |
| 730 | 733 |
src/libpw3270cpp/testprogram.cc
| @@ -43,8 +43,8 @@ | @@ -43,8 +43,8 @@ | ||
| 43 | { | 43 | { |
| 44 | string s; | 44 | string s; |
| 45 | // session *session = session::start("service://?"); | 45 | // session *session = session::start("service://?"); |
| 46 | - // session *session = session::start(""); | ||
| 47 | - session *session = session::start("pw3270:A"); | 46 | + session *session = session::start(""); |
| 47 | + // session *session = session::start("pw3270:A"); | ||
| 48 | 48 | ||
| 49 | string name = session->get_session_name(); | 49 | string name = session->get_session_name(); |
| 50 | 50 |
win/pw3270.nsi.in
| @@ -140,10 +140,9 @@ SubSection "@PACKAGE@" SecMain | @@ -140,10 +140,9 @@ SubSection "@PACKAGE@" SecMain | ||
| 140 | 140 | ||
| 141 | ${DisableX64FSRedirection} | 141 | ${DisableX64FSRedirection} |
| 142 | CreateDirectory "$INSTDIR\plugins" | 142 | CreateDirectory "$INSTDIR\plugins" |
| 143 | - file "/oname=$INSTDIR\plugins\ipc3270c.dll" "bin\ipc3270c.dll" | ||
| 144 | 143 | ||
| 145 | - ${EnableX64FSRedirection} | ||
| 146 | - file "/oname=$SYSDIR\libhllapi.dll" "bin\libhllapi.dll" | 144 | + file "/oname=$INSTDIR\plugins\ipc3270c.dll" "bin\ipc3270c.dll" |
| 145 | + file "/oname=$SYSDIR\libhllapi.dll" "bin\libhllapi.dll" | ||
| 147 | 146 | ||
| 148 | sectionEnd | 147 | sectionEnd |
| 149 | 148 |