diff --git a/src/classlib/local.cc b/src/classlib/local.cc index 88e2848..efafeb8 100644 --- a/src/classlib/local.cc +++ b/src/classlib/local.cc @@ -305,6 +305,8 @@ const char * (*_get_display_charset)(H3270 *hSession); int (*_set_host_charset)(H3270 *hSession, const char *name); const char * (*_get_host_charset)(H3270 *hSession); + int (*_print)(H3270 *hSession); + int (*_erase_eof)(H3270 *hSession); public: @@ -354,6 +356,8 @@ { (void **) & _get_display_charset, "lib3270_get_display_charset" }, { (void **) & _set_host_charset, "lib3270_set_host_charset" }, { (void **) & _get_host_charset, "lib3270_get_host_charset" }, + { (void **) & _erase_eof, "lib3270_eraseeof" }, + { (void **) & _print, "lib3270_print" }, }; @@ -561,6 +565,17 @@ return new string(_get_host_charset(hSession)); } + int erase_eof(void) + { + return _erase_eof(hSession); + } + + int print(void) + { + return _print(hSession); + } + + }; session * session::create_local(void) diff --git a/src/classlib/remote.cc b/src/classlib/remote.cc index 61a0753..0c1c72a 100644 --- a/src/classlib/remote.cc +++ b/src/classlib/remote.cc @@ -55,6 +55,8 @@ #define HLLAPI_PACKET_GET_CURSOR "getCursorAddress" #define HLLAPI_PACKET_ENTER "enter" #define HLLAPI_PACKET_QUIT "quit" + #define HLLAPI_PACKET_ERASE_EOF "eraseEOF" + #define HLLAPI_PACKET_PRINT "print" #endif // WIN32 #include @@ -300,7 +302,12 @@ // Get application path *appName = 0; - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) != ERROR_SUCCESS) + { + throw exception("Can't open key %s","HKLM\\Software\\pw3270"); + return; + } + else { unsigned long datatype; // #defined in winnt.h (predefined types 0-11) if(RegQueryValueExA(hKey,"appName",NULL,&datatype,(LPBYTE) appName,&datalen) != ERROR_SUCCESS) @@ -308,6 +315,12 @@ RegCloseKey(hKey); } + if(!*appName) + { + throw exception("key %s\\appName is invalid","HKLM\\Software\\pw3270"); + return; + } + trace("%s appname=%s\n",__FUNCTION__,appName); snprintf(buffer,79,"%s --session=\"H%06d\"",appName,getpid()); @@ -327,7 +340,7 @@ } else { - throw exception("Can't start %s session",PACKAGE_NAME); + throw exception("Can't start %s",appName); return; } @@ -354,11 +367,11 @@ free(str); - timer = time(0)+5; + timer = time(0)+20; while(hPipe == INVALID_HANDLE_VALUE && time(0) < timer) { - Sleep(10); hPipe = FindFirstFile(buffer, &FindFileData); + Sleep(10); } if(hPipe != INVALID_HANDLE_VALUE) @@ -1165,6 +1178,16 @@ #endif // HAVE_DBUS + int erase_eof(void) + { + return query_intval(HLLAPI_PACKET_ERASE_EOF); + } + + int print(void) + { + return query_intval(HLLAPI_PACKET_PRINT); + } + }; session * session::create_remote(const char *session) diff --git a/src/classlib/testprogram.cc b/src/classlib/testprogram.cc index a6b766a..028a738 100644 --- a/src/classlib/testprogram.cc +++ b/src/classlib/testprogram.cc @@ -39,6 +39,7 @@ { string *s; session *session = session::start("pw3270:a"); +// session *session = session::start("new"); cout << "pw3270 version: " << session->get_version() << endl; cout << "pw3270 revision: " << session->get_revision() << endl << endl; -- libgit2 0.21.2