Commit 5559de218fbff25286813a50ec4b4f31a0dcb53c
1 parent
23391401
Exists in
master
and in
5 other branches
Incluindo funcoes extras do hllapi na classe base
Showing
3 changed files
with
43 additions
and
4 deletions
Show diff stats
src/classlib/local.cc
| @@ -305,6 +305,8 @@ | @@ -305,6 +305,8 @@ | ||
| 305 | const char * (*_get_display_charset)(H3270 *hSession); | 305 | const char * (*_get_display_charset)(H3270 *hSession); |
| 306 | int (*_set_host_charset)(H3270 *hSession, const char *name); | 306 | int (*_set_host_charset)(H3270 *hSession, const char *name); |
| 307 | const char * (*_get_host_charset)(H3270 *hSession); | 307 | const char * (*_get_host_charset)(H3270 *hSession); |
| 308 | + int (*_print)(H3270 *hSession); | ||
| 309 | + int (*_erase_eof)(H3270 *hSession); | ||
| 308 | 310 | ||
| 309 | public: | 311 | public: |
| 310 | 312 | ||
| @@ -354,6 +356,8 @@ | @@ -354,6 +356,8 @@ | ||
| 354 | { (void **) & _get_display_charset, "lib3270_get_display_charset" }, | 356 | { (void **) & _get_display_charset, "lib3270_get_display_charset" }, |
| 355 | { (void **) & _set_host_charset, "lib3270_set_host_charset" }, | 357 | { (void **) & _set_host_charset, "lib3270_set_host_charset" }, |
| 356 | { (void **) & _get_host_charset, "lib3270_get_host_charset" }, | 358 | { (void **) & _get_host_charset, "lib3270_get_host_charset" }, |
| 359 | + { (void **) & _erase_eof, "lib3270_eraseeof" }, | ||
| 360 | + { (void **) & _print, "lib3270_print" }, | ||
| 357 | 361 | ||
| 358 | }; | 362 | }; |
| 359 | 363 | ||
| @@ -561,6 +565,17 @@ | @@ -561,6 +565,17 @@ | ||
| 561 | return new string(_get_host_charset(hSession)); | 565 | return new string(_get_host_charset(hSession)); |
| 562 | } | 566 | } |
| 563 | 567 | ||
| 568 | + int erase_eof(void) | ||
| 569 | + { | ||
| 570 | + return _erase_eof(hSession); | ||
| 571 | + } | ||
| 572 | + | ||
| 573 | + int print(void) | ||
| 574 | + { | ||
| 575 | + return _print(hSession); | ||
| 576 | + } | ||
| 577 | + | ||
| 578 | + | ||
| 564 | }; | 579 | }; |
| 565 | 580 | ||
| 566 | session * session::create_local(void) | 581 | session * session::create_local(void) |
src/classlib/remote.cc
| @@ -55,6 +55,8 @@ | @@ -55,6 +55,8 @@ | ||
| 55 | #define HLLAPI_PACKET_GET_CURSOR "getCursorAddress" | 55 | #define HLLAPI_PACKET_GET_CURSOR "getCursorAddress" |
| 56 | #define HLLAPI_PACKET_ENTER "enter" | 56 | #define HLLAPI_PACKET_ENTER "enter" |
| 57 | #define HLLAPI_PACKET_QUIT "quit" | 57 | #define HLLAPI_PACKET_QUIT "quit" |
| 58 | + #define HLLAPI_PACKET_ERASE_EOF "eraseEOF" | ||
| 59 | + #define HLLAPI_PACKET_PRINT "print" | ||
| 58 | #endif // WIN32 | 60 | #endif // WIN32 |
| 59 | 61 | ||
| 60 | #include <pw3270/class.h> | 62 | #include <pw3270/class.h> |
| @@ -300,7 +302,12 @@ | @@ -300,7 +302,12 @@ | ||
| 300 | 302 | ||
| 301 | // Get application path | 303 | // Get application path |
| 302 | *appName = 0; | 304 | *appName = 0; |
| 303 | - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) | 305 | + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) != ERROR_SUCCESS) |
| 306 | + { | ||
| 307 | + throw exception("Can't open key %s","HKLM\\Software\\pw3270"); | ||
| 308 | + return; | ||
| 309 | + } | ||
| 310 | + else | ||
| 304 | { | 311 | { |
| 305 | unsigned long datatype; // #defined in winnt.h (predefined types 0-11) | 312 | unsigned long datatype; // #defined in winnt.h (predefined types 0-11) |
| 306 | if(RegQueryValueExA(hKey,"appName",NULL,&datatype,(LPBYTE) appName,&datalen) != ERROR_SUCCESS) | 313 | if(RegQueryValueExA(hKey,"appName",NULL,&datatype,(LPBYTE) appName,&datalen) != ERROR_SUCCESS) |
| @@ -308,6 +315,12 @@ | @@ -308,6 +315,12 @@ | ||
| 308 | RegCloseKey(hKey); | 315 | RegCloseKey(hKey); |
| 309 | } | 316 | } |
| 310 | 317 | ||
| 318 | + if(!*appName) | ||
| 319 | + { | ||
| 320 | + throw exception("key %s\\appName is invalid","HKLM\\Software\\pw3270"); | ||
| 321 | + return; | ||
| 322 | + } | ||
| 323 | + | ||
| 311 | trace("%s appname=%s\n",__FUNCTION__,appName); | 324 | trace("%s appname=%s\n",__FUNCTION__,appName); |
| 312 | 325 | ||
| 313 | snprintf(buffer,79,"%s --session=\"H%06d\"",appName,getpid()); | 326 | snprintf(buffer,79,"%s --session=\"H%06d\"",appName,getpid()); |
| @@ -327,7 +340,7 @@ | @@ -327,7 +340,7 @@ | ||
| 327 | } | 340 | } |
| 328 | else | 341 | else |
| 329 | { | 342 | { |
| 330 | - throw exception("Can't start %s session",PACKAGE_NAME); | 343 | + throw exception("Can't start %s",appName); |
| 331 | return; | 344 | return; |
| 332 | } | 345 | } |
| 333 | 346 | ||
| @@ -354,11 +367,11 @@ | @@ -354,11 +367,11 @@ | ||
| 354 | 367 | ||
| 355 | free(str); | 368 | free(str); |
| 356 | 369 | ||
| 357 | - timer = time(0)+5; | 370 | + timer = time(0)+20; |
| 358 | while(hPipe == INVALID_HANDLE_VALUE && time(0) < timer) | 371 | while(hPipe == INVALID_HANDLE_VALUE && time(0) < timer) |
| 359 | { | 372 | { |
| 360 | - Sleep(10); | ||
| 361 | hPipe = FindFirstFile(buffer, &FindFileData); | 373 | hPipe = FindFirstFile(buffer, &FindFileData); |
| 374 | + Sleep(10); | ||
| 362 | } | 375 | } |
| 363 | 376 | ||
| 364 | if(hPipe != INVALID_HANDLE_VALUE) | 377 | if(hPipe != INVALID_HANDLE_VALUE) |
| @@ -1165,6 +1178,16 @@ | @@ -1165,6 +1178,16 @@ | ||
| 1165 | 1178 | ||
| 1166 | #endif // HAVE_DBUS | 1179 | #endif // HAVE_DBUS |
| 1167 | 1180 | ||
| 1181 | + int erase_eof(void) | ||
| 1182 | + { | ||
| 1183 | + return query_intval(HLLAPI_PACKET_ERASE_EOF); | ||
| 1184 | + } | ||
| 1185 | + | ||
| 1186 | + int print(void) | ||
| 1187 | + { | ||
| 1188 | + return query_intval(HLLAPI_PACKET_PRINT); | ||
| 1189 | + } | ||
| 1190 | + | ||
| 1168 | }; | 1191 | }; |
| 1169 | 1192 | ||
| 1170 | session * session::create_remote(const char *session) | 1193 | session * session::create_remote(const char *session) |
src/classlib/testprogram.cc
| @@ -39,6 +39,7 @@ | @@ -39,6 +39,7 @@ | ||
| 39 | { | 39 | { |
| 40 | string *s; | 40 | string *s; |
| 41 | session *session = session::start("pw3270:a"); | 41 | session *session = session::start("pw3270:a"); |
| 42 | +// session *session = session::start("new"); | ||
| 42 | 43 | ||
| 43 | cout << "pw3270 version: " << session->get_version() << endl; | 44 | cout << "pw3270 version: " << session->get_version() << endl; |
| 44 | cout << "pw3270 revision: " << session->get_revision() << endl << endl; | 45 | cout << "pw3270 revision: " << session->get_revision() << endl << endl; |