Commit 36dc653d0911d94bc235819f5924c4523dbca8fc

Authored by Perry Werneck
1 parent 78332e33

Ajustes no módulo hllapi.

src/include/pw3270/hllapi.h
@@ -41,7 +41,7 @@ extern "C" { @@ -41,7 +41,7 @@ extern "C" {
41 41
42 #define HLLAPI_MAXLENGTH 4096 42 #define HLLAPI_MAXLENGTH 4096
43 43
44 - /* Function codes */ 44 + /* Function codes - Reference http://www.ibm.com/support/knowledgecenter/SSEQ5Y_6.0.0/com.ibm.pcomm.doc/books/html/emulator_programming08.htm */
45 #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */ 45 #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */
46 #define HLLAPI_CMD_DISCONNECTPS 2 /**< disconnect presentation space */ 46 #define HLLAPI_CMD_DISCONNECTPS 2 /**< disconnect presentation space */
47 #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */ 47 #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */
@@ -50,7 +50,10 @@ extern &quot;C&quot; { @@ -50,7 +50,10 @@ extern &quot;C&quot; {
50 #define HLLAPI_CMD_SEARCHPS 6 /**< Search the presentation space for a specified string. */ 50 #define HLLAPI_CMD_SEARCHPS 6 /**< Search the presentation space for a specified string. */
51 #define HLLAPI_CMD_QUERYCURSOR 7 /**< Determines the location of the cursor in the presentation space. */ 51 #define HLLAPI_CMD_QUERYCURSOR 7 /**< Determines the location of the cursor in the presentation space. */
52 #define HLLAPI_CMD_COPYPSTOSTR 8 /**< Copy presentation space to string */ 52 #define HLLAPI_CMD_COPYPSTOSTR 8 /**< Copy presentation space to string */
  53 + #define HLLAPI_SET_SESSION_PARAMETERS 9 /**< Lets you change certain default session options in EHLLAPI for all sessions. */
53 #define HLLAPI_CMD_COPYSTRTOPS 15 /**< Copies an ASCII string directly to a specified position in the presentation space. */ 54 #define HLLAPI_CMD_COPYSTRTOPS 15 /**< Copies an ASCII string directly to a specified position in the presentation space. */
  55 + #define HLLAPI_CMD_PAUSE 18 /**< Waits for a specified amount of time. */
  56 + #define HLLAPI_RESET_SYSTEM 21 /**< Reinitializes EHLLAPI to its starting state. */
54 #define HLLAPI_CMD_SETCURSOR 40 /**< Places the cursor at a specified position in presentation space.*/ 57 #define HLLAPI_CMD_SETCURSOR 40 /**< Places the cursor at a specified position in presentation space.*/
55 #define HLLAPI_CMD_SENDFILE 90 /**< Send file to the host */ 58 #define HLLAPI_CMD_SENDFILE 90 /**< Send file to the host */
56 #define HLLAPI_CMD_RECEIVEFILE 91 /**< Receive a file from the host */ 59 #define HLLAPI_CMD_RECEIVEFILE 91 /**< Receive a file from the host */
@@ -149,6 +152,8 @@ extern &quot;C&quot; { @@ -149,6 +152,8 @@ extern &quot;C&quot; {
149 HLLAPI_API_CALL hllapi_init(LPSTR mode); 152 HLLAPI_API_CALL hllapi_init(LPSTR mode);
150 HLLAPI_API_CALL hllapi_deinit(void); 153 HLLAPI_API_CALL hllapi_deinit(void);
151 154
  155 + HLLAPI_API_CALL hllapi_reset(void);
  156 +
152 HLLAPI_API_CALL hllapi_get_revision(void); 157 HLLAPI_API_CALL hllapi_get_revision(void);
153 HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir); 158 HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir);
154 159
src/plugins/hllapi/Makefile.in
@@ -80,6 +80,9 @@ $(BINDBG)$(DLL_NAME).$(VERSION): \ @@ -80,6 +80,9 @@ $(BINDBG)$(DLL_NAME).$(VERSION): \
80 test: \ 80 test: \
81 $(BINDBG)/test@EXEEXT@ 81 $(BINDBG)/test@EXEEXT@
82 82
  83 +cleantest: \
  84 + clean
  85 +
83 cleanDebug: \ 86 cleanDebug: \
84 clean 87 clean
85 88
src/plugins/hllapi/calls.cc
@@ -379,3 +379,12 @@ @@ -379,3 +379,12 @@
379 { 379 {
380 free(p); 380 free(p);
381 } 381 }
  382 +
  383 + HLLAPI_API_CALL hllapi_reset(void)
  384 + {
  385 +
  386 +
  387 + return HLLAPI_STATUS_SUCCESS;
  388 + }
  389 +
  390 +
src/plugins/hllapi/hllapi.c
@@ -47,6 +47,8 @@ @@ -47,6 +47,8 @@
47 static int search_ps(char *buffer, unsigned short *length, unsigned short *rc); 47 static int search_ps(char *buffer, unsigned short *length, unsigned short *rc);
48 static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc); 48 static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc);
49 static int wait_system(char *buffer, unsigned short *length, unsigned short *rc); 49 static int wait_system(char *buffer, unsigned short *length, unsigned short *rc);
  50 + static int reset_system(char *buffer, unsigned short *length, unsigned short *rc);
  51 + static int pause_system(char *buffer, unsigned short *length, unsigned short *rc);
50 52
51 static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); 53 static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);
52 static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); 54 static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);
@@ -75,6 +77,8 @@ @@ -75,6 +77,8 @@
75 { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps }, 77 { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps },
76 { HLLAPI_CMD_SENDFILE, invalid_request }, 78 { HLLAPI_CMD_SENDFILE, invalid_request },
77 { HLLAPI_CMD_RECEIVEFILE, invalid_request }, 79 { HLLAPI_CMD_RECEIVEFILE, invalid_request },
  80 + { HLLAPI_RESET_SYSTEM, reset_system },
  81 + { HLLAPI_CMD_PAUSE, pause_system },
78 82
79 }; 83 };
80 84
@@ -409,14 +413,16 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) @@ -409,14 +413,16 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)
409 /* 413 /*
410 * Return Code Definition 414 * Return Code Definition
411 * 415 *
412 - * 0 The keyboard is unlocked and ready for input.  
413 - * 1 Your application program is not connected to a valid session.  
414 - * 4 Timeout while still in XCLOCK (X []) or XSYSTEM.  
415 - * 5 The keyboard is locked.  
416 - * 9 A system error was encountered. 416 + * HLLAPI_STATUS_SUCCESS 0 The keyboard is unlocked and ready for input.
  417 + * HLLAPI_STATUS_DISCONNECTED 1 Your application program is not connected to a valid session.
  418 + * HLLAPI_STATUS_TIMEOUT 4 Timeout while still in XCLOCK (X []) or XSYSTEM.
  419 + * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The keyboard is locked.
  420 + * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.
417 * 421 *
418 */ 422 */
419 - time_t end = time(0) + 3600; 423 +
  424 + /*
  425 + time_t end = time(0) + 60;
420 426
421 while(time(0) < end) 427 while(time(0) < end)
422 { 428 {
@@ -425,12 +431,16 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) @@ -425,12 +431,16 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)
425 if(state != HLLAPI_STATUS_WAITING) 431 if(state != HLLAPI_STATUS_WAITING)
426 return state; 432 return state;
427 433
428 - if(hllapi_wait(1))  
429 - return HLLAPI_STATUS_SYSTEM_ERROR; 434 + hllapi_wait(1);
430 435
431 } 436 }
432 437
433 return HLLAPI_STATUS_TIMEOUT; 438 return HLLAPI_STATUS_TIMEOUT;
  439 + */
  440 +
  441 + int state = hllapi_wait_for_ready(60);
  442 + return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state);
  443 +
434 } 444 }
435 445
436 static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps) 446 static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps)
@@ -438,19 +448,19 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps @@ -438,19 +448,19 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps
438 /* 448 /*
439 * Call Parameters 449 * Call Parameters
440 * 450 *
441 - * Data String String of ASCII data to be copied into the host presentation space. 451 + * Data String of ASCII data to be copied into the host presentation space.
442 * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode. 452 * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode.
443 - * PS Position Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space. 453 + * PS Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space.
444 * 454 *
445 * Return Parameters 455 * Return Parameters
446 * 456 *
447 - * 0 The Copy String to Presentation Space function was successful.  
448 - * 1 Your program is not connected to a host session.  
449 - * 2 Parameter error or zero length for copy.  
450 - * 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte).  
451 - * 6 The copy was completed, but the data was truncated.  
452 - * 7 The host presentation space position is not valid.  
453 - * 9 A system error was encountered. 457 + * HLLAPI_STATUS_SUCCESS 0 The Copy String to Presentation Space function was successful.
  458 + * HLLAPI_STATUS_DISCONNECTED 1 Your program is not connected to a host session.
  459 + * HLLAPI_STATUS_BAD_PARAMETER 2 Parameter error or zero length for copy.
  460 + * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte).
  461 + * 6 The copy was completed, but the data was truncated.
  462 + * 7 The host presentation space position is not valid.
  463 + * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.
454 * 464 *
455 */ 465 */
456 size_t szText = strlen(text); 466 size_t szText = strlen(text);
@@ -459,7 +469,7 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps @@ -459,7 +469,7 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps
459 szText = *length; 469 szText = *length;
460 470
461 if(!szText) 471 if(!szText)
462 - return 2; 472 + return HLLAPI_STATUS_BAD_PARAMETER;
463 473
464 switch(hllapi_get_message_id()) 474 switch(hllapi_get_message_id())
465 { 475 {
@@ -483,3 +493,13 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps @@ -483,3 +493,13 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps
483 493
484 return hllapi_emulate_input(text,szText,0); 494 return hllapi_emulate_input(text,szText,0);
485 } 495 }
  496 +
  497 +static int reset_system(char *buffer, unsigned short *length, unsigned short *rc)
  498 +{
  499 + return hllapi_reset();
  500 +}
  501 +
  502 +static int pause_system(char *buffer, unsigned short *length, unsigned short *rc)
  503 +{
  504 + return hllapi_wait_for_ready((*length) / 2);
  505 +}
src/plugins/hllapi/testprogram.c
@@ -54,10 +54,12 @@ @@ -54,10 +54,12 @@
54 len = strlen(session); 54 len = strlen(session);
55 hllapi(&fn,hllapi_data,&len,&rc); 55 hllapi(&fn,hllapi_data,&len,&rc);
56 56
  57 + /*
57 if(rc) 58 if(rc)
58 { 59 {
59 trace("HLLAPI_CMD_CONNECTPS(%s) exits with rc=%d", session, (int) rc); 60 trace("HLLAPI_CMD_CONNECTPS(%s) exits with rc=%d", session, (int) rc);
60 } 61 }
  62 + */
61 63
62 } 64 }
63 65